bool CCECProcessor::TryLogicalAddress(cec_logical_address address, unsigned int iIndex)
{
- const char *strLabel = CCECCommandHandler::ToString(address);
- CStdString strLog;
- strLog.Format("trying logical address '%s'", strLabel);
- AddLog(CEC_LOG_DEBUG, strLog);
-
- SetAckMask(0x1 << address);
- if (!m_busDevices[address]->TransmitPoll(address))
+ if (m_busDevices[address]->TryLogicalAddress())
{
- strLog.Format("using logical address '%s'", strLabel);
- AddLog(CEC_LOG_NOTICE, strLog);
-
/* only set our OSD name and active source for the primary device */
if (m_logicalAddresses.IsEmpty())
{
m_busDevices[address]->m_strDeviceName = m_strDeviceName;
m_busDevices[address]->m_bActiveSource = true;
}
- m_busDevices[address]->m_powerStatus = CEC_POWER_STATUS_STANDBY;
- m_busDevices[address]->m_cecVersion = CEC_VERSION_1_3A;
- m_busDevices[address]->m_deviceStatus = CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC;
-
m_logicalAddresses.Set(address);
// TODO
return true;
}
- strLog.Format("logical address '%s' already taken", strLabel);
- AddLog(CEC_LOG_DEBUG, strLog);
return false;
}
virtual void AddLog(cec_log_level level, const CStdString &strMessage);
virtual bool FindLogicalAddresses(void);
+ virtual bool SetAckMask(uint16_t iMask);
CCECBusDevice *m_busDevices[16];
bool FindLogicalAddressPlaybackDevice(unsigned int iIndex);
bool FindLogicalAddressAudioSystem(unsigned int iIndex);
- bool SetAckMask(uint16_t iMask);
void LogOutput(const cec_command &data);
bool WaitForTransmitSucceeded(uint8_t iLength, uint32_t iTimeout = 1000);
bool ParseMessage(const CCECAdapterMessage &msg);
m_powerStatus = CEC_POWER_STATUS_ON;
}
+bool CCECBusDevice::TryLogicalAddress(void)
+{
+ CStdString strLog;
+ strLog.Format("trying logical address '%s'", GetLogicalAddressName());
+ AddLog(CEC_LOG_DEBUG, strLog);
+
+ m_processor->SetAckMask(0x1 << m_iLogicalAddress);
+ if (!TransmitPoll(m_iLogicalAddress))
+ {
+ strLog.Format("using logical address '%s'", GetLogicalAddressName());
+ AddLog(CEC_LOG_NOTICE, strLog);
+ SetDeviceStatus(CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC);
+
+ return true;
+ }
+
+ strLog.Format("logical address '%s' already taken", GetLogicalAddressName());
+ AddLog(CEC_LOG_DEBUG, strLog);
+ SetDeviceStatus(CEC_DEVICE_STATUS_PRESENT);
+ return false;
+}
+
+void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus)
+{
+ CLockObject lock(&m_mutex);
+ switch (newStatus)
+ {
+ case CEC_DEVICE_STATUS_UNKNOWN:
+ m_iStreamPath = 0;
+ m_powerStatus = CEC_POWER_STATUS_UNKNOWN;
+ m_vendor = CEC_VENDOR_UNKNOWN;
+ m_menuState = CEC_MENU_STATE_ACTIVATED;
+ m_bActiveSource = false;
+ m_iLastCommandSent = 0;
+ m_iLastActive = 0;
+ m_cecVersion = CEC_VERSION_UNKNOWN;
+ m_deviceStatus = newStatus;
+ break;
+ case CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC:
+ m_iStreamPath = 0;
+ m_powerStatus = CEC_POWER_STATUS_ON;
+ m_vendor = CEC_VENDOR_UNKNOWN;
+ m_menuState = CEC_MENU_STATE_ACTIVATED;
+ m_bActiveSource = false;
+ m_iLastCommandSent = 0;
+ m_iLastActive = 0;
+ m_cecVersion = CEC_VERSION_1_3A;
+ m_deviceStatus = newStatus;
+ break;
+ case CEC_DEVICE_STATUS_PRESENT:
+ case CEC_DEVICE_STATUS_NOT_PRESENT:
+ m_deviceStatus = newStatus;
+ break;
+ }
+}
+
void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress)
{
CLockObject lock(&m_mutex);
virtual void SetInactiveDevice(void);
virtual void SetActiveDevice(void);
+ virtual bool TryLogicalAddress(void);
+ virtual void SetDeviceStatus(const cec_bus_device_status newStatus);
virtual void SetPhysicalAddress(uint16_t iNewAddress);
virtual void SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress = 0);
virtual void SetCecVersion(const cec_version newVersion);