+ if (m_powerStatus == CEC_POWER_STATUS_UNKNOWN)
+ {
+ if (!MyLogicalAddressContains(m_iLogicalAddress))
+ {
+ AddLog(CEC_LOG_NOTICE, "<< requesting power status");
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_POWER_STATUS);
+ CLockObject lock(&m_mutex);
+ if (m_processor->Transmit(command))
+ m_condition.Wait(&m_mutex, 1000);
+ }
+ }
+
+ return m_powerStatus;
+}
+
+const cec_vendor &CCECBusDevice::GetVendor(void)
+{
+ if (m_vendor.vendor == CEC_VENDOR_UNKNOWN)
+ {
+ if (!MyLogicalAddressContains(m_iLogicalAddress))
+ {
+ AddLog(CEC_LOG_NOTICE, "<< requesting vendor ID");
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
+ CLockObject lock(&m_mutex);
+
+ if (m_processor->Transmit(command))
+ m_condition.Wait(&m_mutex, 1000);
+ }
+ }
+
+ return m_vendor;
+}
+
+bool CCECBusDevice::MyLogicalAddressContains(cec_logical_address address) const
+{
+ return m_processor->HasLogicalAddress(address);
+}
+
+//@}
+
+/** @name Setters */
+//@{
+void CCECBusDevice::SetCecVersion(const cec_version newVersion)
+{
+ CStdString strLog;
+ m_cecVersion = newVersion;
+
+ switch (newVersion)
+ {
+ case CEC_VERSION_1_2:
+ strLog.Format("device %d reports CEC version 1.2", m_iLogicalAddress);
+ break;
+ case CEC_VERSION_1_2A:
+ strLog.Format("device %d reports CEC version 1.2a", m_iLogicalAddress);
+ break;
+ case CEC_VERSION_1_3:
+ strLog.Format("device %d reports CEC version 1.3", m_iLogicalAddress);
+ break;
+ case CEC_VERSION_1_3A:
+ strLog.Format("device %d reports CEC version 1.3a", m_iLogicalAddress);
+ break;
+ default:
+ strLog.Format("device %d reports an unknown CEC version", m_iLogicalAddress);
+ m_cecVersion = CEC_VERSION_UNKNOWN;
+ break;
+ }
+ AddLog(CEC_LOG_DEBUG, strLog);
+}
+
+void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language)
+{
+ if (language.device == m_iLogicalAddress)
+ {
+ CStdString strLog;
+ strLog.Format("device %d menu language set to '%s'", m_iLogicalAddress, language.language);
+ m_processor->AddLog(CEC_LOG_DEBUG, strLog);
+ m_menuLanguage = language;
+ }
+}
+
+void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress, uint16_t iOldAddress /* = 0 */)
+{
+ if (iNewAddress > 0)
+ {
+ CStdString strLog;
+ strLog.Format(">> %i changed physical address from %04x to %04x", m_iLogicalAddress, m_iPhysicalAddress, iNewAddress);
+ AddLog(CEC_LOG_DEBUG, strLog.c_str());
+
+ m_iPhysicalAddress = iNewAddress;
+ }
+}
+
+void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus)
+{
+ if (m_powerStatus != powerStatus)
+ {
+ CStdString strLog;
+ strLog.Format("device %d power status changed from %2x to %2x", m_iLogicalAddress, m_powerStatus, powerStatus);
+ m_processor->AddLog(CEC_LOG_DEBUG, strLog);
+ m_powerStatus = powerStatus;
+ }