don't crash LibCecSharp when receiving an alert with a NULL param (like the connectio...
[deb_libcec.git] / src / lib / LibCEC.cpp
CommitLineData
2abe74eb
LOK
1/*
2 * This file is part of the libCEC(R) library.
3 *
16f47961 4 * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited. All rights reserved.
2abe74eb
LOK
5 * libCEC(R) is an original work, containing original code.
6 *
7 * libCEC(R) is a trademark of Pulse-Eight Limited.
8 *
9 * This program is dual-licensed; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 *
23 *
24 * Alternatively, you can license this library under a commercial license,
25 * please contact Pulse-Eight Licensing for more information.
26 *
27 * For more information contact:
28 * Pulse-Eight Licensing <license@pulse-eight.com>
29 * http://www.pulse-eight.com/
30 * http://www.pulse-eight.net/
31 */
32
2b44051c 33#include "env.h"
2abe74eb
LOK
34#include "LibCEC.h"
35
2b44051c
LOK
36#include "adapter/AdapterFactory.h"
37#include "adapter/AdapterCommunication.h"
2abe74eb 38#include "CECProcessor.h"
004b8382 39#include "devices/CECAudioSystem.h"
0f23c85c 40#include "devices/CECBusDevice.h"
004b8382
LOK
41#include "devices/CECPlaybackDevice.h"
42#include "devices/CECTV.h"
ba65909d
LOK
43#include "platform/util/timeutils.h"
44#include "platform/util/StdString.h"
c9d15485 45#include "platform/util/util.h"
2abe74eb 46
004b8382
LOK
47#include "CECClient.h"
48
2abe74eb
LOK
49using namespace std;
50using namespace CEC;
f00ff009 51using namespace PLATFORM;
2abe74eb 52
cd7a6c70 53CLibCEC::CLibCEC(void) :
c30acafa
LOK
54 m_iStartTime(GetTimeMs()),
55 m_client(NULL)
caca2d81 56{
004b8382 57 m_cec = new CCECProcessor(this);
f8513317
LOK
58}
59
2abe74eb
LOK
60CLibCEC::~CLibCEC(void)
61{
c0152c09
LOK
62 // unregister all clients client
63 UnregisterClients();
64
65 // delete the adapter connection
c9d15485 66 DELETE_AND_NULL(m_cec);
2abe74eb
LOK
67}
68
b32ffd87 69bool CLibCEC::Open(const char *strPort, uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */)
2abe74eb 70{
c0152c09 71 if (!m_cec || !strPort)
99aeafb9
LOK
72 return false;
73
c0152c09 74 // open a new connection
b32ffd87 75 if (!m_cec->Start(strPort, CEC_SERIAL_DEFAULT_BAUDRATE, iTimeoutMs))
2abe74eb
LOK
76 {
77 AddLog(CEC_LOG_ERROR, "could not start CEC communications");
78 return false;
79 }
80
c0152c09 81 // register all clients
004b8382
LOK
82 for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
83 {
84 if (!m_cec->RegisterClient(*it))
85 {
86 AddLog(CEC_LOG_ERROR, "failed to register a CEC client");
87 return false;
88 }
89 }
90
2abe74eb
LOK
91 return true;
92}
93
94void CLibCEC::Close(void)
95{
af205cf4
LOK
96 if (!m_cec)
97 return;
98
c0152c09 99 // unregister all clients
af205cf4 100 m_cec->UnregisterClients();
c0152c09
LOK
101
102 // close the connection
af205cf4 103 m_cec->Close();
fa4798bd
LOK
104}
105
25701fa6 106int8_t CLibCEC::FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, const char *strDevicePath /* = NULL */)
2abe74eb 107{
2b44051c 108 return CAdapterFactory(this).FindAdapters(deviceList, iBufSize, strDevicePath);
2abe74eb
LOK
109}
110
2abe74eb
LOK
111bool CLibCEC::StartBootloader(void)
112{
1113cb7d 113 return m_cec ? m_cec->StartBootloader() : false;
2abe74eb
LOK
114}
115
c0152c09 116bool CLibCEC::PingAdapter(void)
2abe74eb 117{
c0152c09 118 return m_client ? m_client->PingAdapter() : false;
2abe74eb
LOK
119}
120
c0152c09 121bool CLibCEC::EnableCallbacks(void *cbParam, ICECCallbacks *callbacks)
a9232a79 122{
c0152c09 123 return m_client ? m_client->EnableCallbacks(cbParam, callbacks) : false;
a9232a79
LOK
124}
125
c0152c09 126bool CLibCEC::GetCurrentConfiguration(libcec_configuration *configuration)
2abe74eb 127{
c0152c09 128 return m_client ? m_client->GetCurrentConfiguration(*configuration) : false;
2abe74eb
LOK
129}
130
c0152c09 131bool CLibCEC::SetConfiguration(const libcec_configuration *configuration)
28fa6c97 132{
c0152c09 133 return m_client ? m_client->SetConfiguration(*configuration) : false;
28fa6c97
LOK
134}
135
004b8382 136bool CLibCEC::CanPersistConfiguration(void)
1969b140 137{
c0152c09 138 return m_client ? m_client->CanPersistConfiguration() : false;
1969b140
LOK
139}
140
004b8382 141bool CLibCEC::PersistConfiguration(libcec_configuration *configuration)
8b7e5ff6 142{
c0152c09 143 return m_client ? m_client->PersistConfiguration(*configuration) : false;
8b7e5ff6
LOK
144}
145
004b8382 146void CLibCEC::RescanActiveDevices(void)
6a1c0009 147{
c0152c09
LOK
148 if (m_client)
149 m_client->RescanActiveDevices();
44c74256
LOK
150}
151
c0152c09 152bool CLibCEC::IsLibCECActiveSource(void)
eab72c40 153{
c0152c09 154 return m_client ? m_client->IsLibCECActiveSource() : false;
eab72c40
LOK
155}
156
004b8382 157bool CLibCEC::Transmit(const cec_command &data)
b4b1b49b 158{
2b44051c 159 return m_client ? m_client->Transmit(data, false) : false;
b4b1b49b
LOK
160}
161
004b8382 162bool CLibCEC::SetLogicalAddress(cec_logical_address iLogicalAddress)
b4b1b49b 163{
004b8382 164 return m_client ? m_client->SetLogicalAddress(iLogicalAddress) : false;
b4b1b49b
LOK
165}
166
004b8382 167bool CLibCEC::SetPhysicalAddress(uint16_t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS */)
e55f3f70 168{
004b8382 169 return m_client ? m_client->SetPhysicalAddress(iPhysicalAddress) : false;
e55f3f70 170}
44c74256 171
004b8382 172bool CLibCEC::SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort /* = CEC_DEFAULT_HDMI_PORT */)
57f45e6c 173{
004b8382 174 return m_client ? m_client->SetHDMIPort(iBaseDevice, iPort) : false;
57f45e6c
LOK
175}
176
004b8382 177bool CLibCEC::PowerOnDevices(cec_logical_address address /* = CECDEVICE_TV */)
6d858ba4 178{
004b8382 179 return m_client ? m_client->SendPowerOnDevices(address) : false;
6d858ba4
LOK
180}
181
004b8382 182bool CLibCEC::StandbyDevices(cec_logical_address address /* = CECDEVICE_BROADCAST */)
6d858ba4 183{
004b8382 184 return m_client ? m_client->SendStandbyDevices(address) : false;
6d858ba4
LOK
185}
186
004b8382 187bool CLibCEC::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RESERVED */)
6d858ba4 188{
004b8382 189 return m_client ? m_client->SendSetActiveSource(type) : false;
6d858ba4
LOK
190}
191
004b8382 192bool CLibCEC::SetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate /* = true */)
04e637f9 193{
004b8382 194 return m_client ? m_client->SendSetDeckControlMode(mode, bSendUpdate) : false;
04e637f9
LOK
195}
196
004b8382 197bool CLibCEC::SetDeckInfo(cec_deck_info info, bool bSendUpdate /* = true */)
04e637f9 198{
004b8382 199 return m_client ? m_client->SendSetDeckInfo(info, bSendUpdate) : false;
04e637f9
LOK
200}
201
004b8382 202bool CLibCEC::SetInactiveView(void)
04e637f9 203{
004b8382 204 return m_client ? m_client->SendSetInactiveView() : false;
04e637f9
LOK
205}
206
004b8382 207bool CLibCEC::SetMenuState(cec_menu_state state, bool bSendUpdate /* = true */)
a33794d8 208{
004b8382 209 return m_client ? m_client->SendSetMenuState(state, bSendUpdate) : false;
a33794d8
LOK
210}
211
004b8382 212bool CLibCEC::SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage)
a33794d8 213{
004b8382 214 return m_client ? m_client->SendSetOSDString(iLogicalAddress, duration, strMessage) : false;
a33794d8
LOK
215}
216
c0152c09
LOK
217bool CLibCEC::SwitchMonitoring(bool bEnable)
218{
219 return m_client ? m_client->SwitchMonitoring(bEnable) : false;
220}
221
004b8382 222cec_version CLibCEC::GetDeviceCecVersion(cec_logical_address iAddress)
ed21be2a 223{
004b8382 224 return m_client ? m_client->GetDeviceCecVersion(iAddress) : CEC_VERSION_UNKNOWN;
ed21be2a
LOK
225}
226
004b8382 227bool CLibCEC::GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language)
2abe74eb 228{
c0152c09 229 return m_client ? m_client->GetDeviceMenuLanguage(iAddress, *language) : false;
2abe74eb
LOK
230}
231
004b8382 232uint64_t CLibCEC::GetDeviceVendorId(cec_logical_address iAddress)
95ba7a09 233{
004b8382 234 return m_client ? m_client->GetDeviceVendorId(iAddress) : (uint64_t)CEC_VENDOR_UNKNOWN;
02e7043e
LOK
235}
236
004b8382 237uint16_t CLibCEC::GetDevicePhysicalAddress(cec_logical_address iAddress)
32403cc3 238{
004b8382 239 return m_client ? m_client->GetDevicePhysicalAddress(iAddress) : CEC_INVALID_PHYSICAL_ADDRESS;
32403cc3
LOK
240}
241
004b8382 242cec_power_status CLibCEC::GetDevicePowerStatus(cec_logical_address iAddress)
02e7043e 243{
004b8382 244 return m_client ? m_client->GetDevicePowerStatus(iAddress) : CEC_POWER_STATUS_UNKNOWN;
95ba7a09
LOK
245}
246
c0152c09
LOK
247bool CLibCEC::PollDevice(cec_logical_address iAddress)
248{
249 return m_client ? m_client->PollDevice(iAddress) : false;
250}
251
252cec_logical_addresses CLibCEC::GetActiveDevices(void)
253{
254 cec_logical_addresses addresses;
255 addresses.Clear();
256 if (m_client)
257 addresses = m_client->GetActiveDevices();
258 return addresses;
259}
260
261bool CLibCEC::IsActiveDevice(cec_logical_address iAddress)
262{
263 return m_client ? m_client->IsActiveDevice(iAddress) : false;
264}
265
266bool CLibCEC::IsActiveDeviceType(cec_device_type type)
267{
268 return m_client ? m_client->IsActiveDeviceType(type) : false;
269}
270
004b8382 271uint8_t CLibCEC::VolumeUp(bool bSendRelease /* = true */)
2abe74eb 272{
004b8382 273 return m_client ? m_client->SendVolumeUp(bSendRelease) : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN;
2abe74eb
LOK
274}
275
004b8382 276uint8_t CLibCEC::VolumeDown(bool bSendRelease /* = true */)
2abe74eb 277{
004b8382 278 return m_client ? m_client->SendVolumeDown(bSendRelease) : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN;
2abe74eb
LOK
279}
280
004b8382 281uint8_t CLibCEC::MuteAudio(bool UNUSED(bSendRelease) /* = true */)
b1c47f9d 282{
6d2bc8de 283 AddLog(CEC_LOG_WARNING, "deprecated function called: %s", __FUNCTION__);
004b8382 284 return m_client ? m_client->SendMuteAudio() : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN;
b1c47f9d
LOK
285}
286
004b8382 287bool CLibCEC::SendKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait /* = true */)
2abe74eb 288{
004b8382 289 return m_client ? m_client->SendKeypress(iDestination, key, bWait) : false;
2abe74eb
LOK
290}
291
004b8382 292bool CLibCEC::SendKeyRelease(cec_logical_address iDestination, bool bWait /* = true */)
e1804a4e 293{
004b8382 294 return m_client ? m_client->SendKeyRelease(iDestination, bWait) : false;
e1804a4e
LOK
295}
296
004b8382 297cec_osd_name CLibCEC::GetDeviceOSDName(cec_logical_address iAddress)
f42d3e0f 298{
004b8382 299 cec_osd_name retVal;
20505741
LOK
300 retVal.device = CECDEVICE_UNKNOWN;
301 memset(retVal.name, 0, 14);
302
004b8382
LOK
303 if (m_client)
304 retVal = m_client->GetDeviceOSDName(iAddress);
305 return retVal;
f42d3e0f
LOK
306}
307
c0152c09
LOK
308cec_logical_address CLibCEC::GetActiveSource(void)
309{
310 return m_client ? m_client->GetActiveSource() : CECDEVICE_UNKNOWN;
311}
312
313bool CLibCEC::IsActiveSource(cec_logical_address iAddress)
314{
315 return m_client ? m_client->IsActiveSource(iAddress) : false;
316}
317bool CLibCEC::SetStreamPath(cec_logical_address iAddress)
318{
319 return m_client ? m_client->SetStreamPath(iAddress) : false;
320}
321
322bool CLibCEC::SetStreamPath(uint16_t iPhysicalAddress)
323{
324 return m_client ? m_client->SetStreamPath(iPhysicalAddress) : false;
325}
326
004b8382 327cec_logical_addresses CLibCEC::GetLogicalAddresses(void)
f42d3e0f 328{
004b8382 329 cec_logical_addresses addresses;
c30acafa 330 addresses.Clear();
c0152c09 331 if (m_client)
6d503311 332 addresses = m_client->GetLogicalAddresses();
004b8382 333 return addresses;
f42d3e0f
LOK
334}
335
004b8382 336cec_device_type CLibCEC::GetType(cec_logical_address address)
f8513317 337{
0d800fe5 338 return CCECTypeUtils::GetType(address);
f8513317
LOK
339}
340
004b8382 341uint16_t CLibCEC::GetMaskForType(cec_logical_address address)
caca2d81 342{
0d800fe5 343 return CCECTypeUtils::GetMaskForType(address);
caca2d81
LOK
344}
345
004b8382 346uint16_t CLibCEC::GetMaskForType(cec_device_type type)
a2198e5e 347{
0d800fe5 348 return CCECTypeUtils::GetMaskForType(type);
004b8382 349}
08d80226 350
004b8382
LOK
351bool CLibCEC::IsValidPhysicalAddress(uint16_t iPhysicalAddress)
352{
353 return iPhysicalAddress >= CEC_MIN_PHYSICAL_ADDRESS &&
354 iPhysicalAddress <= CEC_MAX_PHYSICAL_ADDRESS;
a2198e5e
LOK
355}
356
004b8382 357void CLibCEC::CheckKeypressTimeout(void)
a75e3a5a 358{
004b8382
LOK
359 // check all clients
360 for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
361 (*it)->CheckKeypressTimeout();
a75e3a5a
LOK
362}
363
004b8382 364void CLibCEC::AddLog(const cec_log_level level, const char *strFormat, ...)
d40928b5 365{
004b8382
LOK
366 CStdString strLog;
367
c0152c09 368 // format the message
004b8382
LOK
369 va_list argList;
370 va_start(argList, strFormat);
371 strLog.FormatV(strFormat, argList);
372 va_end(argList);
373
374 cec_log_message message;
375 message.level = level;
376 message.time = GetTimeMs() - m_iStartTime;
377 snprintf(message.message, sizeof(message.message), "%s", strLog.c_str());
378
379 // send the message to all clients
380 for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
381 (*it)->AddLog(message);
224ea877
LOK
382}
383
5d19989f
LOK
384void CLibCEC::AddCommand(const cec_command &command)
385{
386 // send the command to all clients
387 for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
388 (*it)->AddCommand(command);
389}
390
004b8382 391void CLibCEC::Alert(const libcec_alert type, const libcec_parameter &param)
30b4aac0 392{
004b8382
LOK
393 // send the alert to all clients
394 for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
395 (*it)->Alert(type, param);
30b4aac0
LOK
396}
397
c0152c09 398CCECClient *CLibCEC::RegisterClient(libcec_configuration &configuration)
3efda01a 399{
004b8382
LOK
400 if (!m_cec)
401 return NULL;
402
c0152c09 403 // create a new client instance
004b8382
LOK
404 CCECClient *newClient = new CCECClient(m_cec, configuration);
405 if (!newClient)
406 return NULL;
004b8382 407 m_clients.push_back(newClient);
c0152c09
LOK
408
409 // if the default client isn't set, set it
004b8382
LOK
410 if (!m_client)
411 m_client = newClient;
412
c0152c09 413 // register the new client
0b8c7eab 414 if (m_cec->CECInitialised())
004b8382
LOK
415 m_cec->RegisterClient(newClient);
416
99aeafb9 417 return newClient;
3efda01a 418}
c9549d35 419
004b8382 420void CLibCEC::UnregisterClients(void)
c9549d35 421{
aaff5cee 422 if (m_cec && m_cec->IsRunning())
c0152c09
LOK
423 m_cec->UnregisterClients();
424
004b8382 425 m_clients.clear();
c0152c09 426
c9d15485 427 DELETE_AND_NULL(m_client);
c9549d35 428}
9878069e 429
004b8382 430void * CECInitialise(libcec_configuration *configuration)
9878069e 431{
004b8382
LOK
432 if (!configuration)
433 return NULL;
434
c0152c09 435 // create a new libCEC instance
cd7a6c70 436 CLibCEC *lib = new CLibCEC;
c0152c09
LOK
437
438 // register a new client
99aeafb9 439 CCECClient *client(NULL);
c0152c09
LOK
440 if (lib && configuration)
441 client = lib->RegisterClient(*configuration);
99aeafb9 442
c0152c09 443 // update the current configuration
99aeafb9 444 if (client)
c0152c09 445 client->GetCurrentConfiguration(*configuration);
99aeafb9
LOK
446
447 // ensure that the correct server version is set
448 configuration->serverVersion = LIBCEC_VERSION_CURRENT;
004b8382
LOK
449
450 return static_cast< void* > (lib);
9878069e 451}
209b7a5c 452
38f1fbcc 453void * CECInit(const char *strDeviceName, CEC::cec_device_type_list types)
209b7a5c 454{
38f1fbcc 455 libcec_configuration configuration; configuration.Clear();
004b8382
LOK
456
457 // client version < 1.5.0
458 snprintf(configuration.strDeviceName, 13, "%s", strDeviceName);
459 configuration.deviceTypes = types;
aa169fd7 460 configuration.iPhysicalAddress = CEC_INVALID_PHYSICAL_ADDRESS;
004b8382
LOK
461
462 if (configuration.deviceTypes.IsEmpty())
463 configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
464
465 return CECInitialise(&configuration);
209b7a5c
LOK
466}
467
004b8382 468bool CECStartBootloader(void)
209b7a5c 469{
004b8382
LOK
470 bool bReturn(false);
471 cec_adapter deviceList[1];
2b44051c 472 if (CAdapterFactory(NULL).FindAdapters(deviceList, 1, 0) > 0)
209b7a5c 473 {
2b44051c
LOK
474 CAdapterFactory factory(NULL);
475 IAdapterCommunication *comm = factory.GetInstance(deviceList[0].comm);
476 if (comm)
209b7a5c 477 {
2b44051c
LOK
478 CTimeout timeout(CEC_DEFAULT_CONNECT_TIMEOUT);
479 while (timeout.TimeLeft() > 0 &&
480 (bReturn = comm->Open(timeout.TimeLeft() / CEC_CONNECT_TRIES, true)) == false)
481 {
482 comm->Close();
483 CEvent::Sleep(500);
484 }
485 if (comm->IsOpen())
486 bReturn = comm->StartBootloader();
487
488 delete comm;
209b7a5c 489 }
209b7a5c 490 }
004b8382
LOK
491
492 return bReturn;
493}
494
495void CECDestroy(CEC::ICECAdapter *instance)
496{
c9d15485 497 DELETE_AND_NULL(instance);
209b7a5c 498}
f80cd208 499
b32ffd87 500bool CLibCEC::GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */)
f80cd208
LOK
501{
502 if (m_cec->IsRunning())
503 return false;
004b8382 504
f80cd208 505 return m_cec->GetDeviceInformation(strPort, config, iTimeoutMs);
a75e3a5a 506}
c30acafa 507
2b44051c
LOK
508const char *CLibCEC::GetLibInfo(void)
509{
510#ifndef LIB_INFO
511#ifdef _WIN32
512#define FEATURES "'P8 USB' 'P8 USB detect'"
513#ifdef _WIN64
514#define HOST_TYPE "Windows (x64)"
515#else
516#define HOST_TYPE "Windows (x86)"
517#endif
518#else
519#define HOST_TYPE "unknown"
520#define FEATURES "unknown"
521#endif
522
523 return "host: " HOST_TYPE ", features: " FEATURES ", compiled: " __DATE__;
524#else
525 return LIB_INFO;
526#endif
527}
528
2b44051c
LOK
529void CLibCEC::InitVideoStandalone(void)
530{
531 CAdapterFactory::InitVideoStandalone();
532}
8768aeca
LOK
533uint16_t CLibCEC::GetAdapterVendorId(void) const
534{
535 return m_cec && m_cec->IsRunning() ? m_cec->GetAdapterVendorId() : 0;
536}
537
538uint16_t CLibCEC::GetAdapterProductId(void) const
539{
540 return m_cec && m_cec->IsRunning() ? m_cec->GetAdapterProductId() : 0;
541}
6d2bc8de
LOK
542
543uint8_t CLibCEC::AudioToggleMute(void)
544{
545 return m_client ? m_client->AudioToggleMute() : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN;
546}
547
548uint8_t CLibCEC::AudioMute(void)
549{
550 return m_client ? m_client->AudioMute() : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN;
551}
552
553uint8_t CLibCEC::AudioUnmute(void)
554{
555 return m_client ? m_client->AudioUnmute() : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN;
556}
557
558uint8_t CLibCEC::AudioStatus(void)
559{
560 return m_client ? m_client->AudioStatus() : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN;
561}
e7fd53c8 562
bfea6e0a 563int8_t CLibCEC::DetectAdapters(cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath /* = NULL */, bool bQuickScan /* = false */)
e7fd53c8
LOK
564{
565 int8_t iAdaptersFound = CAdapterFactory(this).DetectAdapters(deviceList, iBufSize, strDevicePath);
bfea6e0a 566 if (!bQuickScan)
e7fd53c8 567 {
bfea6e0a
LOK
568 for (int8_t iPtr = 0; iPtr < iAdaptersFound; iPtr++)
569 {
570 libcec_configuration config;
571 GetDeviceInformation(deviceList[iPtr].strComName, &config);
572 deviceList[iPtr].iFirmwareVersion = config.iFirmwareVersion;
573 deviceList[iPtr].iPhysicalAddress = config.iPhysicalAddress;
574 deviceList[iPtr].iFirmwareBuildDate = config.iFirmwareBuildDate;
575 deviceList[iPtr].adapterType = config.adapterType;
576 }
e7fd53c8
LOK
577 }
578 return iAdaptersFound;
579}