2 * This file is part of the libCEC(R) library.
4 * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved.
5 * libCEC(R) is an original work, containing original code.
7 * libCEC(R) is a trademark of Pulse-Eight Limited.
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.
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.
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.
24 * Alternatively, you can license this library under a commercial license,
25 * please contact Pulse-Eight Licensing for more information.
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/
33 #include "CECProcessor.h"
35 #include "adapter/USBCECAdapterCommunication.h"
36 #include "devices/CECBusDevice.h"
37 #include "devices/CECAudioSystem.h"
38 #include "devices/CECPlaybackDevice.h"
39 #include "devices/CECRecordingDevice.h"
40 #include "devices/CECTuner.h"
41 #include "devices/CECTV.h"
42 #include "implementations/CECCommandHandler.h"
44 #include "CECClient.h"
45 #include "CECTypeUtils.h"
46 #include "platform/util/timeutils.h"
47 #include "platform/util/util.h"
51 using namespace PLATFORM
;
53 #define CEC_PROCESSOR_SIGNAL_WAIT_TIME 1000
55 #define ToString(x) CCECTypeUtils::ToString(x)
57 CCECProcessor::CCECProcessor(CLibCEC
*libcec
) :
58 m_bInitialised(false),
59 m_communication(NULL
),
61 m_iStandardLineTimeout(3),
62 m_iRetryLineTimeout(3),
63 m_iLastTransmission(0)
65 m_busDevices
= new CCECDeviceMap(this);
68 CCECProcessor::~CCECProcessor(void)
71 DELETE_AND_NULL(m_busDevices
);
74 bool CCECProcessor::Start(const char *strPort
, uint16_t iBaudRate
/* = CEC_SERIAL_DEFAULT_BAUDRATE */, uint32_t iTimeoutMs
/* = CEC_DEFAULT_CONNECT_TIMEOUT */)
76 CLockObject
lock(m_mutex
);
78 if (!OpenConnection(strPort
, iBaudRate
, iTimeoutMs
))
81 // create the processor thread
86 m_libcec
->AddLog(CEC_LOG_ERROR
, "could not create a processor thread");
94 void CCECProcessor::Close(void)
96 // mark as uninitialised
97 SetCECInitialised(false);
102 // close the connection
103 DELETE_AND_NULL(m_communication
);
106 void CCECProcessor::ResetMembers(void)
108 // close the connection
109 DELETE_AND_NULL(m_communication
);
111 // reset the other members to the initial state
112 m_iStandardLineTimeout
= 3;
113 m_iRetryLineTimeout
= 3;
114 m_iLastTransmission
= 0;
115 m_busDevices
->ResetDeviceStatus();
118 bool CCECProcessor::OpenConnection(const char *strPort
, uint16_t iBaudRate
, uint32_t iTimeoutMs
, bool bStartListening
/* = true */)
121 CTimeout
timeout(iTimeoutMs
> 0 ? iTimeoutMs
: CEC_DEFAULT_TRANSMIT_WAIT
);
123 // ensure that a previous connection is closed
126 // reset all member to the initial state
129 // check whether the Close() method deleted any previous connection
132 m_libcec
->AddLog(CEC_LOG_ERROR
, "previous connection could not be closed");
136 // create a new connection
137 m_communication
= new CUSBCECAdapterCommunication(this, strPort
, iBaudRate
);
139 // open a new connection
140 unsigned iConnectTry(0);
141 while (timeout
.TimeLeft() > 0 && (bReturn
= m_communication
->Open((timeout
.TimeLeft() / CEC_CONNECT_TRIES
), false, bStartListening
)) == false)
143 m_libcec
->AddLog(CEC_LOG_ERROR
, "could not open a connection (try %d)", ++iConnectTry
);
144 m_communication
->Close();
145 CEvent::Sleep(CEC_DEFAULT_CONNECT_RETRY_WAIT
);
148 m_libcec
->AddLog(CEC_LOG_NOTICE
, "connection opened");
150 // always start by setting the ackmask to 0, to clear previous values
153 // mark as initialised
154 SetCECInitialised(true);
159 bool CCECProcessor::CECInitialised(void)
161 CLockObject
lock(m_threadMutex
);
162 return m_bInitialised
;
165 void CCECProcessor::SetCECInitialised(bool bSetTo
/* = true */)
168 CLockObject
lock(m_mutex
);
169 m_bInitialised
= bSetTo
;
175 bool CCECProcessor::TryLogicalAddress(cec_logical_address address
)
178 CCECBusDevice
*device
= m_busDevices
->At(address
);
181 // check if it's already marked as present or used
182 if (device
->IsPresent() || device
->IsHandledByLibCEC())
185 // poll the LA if not
187 return device
->TryLogicalAddress();
193 void CCECProcessor::ReplaceHandlers(void)
195 if (!CECInitialised())
199 for (CECDEVICEMAP::iterator it
= m_busDevices
->Begin(); it
!= m_busDevices
->End(); it
++)
200 it
->second
->ReplaceHandler(true);
203 bool CCECProcessor::OnCommandReceived(const cec_command
&command
)
205 return m_inBuffer
.Push(command
);
208 void *CCECProcessor::Process(void)
210 m_libcec
->AddLog(CEC_LOG_DEBUG
, "processor thread started");
214 // as long as we're not being stopped and the connection is open
215 while (!IsStopped() && m_communication
->IsOpen())
217 // wait for a new incoming command, and process it
218 if (m_inBuffer
.Pop(command
, CEC_PROCESSOR_SIGNAL_WAIT_TIME
))
219 ProcessCommand(command
);
221 if (CECInitialised())
223 // check clients for keypress timeouts
224 m_libcec
->CheckKeypressTimeout();
226 // check if we need to replace handlers
234 bool CCECProcessor::ActivateSource(uint16_t iStreamPath
)
238 // find the device with the given PA
239 CCECBusDevice
*device
= GetDeviceByPhysicalAddress(iStreamPath
);
240 // and make it the active source when found
242 bReturn
= device
->ActivateSource();
244 m_libcec
->AddLog(CEC_LOG_DEBUG
, "device with PA '%04x' not found", iStreamPath
);
249 void CCECProcessor::SetStandardLineTimeout(uint8_t iTimeout
)
251 CLockObject
lock(m_mutex
);
252 m_iStandardLineTimeout
= iTimeout
;
255 uint8_t CCECProcessor::GetStandardLineTimeout(void)
257 CLockObject
lock(m_mutex
);
258 return m_iStandardLineTimeout
;
261 void CCECProcessor::SetRetryLineTimeout(uint8_t iTimeout
)
263 CLockObject
lock(m_mutex
);
264 m_iRetryLineTimeout
= iTimeout
;
267 uint8_t CCECProcessor::GetRetryLineTimeout(void)
269 CLockObject
lock(m_mutex
);
270 return m_iRetryLineTimeout
;
273 bool CCECProcessor::PhysicalAddressInUse(uint16_t iPhysicalAddress
)
275 CCECBusDevice
*device
= GetDeviceByPhysicalAddress(iPhysicalAddress
);
276 return device
!= NULL
;
279 void CCECProcessor::LogOutput(const cec_command
&data
)
283 // initiator and destination
284 strTx
.Format("<< %02x", ((uint8_t)data
.initiator
<< 4) + (uint8_t)data
.destination
);
288 strTx
.AppendFormat(":%02x", (uint8_t)data
.opcode
);
290 // append the parameters
291 for (uint8_t iPtr
= 0; iPtr
< data
.parameters
.size
; iPtr
++)
292 strTx
.AppendFormat(":%02x", data
.parameters
[iPtr
]);
295 m_libcec
->AddLog(CEC_LOG_TRAFFIC
, strTx
.c_str());
298 bool CCECProcessor::PollDevice(cec_logical_address iAddress
)
300 // try to find the primary device
301 CCECBusDevice
*primary
= GetPrimaryDevice();
302 // poll the destination, with the primary as source
304 return primary
->TransmitPoll(iAddress
);
306 // try to find the destination
307 CCECBusDevice
*device
= m_busDevices
->At(iAddress
);
308 // and poll the destination, with the same LA as source
310 return device
->TransmitPoll(iAddress
);
315 CCECBusDevice
*CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress
, bool bSuppressUpdate
/* = true */)
317 return m_busDevices
?
318 m_busDevices
->GetDeviceByPhysicalAddress(iPhysicalAddress
, bSuppressUpdate
) :
322 CCECBusDevice
*CCECProcessor::GetDevice(cec_logical_address address
) const
324 return m_busDevices
?
325 m_busDevices
->At(address
) :
329 cec_logical_address
CCECProcessor::GetActiveSource(bool bRequestActiveSource
/* = true */)
331 // get the device that is marked as active source from the device map
332 CCECBusDevice
*activeSource
= m_busDevices
->GetActiveSource();
334 return activeSource
->GetLogicalAddress();
336 if (bRequestActiveSource
)
338 // request the active source from the bus
339 CCECBusDevice
*primary
= GetPrimaryDevice();
342 primary
->RequestActiveSource();
343 return GetActiveSource(false);
348 return CECDEVICE_UNKNOWN
;
351 bool CCECProcessor::IsActiveSource(cec_logical_address iAddress
)
353 CCECBusDevice
*device
= m_busDevices
->At(iAddress
);
354 return device
&& device
->IsActiveSource();
357 bool CCECProcessor::Transmit(const cec_command
&data
)
359 uint8_t iMaxTries(0);
363 // get the current timeout setting
364 uint8_t iLineTimeout(GetStandardLineTimeout());
366 // reset the state of this message to 'unknown'
367 cec_adapter_message_state adapterState
= ADAPTER_MESSAGE_STATE_UNKNOWN
;
371 // find the initiator device
372 CCECBusDevice
*initiator
= m_busDevices
->At(data
.initiator
);
375 m_libcec
->AddLog(CEC_LOG_WARNING
, "invalid initiator");
379 // find the destination device, if it's not the broadcast address
380 if (data
.destination
!= CECDEVICE_BROADCAST
)
382 // check if the device is marked as handled by libCEC
383 CCECBusDevice
*destination
= m_busDevices
->At(data
.destination
);
384 if (destination
&& destination
->IsHandledByLibCEC())
386 // and reject the command if it's trying to send data to a device that is handled by libCEC
387 m_libcec
->AddLog(CEC_LOG_WARNING
, "not sending data to myself!");
393 CLockObject
lock(m_mutex
);
394 m_iLastTransmission
= GetTimeMs();
395 // set the number of tries
396 iMaxTries
= initiator
->GetHandler()->GetTransmitRetries() + 1;
399 // and try to send the command
400 while (bRetry
&& ++iTries
< iMaxTries
)
402 if (initiator
->IsUnsupportedFeature(data
.opcode
))
405 adapterState
= !IsStopped() && m_communication
&& m_communication
->IsOpen() ?
406 m_communication
->Write(data
, bRetry
, iLineTimeout
) :
407 ADAPTER_MESSAGE_STATE_ERROR
;
408 iLineTimeout
= m_iRetryLineTimeout
;
411 return adapterState
== ADAPTER_MESSAGE_STATE_SENT_ACKED
;
414 void CCECProcessor::TransmitAbort(cec_logical_address source
, cec_logical_address destination
, cec_opcode opcode
, cec_abort_reason reason
/* = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE */)
416 m_libcec
->AddLog(CEC_LOG_DEBUG
, "<< transmitting abort message");
419 cec_command::Format(command
, source
, destination
, CEC_OPCODE_FEATURE_ABORT
);
420 command
.parameters
.PushBack((uint8_t)opcode
);
421 command
.parameters
.PushBack((uint8_t)reason
);
426 void CCECProcessor::ProcessCommand(const cec_command
&command
)
430 dataStr
.Format(">> %1x%1x", command
.initiator
, command
.destination
);
431 if (command
.opcode_set
== 1)
432 dataStr
.AppendFormat(":%02x", command
.opcode
);
433 for (uint8_t iPtr
= 0; iPtr
< command
.parameters
.size
; iPtr
++)
434 dataStr
.AppendFormat(":%02x", (unsigned int)command
.parameters
[iPtr
]);
435 m_libcec
->AddLog(CEC_LOG_TRAFFIC
, dataStr
.c_str());
437 // find the initiator
438 CCECBusDevice
*device
= m_busDevices
->At(command
.initiator
);
441 device
->HandleCommand(command
);
444 bool CCECProcessor::IsPresentDevice(cec_logical_address address
)
446 CCECBusDevice
*device
= m_busDevices
->At(address
);
447 return device
&& device
->GetStatus() == CEC_DEVICE_STATUS_PRESENT
;
450 bool CCECProcessor::IsPresentDeviceType(cec_device_type type
)
452 CECDEVICEVEC devices
;
453 m_busDevices
->GetByType(type
, devices
);
454 CCECDeviceMap::FilterActive(devices
);
455 return !devices
.empty();
458 uint16_t CCECProcessor::GetDetectedPhysicalAddress(void) const
460 return m_communication
? m_communication
->GetPhysicalAddress() : CEC_INVALID_PHYSICAL_ADDRESS
;
463 bool CCECProcessor::SetAckMask(uint16_t iMask
)
465 return m_communication
? m_communication
->SetAckMask(iMask
) : false;
468 bool CCECProcessor::StandbyDevices(const cec_logical_address initiator
, const CECDEVICEVEC
&devices
)
471 for (CECDEVICEVEC::const_iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
472 bReturn
&= (*it
)->Standby(initiator
);
476 bool CCECProcessor::StandbyDevice(const cec_logical_address initiator
, cec_logical_address address
)
478 CCECBusDevice
*device
= m_busDevices
->At(address
);
479 return device
? device
->Standby(initiator
) : false;
482 bool CCECProcessor::PowerOnDevices(const cec_logical_address initiator
, const CECDEVICEVEC
&devices
)
485 for (CECDEVICEVEC::const_iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
486 bReturn
&= (*it
)->PowerOn(initiator
);
490 bool CCECProcessor::PowerOnDevice(const cec_logical_address initiator
, cec_logical_address address
)
492 CCECBusDevice
*device
= m_busDevices
->At(address
);
493 return device
? device
->PowerOn(initiator
) : false;
496 bool CCECProcessor::StartBootloader(const char *strPort
/* = NULL */)
499 // open a connection if no connection has been opened
500 if (!m_communication
&& strPort
)
502 IAdapterCommunication
*comm
= new CUSBCECAdapterCommunication(this, strPort
);
503 CTimeout
timeout(CEC_DEFAULT_CONNECT_TIMEOUT
);
505 while (timeout
.TimeLeft() > 0 && (bReturn
= comm
->Open(timeout
.TimeLeft() / CEC_CONNECT_TRIES
, true)) == false)
507 m_libcec
->AddLog(CEC_LOG_ERROR
, "could not open a connection (try %d)", ++iConnectTry
);
509 Sleep(CEC_DEFAULT_TRANSMIT_RETRY_WAIT
);
513 bReturn
= comm
->StartBootloader();
514 DELETE_AND_NULL(comm
);
520 m_communication
->StartBootloader();
528 bool CCECProcessor::PingAdapter(void)
530 return m_communication
->PingAdapter();
533 void CCECProcessor::HandlePoll(cec_logical_address initiator
, cec_logical_address destination
)
535 CCECBusDevice
*device
= m_busDevices
->At(destination
);
537 device
->HandlePollFrom(initiator
);
540 bool CCECProcessor::HandleReceiveFailed(cec_logical_address initiator
)
542 CCECBusDevice
*device
= m_busDevices
->At(initiator
);
543 return !device
|| !device
->HandleReceiveFailed();
546 bool CCECProcessor::SetStreamPath(uint16_t iPhysicalAddress
)
548 // stream path changes are sent by the TV
549 return GetTV()->GetHandler()->TransmitSetStreamPath(iPhysicalAddress
);
552 bool CCECProcessor::CanPersistConfiguration(void)
554 return m_communication
? m_communication
->GetFirmwareVersion() >= 2 : false;
557 bool CCECProcessor::PersistConfiguration(const libcec_configuration
&configuration
)
559 return m_communication
? m_communication
->PersistConfiguration(configuration
) : false;
562 void CCECProcessor::RescanActiveDevices(void)
564 for (CECDEVICEMAP::iterator it
= m_busDevices
->Begin(); it
!= m_busDevices
->End(); it
++)
565 it
->second
->GetStatus(true);
568 bool CCECProcessor::GetDeviceInformation(const char *strPort
, libcec_configuration
*config
, uint32_t iTimeoutMs
/* = CEC_DEFAULT_CONNECT_TIMEOUT */)
570 if (!OpenConnection(strPort
, CEC_SERIAL_DEFAULT_BAUDRATE
, iTimeoutMs
, false))
573 config
->iFirmwareVersion
= m_communication
->GetFirmwareVersion();
574 config
->iPhysicalAddress
= m_communication
->GetPhysicalAddress();
575 config
->iFirmwareBuildDate
= m_communication
->GetFirmwareBuildDate();
580 bool CCECProcessor::TransmitPendingActiveSourceCommands(void)
583 for (CECDEVICEMAP::iterator it
= m_busDevices
->Begin(); it
!= m_busDevices
->End(); it
++)
584 bReturn
&= it
->second
->TransmitPendingActiveSourceCommands();
588 CCECTV
*CCECProcessor::GetTV(void) const
590 return CCECBusDevice::AsTV(m_busDevices
->At(CECDEVICE_TV
));
593 CCECAudioSystem
*CCECProcessor::GetAudioSystem(void) const
595 return CCECBusDevice::AsAudioSystem(m_busDevices
->At(CECDEVICE_AUDIOSYSTEM
));
598 CCECPlaybackDevice
*CCECProcessor::GetPlaybackDevice(cec_logical_address address
) const
600 return CCECBusDevice::AsPlaybackDevice(m_busDevices
->At(address
));
603 CCECRecordingDevice
*CCECProcessor::GetRecordingDevice(cec_logical_address address
) const
605 return CCECBusDevice::AsRecordingDevice(m_busDevices
->At(address
));
608 CCECTuner
*CCECProcessor::GetTuner(cec_logical_address address
) const
610 return CCECBusDevice::AsTuner(m_busDevices
->At(address
));
613 bool CCECProcessor::RegisterClient(CCECClient
*client
)
618 libcec_configuration
&configuration
= *client
->GetConfiguration();
620 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_3
&& configuration
.bMonitorOnly
== 1)
623 if (!CECInitialised())
625 m_libcec
->AddLog(CEC_LOG_ERROR
, "failed to register a new CEC client: CEC processor is not initialised");
629 // unregister the client first if it's already been marked as registered
630 if (client
->IsRegistered())
631 UnregisterClient(client
);
633 // get the configuration from the client
634 m_libcec
->AddLog(CEC_LOG_NOTICE
, "registering new CEC client - v%s", ToString((cec_client_version
)configuration
.clientVersion
));
636 // mark as uninitialised and unregistered
637 client
->SetRegistered(false);
638 client
->SetInitialised(false);
640 // get the current ackmask, so we can restore it if polling fails
641 uint16_t iPreviousMask(m_communication
->GetAckMask());
643 // find logical addresses for this client
644 if (!client
->AllocateLogicalAddresses())
646 m_libcec
->AddLog(CEC_LOG_ERROR
, "failed to register the new CEC client - cannot allocate the requested device types");
647 SetAckMask(iPreviousMask
);
651 // register this client on the new addresses
652 CECDEVICEVEC devices
;
653 m_busDevices
->GetByLogicalAddresses(devices
, configuration
.logicalAddresses
);
654 for (CECDEVICEVEC::const_iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
656 // replace a previous client
657 CLockObject
lock(m_mutex
);
658 m_clients
.erase((*it
)->GetLogicalAddress());
659 m_clients
.insert(make_pair
<cec_logical_address
, CCECClient
*>((*it
)->GetLogicalAddress(), client
));
662 // get the settings from the rom
663 if (configuration
.bGetSettingsFromROM
== 1)
665 libcec_configuration config
;
666 m_communication
->GetConfiguration(config
);
668 CLockObject
lock(m_mutex
);
669 if (!config
.deviceTypes
.IsEmpty())
670 configuration
.deviceTypes
= config
.deviceTypes
;
671 if (CLibCEC::IsValidPhysicalAddress(config
.iPhysicalAddress
))
672 configuration
.iPhysicalAddress
= config
.iPhysicalAddress
;
673 snprintf(configuration
.strDeviceName
, 13, "%s", config
.strDeviceName
);
676 // set the firmware version and build date
677 configuration
.serverVersion
= LIBCEC_VERSION_CURRENT
;
678 configuration
.iFirmwareVersion
= m_communication
->GetFirmwareVersion();
679 configuration
.iFirmwareBuildDate
= m_communication
->GetFirmwareBuildDate();
681 // mark the client as registered
682 client
->SetRegistered(true);
684 // set the new ack mask
685 bool bReturn
= SetAckMask(GetLogicalAddresses().AckMask()) &&
686 // and initialise the client
687 client
->OnRegister();
689 // log the new registration
691 strLog
.Format("%s: %s", bReturn
? "CEC client registered" : "failed to register the CEC client", client
->GetConnectionInfo().c_str());
692 m_libcec
->AddLog(bReturn
? CEC_LOG_NOTICE
: CEC_LOG_ERROR
, strLog
);
694 // display a warning if the firmware can be upgraded
695 if (bReturn
&& !IsRunningLatestFirmware())
697 const char *strUpgradeMessage
= "The firmware of this adapter can be upgraded. Please visit http://blog.pulse-eight.com/ for more information.";
698 m_libcec
->AddLog(CEC_LOG_WARNING
, strUpgradeMessage
);
699 libcec_parameter param
;
700 param
.paramData
= (void*)strUpgradeMessage
; param
.paramType
= CEC_PARAMETER_TYPE_STRING
;
701 client
->Alert(CEC_ALERT_SERVICE_DEVICE
, param
);
707 bool CCECProcessor::UnregisterClient(CCECClient
*client
)
712 if (client
->IsRegistered())
713 m_libcec
->AddLog(CEC_LOG_NOTICE
, "unregistering client: %s", client
->GetConnectionInfo().c_str());
715 // notify the client that it will be unregistered
716 client
->OnUnregister();
719 CLockObject
lock(m_mutex
);
720 // find all devices that match the LA's of this client
721 CECDEVICEVEC devices
;
722 m_busDevices
->GetByLogicalAddresses(devices
, client
->GetConfiguration()->logicalAddresses
);
723 for (CECDEVICEVEC::const_iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
726 map
<cec_logical_address
, CCECClient
*>::iterator entry
= m_clients
.find((*it
)->GetLogicalAddress());
727 // unregister the client
728 if (entry
!= m_clients
.end())
729 m_clients
.erase(entry
);
731 // reset the device status
732 (*it
)->ResetDeviceStatus();
736 // set the new ackmask
737 return SetAckMask(GetLogicalAddresses().AckMask());
740 void CCECProcessor::UnregisterClients(void)
742 m_libcec
->AddLog(CEC_LOG_NOTICE
, "unregistering all CEC clients");
744 vector
<CCECClient
*> clients
= m_libcec
->GetClients();
745 for (vector
<CCECClient
*>::iterator client
= clients
.begin(); client
!= clients
.end(); client
++)
746 UnregisterClient(*client
);
748 CLockObject
lock(m_mutex
);
752 CCECClient
*CCECProcessor::GetClient(const cec_logical_address address
)
754 CLockObject
lock(m_mutex
);
755 map
<cec_logical_address
, CCECClient
*>::const_iterator client
= m_clients
.find(address
);
756 if (client
!= m_clients
.end())
757 return client
->second
;
761 CCECClient
*CCECProcessor::GetPrimaryClient(void)
763 CLockObject
lock(m_mutex
);
764 map
<cec_logical_address
, CCECClient
*>::const_iterator client
= m_clients
.begin();
765 if (client
!= m_clients
.end())
766 return client
->second
;
770 CCECBusDevice
*CCECProcessor::GetPrimaryDevice(void)
772 return m_busDevices
->At(GetLogicalAddress());
775 cec_logical_address
CCECProcessor::GetLogicalAddress(void)
777 cec_logical_addresses addresses
= GetLogicalAddresses();
778 return addresses
.primary
;
781 cec_logical_addresses
CCECProcessor::GetLogicalAddresses(void)
783 CLockObject
lock(m_mutex
);
784 cec_logical_addresses addresses
;
786 for (map
<cec_logical_address
, CCECClient
*>::const_iterator client
= m_clients
.begin(); client
!= m_clients
.end(); client
++)
787 addresses
.Set(client
->first
);
792 bool CCECProcessor::IsHandledByLibCEC(const cec_logical_address address
) const
794 CCECBusDevice
*device
= GetDevice(address
);
795 return device
&& device
->IsHandledByLibCEC();
798 bool CCECProcessor::IsRunningLatestFirmware(void)
800 return m_communication
&& m_communication
->IsOpen() ?
801 m_communication
->IsRunningLatestFirmware() :