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 // mark as initialised
157 SetCECInitialised(true);
162 bool CCECProcessor::CECInitialised(void)
164 CLockObject
lock(m_threadMutex
);
165 return m_bInitialised
;
168 void CCECProcessor::SetCECInitialised(bool bSetTo
/* = true */)
171 CLockObject
lock(m_mutex
);
172 m_bInitialised
= bSetTo
;
178 bool CCECProcessor::TryLogicalAddress(cec_logical_address address
)
181 CCECBusDevice
*device
= m_busDevices
->At(address
);
184 // check if it's already marked as present or used
185 if (device
->IsPresent() || device
->IsHandledByLibCEC())
188 // poll the LA if not
190 return device
->TryLogicalAddress();
196 void CCECProcessor::ReplaceHandlers(void)
198 if (!CECInitialised())
202 for (CECDEVICEMAP::iterator it
= m_busDevices
->Begin(); it
!= m_busDevices
->End(); it
++)
203 it
->second
->ReplaceHandler(true);
206 bool CCECProcessor::OnCommandReceived(const cec_command
&command
)
208 return m_inBuffer
.Push(command
);
211 void *CCECProcessor::Process(void)
213 m_libcec
->AddLog(CEC_LOG_DEBUG
, "processor thread started");
217 // as long as we're not being stopped and the connection is open
218 while (!IsStopped() && m_communication
->IsOpen())
220 // wait for a new incoming command, and process it
221 if (m_inBuffer
.Pop(command
, CEC_PROCESSOR_SIGNAL_WAIT_TIME
))
222 ProcessCommand(command
);
224 if (CECInitialised())
226 // check clients for keypress timeouts
227 m_libcec
->CheckKeypressTimeout();
229 // check if we need to replace handlers
237 bool CCECProcessor::ActivateSource(uint16_t iStreamPath
)
241 // find the device with the given PA
242 CCECBusDevice
*device
= GetDeviceByPhysicalAddress(iStreamPath
);
243 // and make it the active source when found
245 bReturn
= device
->ActivateSource();
247 m_libcec
->AddLog(CEC_LOG_DEBUG
, "device with PA '%04x' not found", iStreamPath
);
252 void CCECProcessor::SetStandardLineTimeout(uint8_t iTimeout
)
254 CLockObject
lock(m_mutex
);
255 m_iStandardLineTimeout
= iTimeout
;
258 uint8_t CCECProcessor::GetStandardLineTimeout(void)
260 CLockObject
lock(m_mutex
);
261 return m_iStandardLineTimeout
;
264 void CCECProcessor::SetRetryLineTimeout(uint8_t iTimeout
)
266 CLockObject
lock(m_mutex
);
267 m_iRetryLineTimeout
= iTimeout
;
270 uint8_t CCECProcessor::GetRetryLineTimeout(void)
272 CLockObject
lock(m_mutex
);
273 return m_iRetryLineTimeout
;
276 bool CCECProcessor::PhysicalAddressInUse(uint16_t iPhysicalAddress
)
278 CCECBusDevice
*device
= GetDeviceByPhysicalAddress(iPhysicalAddress
);
279 return device
!= NULL
;
282 void CCECProcessor::LogOutput(const cec_command
&data
)
286 // initiator and destination
287 strTx
.Format("<< %02x", ((uint8_t)data
.initiator
<< 4) + (uint8_t)data
.destination
);
291 strTx
.AppendFormat(":%02x", (uint8_t)data
.opcode
);
293 // append the parameters
294 for (uint8_t iPtr
= 0; iPtr
< data
.parameters
.size
; iPtr
++)
295 strTx
.AppendFormat(":%02x", data
.parameters
[iPtr
]);
298 m_libcec
->AddLog(CEC_LOG_TRAFFIC
, strTx
.c_str());
301 bool CCECProcessor::PollDevice(cec_logical_address iAddress
)
303 // try to find the primary device
304 CCECBusDevice
*primary
= GetPrimaryDevice();
305 // poll the destination, with the primary as source
307 return primary
->TransmitPoll(iAddress
);
309 // try to find the destination
310 CCECBusDevice
*device
= m_busDevices
->At(iAddress
);
311 // and poll the destination, with the same LA as source
313 return device
->TransmitPoll(iAddress
);
318 CCECBusDevice
*CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress
, bool bSuppressUpdate
/* = true */)
320 return m_busDevices
?
321 m_busDevices
->GetDeviceByPhysicalAddress(iPhysicalAddress
, bSuppressUpdate
) :
325 CCECBusDevice
*CCECProcessor::GetDevice(cec_logical_address address
) const
327 return m_busDevices
?
328 m_busDevices
->At(address
) :
332 cec_logical_address
CCECProcessor::GetActiveSource(bool bRequestActiveSource
/* = true */)
334 // get the device that is marked as active source from the device map
335 CCECBusDevice
*activeSource
= m_busDevices
->GetActiveSource();
337 return activeSource
->GetLogicalAddress();
339 if (bRequestActiveSource
)
341 // request the active source from the bus
342 CCECBusDevice
*primary
= GetPrimaryDevice();
345 primary
->RequestActiveSource();
346 return GetActiveSource(false);
351 return CECDEVICE_UNKNOWN
;
354 bool CCECProcessor::IsActiveSource(cec_logical_address iAddress
)
356 CCECBusDevice
*device
= m_busDevices
->At(iAddress
);
357 return device
&& device
->IsActiveSource();
360 bool CCECProcessor::Transmit(const cec_command
&data
)
362 uint8_t iMaxTries(0);
366 // get the current timeout setting
367 uint8_t iLineTimeout(GetStandardLineTimeout());
369 // reset the state of this message to 'unknown'
370 cec_adapter_message_state adapterState
= ADAPTER_MESSAGE_STATE_UNKNOWN
;
374 // find the initiator device
375 CCECBusDevice
*initiator
= m_busDevices
->At(data
.initiator
);
378 m_libcec
->AddLog(CEC_LOG_WARNING
, "invalid initiator");
382 // find the destination device, if it's not the broadcast address
383 if (data
.destination
!= CECDEVICE_BROADCAST
)
385 // check if the device is marked as handled by libCEC
386 CCECBusDevice
*destination
= m_busDevices
->At(data
.destination
);
387 if (destination
&& destination
->IsHandledByLibCEC())
389 // and reject the command if it's trying to send data to a device that is handled by libCEC
390 m_libcec
->AddLog(CEC_LOG_WARNING
, "not sending data to myself!");
396 CLockObject
lock(m_mutex
);
397 m_iLastTransmission
= GetTimeMs();
398 // set the number of tries
399 iMaxTries
= initiator
->GetHandler()->GetTransmitRetries() + 1;
402 // and try to send the command
403 while (bRetry
&& ++iTries
< iMaxTries
)
405 if (initiator
->IsUnsupportedFeature(data
.opcode
))
408 adapterState
= !IsStopped() && m_communication
&& m_communication
->IsOpen() ?
409 m_communication
->Write(data
, bRetry
, iLineTimeout
) :
410 ADAPTER_MESSAGE_STATE_ERROR
;
411 iLineTimeout
= m_iRetryLineTimeout
;
414 return adapterState
== ADAPTER_MESSAGE_STATE_SENT_ACKED
;
417 void CCECProcessor::TransmitAbort(cec_logical_address source
, cec_logical_address destination
, cec_opcode opcode
, cec_abort_reason reason
/* = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE */)
419 m_libcec
->AddLog(CEC_LOG_DEBUG
, "<< transmitting abort message");
422 cec_command::Format(command
, source
, destination
, CEC_OPCODE_FEATURE_ABORT
);
423 command
.parameters
.PushBack((uint8_t)opcode
);
424 command
.parameters
.PushBack((uint8_t)reason
);
429 void CCECProcessor::ProcessCommand(const cec_command
&command
)
433 dataStr
.Format(">> %1x%1x", command
.initiator
, command
.destination
);
434 if (command
.opcode_set
== 1)
435 dataStr
.AppendFormat(":%02x", command
.opcode
);
436 for (uint8_t iPtr
= 0; iPtr
< command
.parameters
.size
; iPtr
++)
437 dataStr
.AppendFormat(":%02x", (unsigned int)command
.parameters
[iPtr
]);
438 m_libcec
->AddLog(CEC_LOG_TRAFFIC
, dataStr
.c_str());
440 // find the initiator
441 CCECBusDevice
*device
= m_busDevices
->At(command
.initiator
);
444 device
->HandleCommand(command
);
447 bool CCECProcessor::IsPresentDevice(cec_logical_address address
)
449 CCECBusDevice
*device
= m_busDevices
->At(address
);
450 return device
&& device
->GetStatus() == CEC_DEVICE_STATUS_PRESENT
;
453 bool CCECProcessor::IsPresentDeviceType(cec_device_type type
)
455 CECDEVICEVEC devices
;
456 m_busDevices
->GetByType(type
, devices
);
457 CCECDeviceMap::FilterActive(devices
);
458 return !devices
.empty();
461 uint16_t CCECProcessor::GetDetectedPhysicalAddress(void) const
463 return m_communication
? m_communication
->GetPhysicalAddress() : CEC_INVALID_PHYSICAL_ADDRESS
;
466 bool CCECProcessor::SetAckMask(uint16_t iMask
)
468 return m_communication
? m_communication
->SetAckMask(iMask
) : false;
471 bool CCECProcessor::StandbyDevices(const cec_logical_address initiator
, const CECDEVICEVEC
&devices
)
474 for (CECDEVICEVEC::const_iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
475 bReturn
&= (*it
)->Standby(initiator
);
479 bool CCECProcessor::StandbyDevice(const cec_logical_address initiator
, cec_logical_address address
)
481 CCECBusDevice
*device
= m_busDevices
->At(address
);
482 return device
? device
->Standby(initiator
) : false;
485 bool CCECProcessor::PowerOnDevices(const cec_logical_address initiator
, const CECDEVICEVEC
&devices
)
488 for (CECDEVICEVEC::const_iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
489 bReturn
&= (*it
)->PowerOn(initiator
);
493 bool CCECProcessor::PowerOnDevice(const cec_logical_address initiator
, cec_logical_address address
)
495 CCECBusDevice
*device
= m_busDevices
->At(address
);
496 return device
? device
->PowerOn(initiator
) : false;
499 bool CCECProcessor::StartBootloader(const char *strPort
/* = NULL */)
502 // open a connection if no connection has been opened
503 if (!m_communication
&& strPort
)
505 IAdapterCommunication
*comm
= new CUSBCECAdapterCommunication(this, strPort
);
506 CTimeout
timeout(CEC_DEFAULT_CONNECT_TIMEOUT
);
508 while (timeout
.TimeLeft() > 0 && (bReturn
= comm
->Open(timeout
.TimeLeft() / CEC_CONNECT_TRIES
, true)) == false)
510 m_libcec
->AddLog(CEC_LOG_ERROR
, "could not open a connection (try %d)", ++iConnectTry
);
512 Sleep(CEC_DEFAULT_TRANSMIT_RETRY_WAIT
);
516 bReturn
= comm
->StartBootloader();
523 m_communication
->StartBootloader();
531 bool CCECProcessor::PingAdapter(void)
533 return m_communication
->PingAdapter();
536 void CCECProcessor::HandlePoll(cec_logical_address initiator
, cec_logical_address destination
)
538 CCECBusDevice
*device
= m_busDevices
->At(destination
);
540 device
->HandlePollFrom(initiator
);
543 bool CCECProcessor::HandleReceiveFailed(cec_logical_address initiator
)
545 CCECBusDevice
*device
= m_busDevices
->At(initiator
);
546 return !device
|| !device
->HandleReceiveFailed();
549 bool CCECProcessor::SetStreamPath(uint16_t iPhysicalAddress
)
551 // stream path changes are sent by the TV
552 return GetTV()->GetHandler()->TransmitSetStreamPath(iPhysicalAddress
);
555 bool CCECProcessor::CanPersistConfiguration(void)
557 return m_communication
? m_communication
->GetFirmwareVersion() >= 2 : false;
560 bool CCECProcessor::PersistConfiguration(const libcec_configuration
&configuration
)
562 return m_communication
? m_communication
->PersistConfiguration(configuration
) : false;
565 void CCECProcessor::RescanActiveDevices(void)
567 for (CECDEVICEMAP::iterator it
= m_busDevices
->Begin(); it
!= m_busDevices
->End(); it
++)
568 it
->second
->GetStatus(true);
571 bool CCECProcessor::GetDeviceInformation(const char *strPort
, libcec_configuration
*config
, uint32_t iTimeoutMs
/* = CEC_DEFAULT_CONNECT_TIMEOUT */)
573 if (!OpenConnection(strPort
, CEC_SERIAL_DEFAULT_BAUDRATE
, iTimeoutMs
, false))
576 config
->iFirmwareVersion
= m_communication
->GetFirmwareVersion();
577 config
->iPhysicalAddress
= m_communication
->GetPhysicalAddress();
578 config
->iFirmwareBuildDate
= m_communication
->GetFirmwareBuildDate();
583 bool CCECProcessor::TransmitPendingActiveSourceCommands(void)
586 for (CECDEVICEMAP::iterator it
= m_busDevices
->Begin(); it
!= m_busDevices
->End(); it
++)
587 bReturn
&= it
->second
->TransmitPendingActiveSourceCommands();
591 CCECTV
*CCECProcessor::GetTV(void) const
593 return CCECBusDevice::AsTV(m_busDevices
->At(CECDEVICE_TV
));
596 CCECAudioSystem
*CCECProcessor::GetAudioSystem(void) const
598 return CCECBusDevice::AsAudioSystem(m_busDevices
->At(CECDEVICE_AUDIOSYSTEM
));
601 CCECPlaybackDevice
*CCECProcessor::GetPlaybackDevice(cec_logical_address address
) const
603 return CCECBusDevice::AsPlaybackDevice(m_busDevices
->At(address
));
606 CCECRecordingDevice
*CCECProcessor::GetRecordingDevice(cec_logical_address address
) const
608 return CCECBusDevice::AsRecordingDevice(m_busDevices
->At(address
));
611 CCECTuner
*CCECProcessor::GetTuner(cec_logical_address address
) const
613 return CCECBusDevice::AsTuner(m_busDevices
->At(address
));
616 bool CCECProcessor::RegisterClient(CCECClient
*client
)
621 libcec_configuration
&configuration
= *client
->GetConfiguration();
623 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_3
&& configuration
.bMonitorOnly
== 1)
626 if (!CECInitialised())
628 m_libcec
->AddLog(CEC_LOG_ERROR
, "failed to register a new CEC client: CEC processor is not initialised");
632 // unregister the client first if it's already been marked as registered
633 if (client
->IsRegistered())
634 UnregisterClient(client
);
636 // get the configuration from the client
637 m_libcec
->AddLog(CEC_LOG_NOTICE
, "registering new CEC client - v%s", ToString((cec_client_version
)configuration
.clientVersion
));
639 // mark as uninitialised and unregistered
640 client
->SetRegistered(false);
641 client
->SetInitialised(false);
643 // get the current ackmask, so we can restore it if polling fails
644 uint16_t iPreviousMask(m_communication
->GetAckMask());
646 // find logical addresses for this client
647 if (!client
->AllocateLogicalAddresses())
649 m_libcec
->AddLog(CEC_LOG_ERROR
, "failed to register the new CEC client - cannot allocate the requested device types");
650 SetAckMask(iPreviousMask
);
654 // register this client on the new addresses
655 CECDEVICEVEC devices
;
656 m_busDevices
->GetByLogicalAddresses(devices
, configuration
.logicalAddresses
);
657 for (CECDEVICEVEC::const_iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
659 // replace a previous client
660 CLockObject
lock(m_mutex
);
661 m_clients
.erase((*it
)->GetLogicalAddress());
662 m_clients
.insert(make_pair
<cec_logical_address
, CCECClient
*>((*it
)->GetLogicalAddress(), client
));
665 // get the settings from the rom
666 if (configuration
.bGetSettingsFromROM
== 1)
668 libcec_configuration config
;
669 m_communication
->GetConfiguration(config
);
671 CLockObject
lock(m_mutex
);
672 if (!config
.deviceTypes
.IsEmpty())
673 configuration
.deviceTypes
= config
.deviceTypes
;
674 if (CLibCEC::IsValidPhysicalAddress(config
.iPhysicalAddress
))
675 configuration
.iPhysicalAddress
= config
.iPhysicalAddress
;
676 snprintf(configuration
.strDeviceName
, 13, "%s", config
.strDeviceName
);
679 // set the firmware version and build date
680 configuration
.serverVersion
= LIBCEC_VERSION_CURRENT
;
681 configuration
.iFirmwareVersion
= m_communication
->GetFirmwareVersion();
682 configuration
.iFirmwareBuildDate
= m_communication
->GetFirmwareBuildDate();
684 // mark the client as registered
685 client
->SetRegistered(true);
687 // set the new ack mask
688 bool bReturn
= SetAckMask(GetLogicalAddresses().AckMask()) &&
689 // and initialise the client
690 client
->OnRegister();
692 // log the new registration
694 strLog
.Format("%s: %s", bReturn
? "CEC client registered" : "failed to register the CEC client", client
->GetConnectionInfo().c_str());
695 m_libcec
->AddLog(bReturn
? CEC_LOG_NOTICE
: CEC_LOG_ERROR
, strLog
);
697 // display a warning if the firmware can be upgraded
698 if (bReturn
&& !IsRunningLatestFirmware())
700 const char *strUpgradeMessage
= "The firmware of this adapter can be upgraded. Please visit http://blog.pulse-eight.com/ for more information.";
701 m_libcec
->AddLog(CEC_LOG_WARNING
, strUpgradeMessage
);
702 libcec_parameter param
;
703 param
.paramData
= (void*)strUpgradeMessage
; param
.paramType
= CEC_PARAMETER_TYPE_STRING
;
704 client
->Alert(CEC_ALERT_SERVICE_DEVICE
, param
);
710 bool CCECProcessor::UnregisterClient(CCECClient
*client
)
715 if (client
->IsRegistered())
716 m_libcec
->AddLog(CEC_LOG_NOTICE
, "unregistering client: %s", client
->GetConnectionInfo().c_str());
718 // notify the client that it will be unregistered
719 client
->OnUnregister();
722 CLockObject
lock(m_mutex
);
723 // find all devices that match the LA's of this client
724 CECDEVICEVEC devices
;
725 m_busDevices
->GetByLogicalAddresses(devices
, client
->GetConfiguration()->logicalAddresses
);
726 for (CECDEVICEVEC::const_iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
729 map
<cec_logical_address
, CCECClient
*>::iterator entry
= m_clients
.find((*it
)->GetLogicalAddress());
730 // unregister the client
731 if (entry
!= m_clients
.end())
732 m_clients
.erase(entry
);
734 // reset the device status
735 (*it
)->ResetDeviceStatus();
739 // set the new ackmask
740 return SetAckMask(GetLogicalAddresses().AckMask());
743 void CCECProcessor::UnregisterClients(void)
745 m_libcec
->AddLog(CEC_LOG_NOTICE
, "unregistering all CEC clients");
747 vector
<CCECClient
*> clients
= m_libcec
->GetClients();
748 for (vector
<CCECClient
*>::iterator client
= clients
.begin(); client
!= clients
.end(); client
++)
749 UnregisterClient(*client
);
751 CLockObject
lock(m_mutex
);
755 CCECClient
*CCECProcessor::GetClient(const cec_logical_address address
)
757 CLockObject
lock(m_mutex
);
758 map
<cec_logical_address
, CCECClient
*>::const_iterator client
= m_clients
.find(address
);
759 if (client
!= m_clients
.end())
760 return client
->second
;
764 CCECClient
*CCECProcessor::GetPrimaryClient(void)
766 CLockObject
lock(m_mutex
);
767 map
<cec_logical_address
, CCECClient
*>::const_iterator client
= m_clients
.begin();
768 if (client
!= m_clients
.end())
769 return client
->second
;
773 CCECBusDevice
*CCECProcessor::GetPrimaryDevice(void)
775 return m_busDevices
->At(GetLogicalAddress());
778 cec_logical_address
CCECProcessor::GetLogicalAddress(void)
780 cec_logical_addresses addresses
= GetLogicalAddresses();
781 return addresses
.primary
;
784 cec_logical_addresses
CCECProcessor::GetLogicalAddresses(void)
786 CLockObject
lock(m_mutex
);
787 cec_logical_addresses addresses
;
789 for (map
<cec_logical_address
, CCECClient
*>::const_iterator client
= m_clients
.begin(); client
!= m_clients
.end(); client
++)
790 addresses
.Set(client
->first
);
795 bool CCECProcessor::IsHandledByLibCEC(const cec_logical_address address
) const
797 CCECBusDevice
*device
= GetDevice(address
);
798 return device
&& device
->IsHandledByLibCEC();
801 bool CCECProcessor::IsRunningLatestFirmware(void)
803 return m_communication
&& m_communication
->IsOpen() ?
804 m_communication
->IsRunningLatestFirmware() :