SetAckMask(m_logicalAddresses.AckMask());
+ ScanCECBus();
+
{
CLockObject lock(&m_mutex);
m_bStarted = true;
return bReturn;
}
+void CCECProcessor::ScanCECBus(void)
+{
+ CCECBusDevice *device(NULL);
+ for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
+ {
+ device = m_busDevices[iPtr];
+ if (device && device->GetStatus() == CEC_DEVICE_STATUS_PRESENT)
+ {
+ device->GetPhysicalAddress();
+ device->GetVendorId();
+ device->GetCecVersion();
+ device->GetPowerStatus();
+ }
+ }
+}
+
bool CCECProcessor::CheckPhysicalAddress(uint16_t iPhysicalAddress)
{
for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
bool CCECProcessor::PollDevice(cec_logical_address iAddress)
{
if (iAddress != CECDEVICE_UNKNOWN && m_busDevices[iAddress])
- return m_busDevices[m_logicalAddresses.primary]->TransmitPoll(iAddress);
+ {
+ return m_logicalAddresses.primary == CECDEVICE_UNKNOWN ?
+ m_busDevices[iAddress]->TransmitPoll(iAddress) :
+ m_busDevices[m_logicalAddresses.primary]->TransmitPoll(iAddress);
+ }
return false;
}
CCECBusDevice *m_busDevices[16];
private:
+ void ScanCECBus(void);
bool CheckPhysicalAddress(uint16_t iPhysicalAddress);
bool TryLogicalAddress(cec_logical_address address);
bool FindLogicalAddressRecordingDevice(void);
CLockObject lock(&m_mutex);
if (m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN)
{
- if (m_processor->PollDevice(m_iLogicalAddress))
- m_deviceStatus = CEC_DEVICE_STATUS_PRESENT;
- else
- m_deviceStatus = CEC_DEVICE_STATUS_NOT_PRESENT;
+ lock.Leave();
+ bool bPollAcked = m_processor->PollDevice(m_iLogicalAddress);
+
+ lock.Lock();
+ m_deviceStatus = bPollAcked ? CEC_DEVICE_STATUS_PRESENT : CEC_DEVICE_STATUS_NOT_PRESENT;
}
return m_deviceStatus;