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 "platform/util/timeutils.h"
49 using namespace PLATFORM
;
51 #define CEC_PROCESSOR_SIGNAL_WAIT_TIME 1000
53 #define ToString(x) m_libcec->ToString(x)
55 CCECProcessor::CCECProcessor(CLibCEC
*libcec
) :
56 m_bInitialised(false),
57 m_communication(NULL
),
59 m_iStandardLineTimeout(3),
60 m_iRetryLineTimeout(3),
61 m_iLastTransmission(0)
63 m_busDevices
= new CCECDeviceMap(this);
66 CCECProcessor::~CCECProcessor(void)
72 bool CCECProcessor::Start(const char *strPort
, uint16_t iBaudRate
/* = CEC_SERIAL_DEFAULT_BAUDRATE */, uint32_t iTimeoutMs
/* = CEC_DEFAULT_CONNECT_TIMEOUT */)
74 CLockObject
lock(m_mutex
);
76 if (!OpenConnection(strPort
, iBaudRate
, iTimeoutMs
))
79 // create the processor thread
84 m_libcec
->AddLog(CEC_LOG_ERROR
, "could not create a processor thread");
92 void CCECProcessor::Close(void)
94 // mark as uninitialised
95 SetCECInitialised(false);
100 // close the connection
103 delete m_communication
;
104 m_communication
= NULL
;
108 void CCECProcessor::ResetMembers(void)
110 // close the connection
113 delete m_communication
;
114 m_communication
= NULL
;
117 // reset the other members to the initial state
118 m_iStandardLineTimeout
= 3;
119 m_iRetryLineTimeout
= 3;
120 m_iLastTransmission
= 0;
121 m_busDevices
->ResetDeviceStatus();
124 bool CCECProcessor::OpenConnection(const char *strPort
, uint16_t iBaudRate
, uint32_t iTimeoutMs
, bool bStartListening
/* = true */)
127 CTimeout
timeout(iTimeoutMs
> 0 ? iTimeoutMs
: CEC_DEFAULT_TRANSMIT_WAIT
);
129 // ensure that a previous connection is closed
132 // reset all member to the initial state
135 // check whether the Close() method deleted any previous connection
138 m_libcec
->AddLog(CEC_LOG_ERROR
, "previous connection could not be closed");
142 // create a new connection
143 m_communication
= new CUSBCECAdapterCommunication(this, strPort
, iBaudRate
);
145 // open a new connection
146 unsigned iConnectTry(0);
147 while (timeout
.TimeLeft() > 0 && (bReturn
= m_communication
->Open((timeout
.TimeLeft() / CEC_CONNECT_TRIES
), false, bStartListening
)) == false)
149 m_libcec
->AddLog(CEC_LOG_ERROR
, "could not open a connection (try %d)", ++iConnectTry
);
150 m_communication
->Close();
151 CEvent::Sleep(CEC_DEFAULT_CONNECT_RETRY_WAIT
);
154 m_libcec
->AddLog(CEC_LOG_NOTICE
, "connection opened");
156 // always start by setting the ackmask to 0, to clear previous values
159 // mark as initialised
160 SetCECInitialised(true);
165 bool CCECProcessor::CECInitialised(void)
167 CLockObject
lock(m_threadMutex
);
168 return m_bInitialised
;
171 void CCECProcessor::SetCECInitialised(bool bSetTo
/* = true */)
174 CLockObject
lock(m_mutex
);
175 m_bInitialised
= bSetTo
;
181 bool CCECProcessor::TryLogicalAddress(cec_logical_address address
)
184 CCECBusDevice
*device
= m_busDevices
->At(address
);
187 // check if it's already marked as present or used
188 if (device
->IsPresent() || device
->IsHandledByLibCEC())
191 // poll the LA if not
193 return device
->TryLogicalAddress();
199 void CCECProcessor::ReplaceHandlers(void)
201 if (!CECInitialised())
205 for (CECDEVICEMAP::iterator it
= m_busDevices
->Begin(); it
!= m_busDevices
->End(); it
++)
206 it
->second
->ReplaceHandler(true);
209 bool CCECProcessor::OnCommandReceived(const cec_command
&command
)
211 return m_inBuffer
.Push(command
);
214 void *CCECProcessor::Process(void)
216 m_libcec
->AddLog(CEC_LOG_DEBUG
, "processor thread started");
220 // as long as we're not being stopped and the connection is open
221 while (!IsStopped() && m_communication
->IsOpen())
223 // wait for a new incoming command, and process it
224 if (m_inBuffer
.Pop(command
, CEC_PROCESSOR_SIGNAL_WAIT_TIME
))
225 ProcessCommand(command
);
227 if (CECInitialised())
229 // check clients for keypress timeouts
230 m_libcec
->CheckKeypressTimeout();
232 // check if we need to replace handlers
240 bool CCECProcessor::ActivateSource(uint16_t iStreamPath
)
244 // find the device with the given PA
245 CCECBusDevice
*device
= GetDeviceByPhysicalAddress(iStreamPath
);
246 // and make it the active source when found
248 bReturn
= device
->ActivateSource();
250 m_libcec
->AddLog(CEC_LOG_DEBUG
, "device with PA '%04x' not found", iStreamPath
);
255 void CCECProcessor::SetStandardLineTimeout(uint8_t iTimeout
)
257 CLockObject
lock(m_mutex
);
258 m_iStandardLineTimeout
= iTimeout
;
261 uint8_t CCECProcessor::GetStandardLineTimeout(void)
263 CLockObject
lock(m_mutex
);
264 return m_iStandardLineTimeout
;
267 void CCECProcessor::SetRetryLineTimeout(uint8_t iTimeout
)
269 CLockObject
lock(m_mutex
);
270 m_iRetryLineTimeout
= iTimeout
;
273 uint8_t CCECProcessor::GetRetryLineTimeout(void)
275 CLockObject
lock(m_mutex
);
276 return m_iRetryLineTimeout
;
279 bool CCECProcessor::PhysicalAddressInUse(uint16_t iPhysicalAddress
)
281 CCECBusDevice
*device
= GetDeviceByPhysicalAddress(iPhysicalAddress
);
282 return device
!= NULL
;
285 void CCECProcessor::LogOutput(const cec_command
&data
)
289 // initiator and destination
290 strTx
.Format("<< %02x", ((uint8_t)data
.initiator
<< 4) + (uint8_t)data
.destination
);
294 strTx
.AppendFormat(":%02x", (uint8_t)data
.opcode
);
296 // append the parameters
297 for (uint8_t iPtr
= 0; iPtr
< data
.parameters
.size
; iPtr
++)
298 strTx
.AppendFormat(":%02x", data
.parameters
[iPtr
]);
301 m_libcec
->AddLog(CEC_LOG_TRAFFIC
, strTx
.c_str());
304 bool CCECProcessor::PollDevice(cec_logical_address iAddress
)
306 // try to find the primary device
307 CCECBusDevice
*primary
= GetPrimaryDevice();
308 // poll the destination, with the primary as source
310 return primary
->TransmitPoll(iAddress
);
312 // try to find the destination
313 CCECBusDevice
*device
= m_busDevices
->At(iAddress
);
314 // and poll the destination, with the same LA as source
316 return device
->TransmitPoll(iAddress
);
321 CCECBusDevice
*CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress
, bool bSuppressUpdate
/* = true */)
323 return m_busDevices
?
324 m_busDevices
->GetDeviceByPhysicalAddress(iPhysicalAddress
, bSuppressUpdate
) :
328 CCECBusDevice
*CCECProcessor::GetDevice(cec_logical_address address
) const
330 return m_busDevices
?
331 m_busDevices
->At(address
) :
335 cec_logical_address
CCECProcessor::GetActiveSource(bool bRequestActiveSource
/* = true */)
337 // get the device that is marked as active source from the device map
338 CCECBusDevice
*activeSource
= m_busDevices
->GetActiveSource();
340 return activeSource
->GetLogicalAddress();
342 if (bRequestActiveSource
)
344 // request the active source from the bus
345 CCECBusDevice
*primary
= GetPrimaryDevice();
348 primary
->RequestActiveSource();
349 return GetActiveSource(false);
354 return CECDEVICE_UNKNOWN
;
357 bool CCECProcessor::IsActiveSource(cec_logical_address iAddress
)
359 CCECBusDevice
*device
= m_busDevices
->At(iAddress
);
360 return device
&& device
->IsActiveSource();
363 bool CCECProcessor::Transmit(const cec_command
&data
)
365 uint8_t iMaxTries(0);
369 // get the current timeout setting
370 uint8_t iLineTimeout(GetStandardLineTimeout());
372 // reset the state of this message to 'unknown'
373 cec_adapter_message_state adapterState
= ADAPTER_MESSAGE_STATE_UNKNOWN
;
377 // find the initiator device
378 CCECBusDevice
*initiator
= m_busDevices
->At(data
.initiator
);
381 m_libcec
->AddLog(CEC_LOG_WARNING
, "invalid initiator");
385 // find the destination device, if it's not the broadcast address
386 if (data
.destination
!= CECDEVICE_BROADCAST
)
388 // check if the device is marked as handled by libCEC
389 CCECBusDevice
*destination
= m_busDevices
->At(data
.destination
);
390 if (destination
&& destination
->IsHandledByLibCEC())
392 // and reject the command if it's trying to send data to a device that is handled by libCEC
393 m_libcec
->AddLog(CEC_LOG_WARNING
, "not sending data to myself!");
399 CLockObject
lock(m_mutex
);
400 m_iLastTransmission
= GetTimeMs();
401 // set the number of tries
402 iMaxTries
= initiator
->GetHandler()->GetTransmitRetries() + 1;
405 // and try to send the command
406 while (bRetry
&& ++iTries
< iMaxTries
)
408 if (initiator
->IsUnsupportedFeature(data
.opcode
))
411 adapterState
= !IsStopped() && m_communication
&& m_communication
->IsOpen() ?
412 m_communication
->Write(data
, bRetry
, iLineTimeout
) :
413 ADAPTER_MESSAGE_STATE_ERROR
;
414 iLineTimeout
= m_iRetryLineTimeout
;
417 return adapterState
== ADAPTER_MESSAGE_STATE_SENT_ACKED
;
420 void CCECProcessor::TransmitAbort(cec_logical_address source
, cec_logical_address destination
, cec_opcode opcode
, cec_abort_reason reason
/* = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE */)
422 m_libcec
->AddLog(CEC_LOG_DEBUG
, "<< transmitting abort message");
425 cec_command::Format(command
, source
, destination
, CEC_OPCODE_FEATURE_ABORT
);
426 command
.parameters
.PushBack((uint8_t)opcode
);
427 command
.parameters
.PushBack((uint8_t)reason
);
432 void CCECProcessor::ProcessCommand(const cec_command
&command
)
436 dataStr
.Format(">> %1x%1x", command
.initiator
, command
.destination
);
437 if (command
.opcode_set
== 1)
438 dataStr
.AppendFormat(":%02x", command
.opcode
);
439 for (uint8_t iPtr
= 0; iPtr
< command
.parameters
.size
; iPtr
++)
440 dataStr
.AppendFormat(":%02x", (unsigned int)command
.parameters
[iPtr
]);
441 m_libcec
->AddLog(CEC_LOG_TRAFFIC
, dataStr
.c_str());
443 // find the initiator
444 CCECBusDevice
*device
= m_busDevices
->At(command
.initiator
);
447 device
->HandleCommand(command
);
450 bool CCECProcessor::IsPresentDevice(cec_logical_address address
)
452 CCECBusDevice
*device
= m_busDevices
->At(address
);
453 return device
&& device
->GetStatus() == CEC_DEVICE_STATUS_PRESENT
;
456 bool CCECProcessor::IsPresentDeviceType(cec_device_type type
)
458 CECDEVICEVEC devices
;
459 m_busDevices
->GetByType(type
, devices
);
460 CCECDeviceMap::FilterActive(devices
);
461 return !devices
.empty();
464 uint16_t CCECProcessor::GetDetectedPhysicalAddress(void) const
466 return m_communication
? m_communication
->GetPhysicalAddress() : CEC_INVALID_PHYSICAL_ADDRESS
;
469 bool CCECProcessor::SetAckMask(uint16_t iMask
)
471 return m_communication
? m_communication
->SetAckMask(iMask
) : false;
474 bool CCECProcessor::StandbyDevices(const cec_logical_address initiator
, const CECDEVICEVEC
&devices
)
477 for (CECDEVICEVEC::const_iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
478 bReturn
&= (*it
)->Standby(initiator
);
482 bool CCECProcessor::StandbyDevice(const cec_logical_address initiator
, cec_logical_address address
)
484 CCECBusDevice
*device
= m_busDevices
->At(address
);
485 return device
? device
->Standby(initiator
) : false;
488 bool CCECProcessor::PowerOnDevices(const cec_logical_address initiator
, const CECDEVICEVEC
&devices
)
491 for (CECDEVICEVEC::const_iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
492 bReturn
&= (*it
)->PowerOn(initiator
);
496 bool CCECProcessor::PowerOnDevice(const cec_logical_address initiator
, cec_logical_address address
)
498 CCECBusDevice
*device
= m_busDevices
->At(address
);
499 return device
? device
->PowerOn(initiator
) : false;
502 bool CCECProcessor::StartBootloader(const char *strPort
/* = NULL */)
505 // open a connection if no connection has been opened
506 if (!m_communication
&& strPort
)
508 IAdapterCommunication
*comm
= new CUSBCECAdapterCommunication(this, strPort
);
509 CTimeout
timeout(CEC_DEFAULT_CONNECT_TIMEOUT
);
511 while (timeout
.TimeLeft() > 0 && (bReturn
= comm
->Open(timeout
.TimeLeft() / CEC_CONNECT_TRIES
, true)) == false)
513 m_libcec
->AddLog(CEC_LOG_ERROR
, "could not open a connection (try %d)", ++iConnectTry
);
515 Sleep(CEC_DEFAULT_TRANSMIT_RETRY_WAIT
);
519 bReturn
= comm
->StartBootloader();
526 m_communication
->StartBootloader();
534 bool CCECProcessor::PingAdapter(void)
536 return m_communication
->PingAdapter();
539 void CCECProcessor::HandlePoll(cec_logical_address initiator
, cec_logical_address destination
)
541 CCECBusDevice
*device
= m_busDevices
->At(destination
);
543 device
->HandlePollFrom(initiator
);
546 bool CCECProcessor::HandleReceiveFailed(cec_logical_address initiator
)
548 CCECBusDevice
*device
= m_busDevices
->At(initiator
);
549 return !device
|| !device
->HandleReceiveFailed();
552 bool CCECProcessor::SetStreamPath(uint16_t iPhysicalAddress
)
554 // stream path changes are sent by the TV
555 return GetTV()->GetHandler()->TransmitSetStreamPath(iPhysicalAddress
);
558 bool CCECProcessor::CanPersistConfiguration(void)
560 return m_communication
? m_communication
->GetFirmwareVersion() >= 2 : false;
563 bool CCECProcessor::PersistConfiguration(const libcec_configuration
&configuration
)
565 return m_communication
? m_communication
->PersistConfiguration(configuration
) : false;
568 void CCECProcessor::RescanActiveDevices(void)
570 for (CECDEVICEMAP::iterator it
= m_busDevices
->Begin(); it
!= m_busDevices
->End(); it
++)
571 it
->second
->GetStatus(true);
574 bool CCECProcessor::GetDeviceInformation(const char *strPort
, libcec_configuration
*config
, uint32_t iTimeoutMs
/* = CEC_DEFAULT_CONNECT_TIMEOUT */)
576 if (!OpenConnection(strPort
, CEC_SERIAL_DEFAULT_BAUDRATE
, iTimeoutMs
, false))
579 config
->iFirmwareVersion
= m_communication
->GetFirmwareVersion();
580 config
->iPhysicalAddress
= m_communication
->GetPhysicalAddress();
581 config
->iFirmwareBuildDate
= m_communication
->GetFirmwareBuildDate();
586 bool CCECProcessor::TransmitPendingActiveSourceCommands(void)
589 for (CECDEVICEMAP::iterator it
= m_busDevices
->Begin(); it
!= m_busDevices
->End(); it
++)
590 bReturn
&= it
->second
->TransmitPendingActiveSourceCommands();
594 CCECTV
*CCECProcessor::GetTV(void) const
596 return CCECBusDevice::AsTV(m_busDevices
->At(CECDEVICE_TV
));
599 CCECAudioSystem
*CCECProcessor::GetAudioSystem(void) const
601 return CCECBusDevice::AsAudioSystem(m_busDevices
->At(CECDEVICE_AUDIOSYSTEM
));
604 CCECPlaybackDevice
*CCECProcessor::GetPlaybackDevice(cec_logical_address address
) const
606 return CCECBusDevice::AsPlaybackDevice(m_busDevices
->At(address
));
609 CCECRecordingDevice
*CCECProcessor::GetRecordingDevice(cec_logical_address address
) const
611 return CCECBusDevice::AsRecordingDevice(m_busDevices
->At(address
));
614 CCECTuner
*CCECProcessor::GetTuner(cec_logical_address address
) const
616 return CCECBusDevice::AsTuner(m_busDevices
->At(address
));
619 bool CCECProcessor::RegisterClient(CCECClient
*client
)
624 libcec_configuration
&configuration
= *client
->GetConfiguration();
626 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_3
&& configuration
.bMonitorOnly
== 1)
629 if (!CECInitialised())
631 m_libcec
->AddLog(CEC_LOG_ERROR
, "failed to register a new CEC client: CEC processor is not initialised");
635 // unregister the client first if it's already been marked as registered
636 if (client
->IsRegistered())
637 UnregisterClient(client
);
639 // get the configuration from the client
640 m_libcec
->AddLog(CEC_LOG_NOTICE
, "registering new CEC client - v%s", ToString((cec_client_version
)configuration
.clientVersion
));
642 // mark as uninitialised and unregistered
643 client
->SetRegistered(false);
644 client
->SetInitialised(false);
646 // get the current ackmask, so we can restore it if polling fails
647 uint16_t iPreviousMask(m_communication
->GetAckMask());
649 // find logical addresses for this client
650 if (!client
->AllocateLogicalAddresses())
652 m_libcec
->AddLog(CEC_LOG_ERROR
, "failed to register the new CEC client - cannot allocate the requested device types");
653 SetAckMask(iPreviousMask
);
657 // register this client on the new addresses
658 CECDEVICEVEC devices
;
659 m_busDevices
->GetByLogicalAddresses(devices
, configuration
.logicalAddresses
);
660 for (CECDEVICEVEC::const_iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
662 // replace a previous client
663 CLockObject
lock(m_mutex
);
664 m_clients
.erase((*it
)->GetLogicalAddress());
665 m_clients
.insert(make_pair
<cec_logical_address
, CCECClient
*>((*it
)->GetLogicalAddress(), client
));
668 // get the settings from the rom
669 if (configuration
.bGetSettingsFromROM
== 1)
671 libcec_configuration config
;
672 m_communication
->GetConfiguration(config
);
674 CLockObject
lock(m_mutex
);
675 if (!config
.deviceTypes
.IsEmpty())
676 configuration
.deviceTypes
= config
.deviceTypes
;
677 if (CLibCEC::IsValidPhysicalAddress(config
.iPhysicalAddress
))
678 configuration
.iPhysicalAddress
= config
.iPhysicalAddress
;
679 snprintf(configuration
.strDeviceName
, 13, "%s", config
.strDeviceName
);
682 // set the firmware version and build date
683 configuration
.serverVersion
= LIBCEC_VERSION_CURRENT
;
684 configuration
.iFirmwareVersion
= m_communication
->GetFirmwareVersion();
685 configuration
.iFirmwareBuildDate
= m_communication
->GetFirmwareBuildDate();
687 // mark the client as registered
688 client
->SetRegistered(true);
690 // set the new ack mask
691 bool bReturn
= SetAckMask(GetLogicalAddresses().AckMask()) &&
692 // and initialise the client
693 client
->OnRegister();
695 // log the new registration
697 strLog
.Format("%s: %s", bReturn
? "CEC client registered" : "failed to register the CEC client", client
->GetConnectionInfo().c_str());
698 m_libcec
->AddLog(bReturn
? CEC_LOG_NOTICE
: CEC_LOG_ERROR
, strLog
);
700 // display a warning if the firmware can be upgraded
701 if (bReturn
&& !IsRunningLatestFirmware())
703 const char *strUpgradeMessage
= "The firmware of this adapter can be upgraded. Please visit http://blog.pulse-eight.com/ for more information.";
704 m_libcec
->AddLog(CEC_LOG_WARNING
, strUpgradeMessage
);
705 libcec_parameter param
;
706 param
.paramData
= (void*)strUpgradeMessage
; param
.paramType
= CEC_PARAMETER_TYPE_STRING
;
707 client
->Alert(CEC_ALERT_SERVICE_DEVICE
, param
);
713 bool CCECProcessor::UnregisterClient(CCECClient
*client
)
718 if (client
->IsRegistered())
719 m_libcec
->AddLog(CEC_LOG_NOTICE
, "unregistering client: %s", client
->GetConnectionInfo().c_str());
721 // notify the client that it will be unregistered
722 client
->OnUnregister();
725 CLockObject
lock(m_mutex
);
726 // find all devices that match the LA's of this client
727 CECDEVICEVEC devices
;
728 m_busDevices
->GetByLogicalAddresses(devices
, client
->GetConfiguration()->logicalAddresses
);
729 for (CECDEVICEVEC::const_iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
732 map
<cec_logical_address
, CCECClient
*>::iterator entry
= m_clients
.find((*it
)->GetLogicalAddress());
733 // unregister the client
734 if (entry
!= m_clients
.end())
735 m_clients
.erase(entry
);
737 // reset the device status
738 (*it
)->ResetDeviceStatus();
742 // set the new ackmask
743 return SetAckMask(GetLogicalAddresses().AckMask());
746 void CCECProcessor::UnregisterClients(void)
748 m_libcec
->AddLog(CEC_LOG_NOTICE
, "unregistering all CEC clients");
750 vector
<CCECClient
*> clients
= m_libcec
->GetClients();
751 for (vector
<CCECClient
*>::iterator client
= clients
.begin(); client
!= clients
.end(); client
++)
752 UnregisterClient(*client
);
754 CLockObject
lock(m_mutex
);
758 CCECClient
*CCECProcessor::GetClient(const cec_logical_address address
)
760 CLockObject
lock(m_mutex
);
761 map
<cec_logical_address
, CCECClient
*>::const_iterator client
= m_clients
.find(address
);
762 if (client
!= m_clients
.end())
763 return client
->second
;
767 CCECClient
*CCECProcessor::GetPrimaryClient(void)
769 CLockObject
lock(m_mutex
);
770 map
<cec_logical_address
, CCECClient
*>::const_iterator client
= m_clients
.begin();
771 if (client
!= m_clients
.end())
772 return client
->second
;
776 CCECBusDevice
*CCECProcessor::GetPrimaryDevice(void)
778 return m_busDevices
->At(GetLogicalAddress());
781 cec_logical_address
CCECProcessor::GetLogicalAddress(void)
783 cec_logical_addresses addresses
= GetLogicalAddresses();
784 return addresses
.primary
;
787 cec_logical_addresses
CCECProcessor::GetLogicalAddresses(void)
789 CLockObject
lock(m_mutex
);
790 cec_logical_addresses addresses
;
792 for (map
<cec_logical_address
, CCECClient
*>::const_iterator client
= m_clients
.begin(); client
!= m_clients
.end(); client
++)
793 addresses
.Set(client
->first
);
798 bool CCECProcessor::IsHandledByLibCEC(const cec_logical_address address
) const
800 CCECBusDevice
*device
= GetDevice(address
);
801 return device
&& device
->IsHandledByLibCEC();
804 bool CCECProcessor::IsRunningLatestFirmware(void)
806 return m_communication
&& m_communication
->IsOpen() ?
807 m_communication
->IsRunningLatestFirmware() :