+ CLockObject lock(&m_mutex);
+ m_iLastActive = GetTimeMs();
+ m_handler->HandleCommand(command);
+ m_condition.Signal();
+ return true;
+}
+
+void CCECBusDevice::PollVendorId(void)
+{
+ CLockObject lock(&m_mutex);
+ if (m_iLastActive > 0 && m_iLogicalAddress != CECDEVICE_BROADCAST &&
+ m_vendor == CEC_VENDOR_UNKNOWN &&
+ GetTimeMs() - m_iLastCommandSent > 5000 &&
+ !m_processor->IsMonitoring())
+ {
+ CStdString strLog;
+ strLog.Format("<< requesting vendor ID of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+ AddLog(CEC_LOG_NOTICE, strLog);
+ m_iLastCommandSent = GetTimeMs();
+
+ cec_command command;
+ cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
+ if (m_processor->Transmit(command))
+ m_condition.Wait(&m_mutex, 1000);
+ }
+}
+
+bool CCECBusDevice::PowerOn(void)
+{
+ cec_power_status current = GetPowerStatus();
+ if (current != CEC_POWER_STATUS_ON &&
+ current != CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON)
+ {
+ CStdString strLog;
+ strLog.Format("<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+ AddLog(CEC_LOG_DEBUG, strLog.c_str());
+
+ SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
+
+ cec_command command;
+ cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_IMAGE_VIEW_ON);
+
+ return m_processor->Transmit(command);
+ }
+
+ return true;
+}
+
+bool CCECBusDevice::Standby(void)
+{
+ CStdString strLog;
+ strLog.Format("<< putting '%s' (%X) in standby mode", GetLogicalAddressName(), m_iLogicalAddress);
+ AddLog(CEC_LOG_DEBUG, strLog.c_str());
+
+ cec_command command;
+ cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_STANDBY);
+
+ return m_processor->Transmit(command);
+}
+
+/** @name Getters */
+//@{
+cec_version CCECBusDevice::GetCecVersion(void)
+{
+ if (m_cecVersion == CEC_VERSION_UNKNOWN)
+ {
+ if (!MyLogicalAddressContains(m_iLogicalAddress))
+ {
+ CStdString strLog;
+ strLog.Format("<< requesting CEC version of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+ AddLog(CEC_LOG_NOTICE, strLog);
+ cec_command command;
+ cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_CEC_VERSION);
+ CLockObject lock(&m_mutex);
+ if (m_processor->Transmit(command))
+ m_condition.Wait(&m_mutex, 1000);
+ }
+ }
+
+ return m_cecVersion;
+}
+
+const char* CCECBusDevice::GetLogicalAddressName(void) const
+{
+ return ToString(m_iLogicalAddress);
+}
+
+cec_menu_language &CCECBusDevice::GetMenuLanguage(void)
+{
+ if (!strcmp(m_menuLanguage.language, "???"))
+ {
+ if (!MyLogicalAddressContains(m_iLogicalAddress))
+ {
+ CStdString strLog;
+ strLog.Format("<< requesting menu language of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+ AddLog(CEC_LOG_NOTICE, strLog);
+ cec_command command;
+ cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_MENU_LANGUAGE);
+ CLockObject lock(&m_mutex);
+ if (m_processor->Transmit(command))
+ m_condition.Wait(&m_mutex, 1000);
+ }
+ }
+
+ return m_menuLanguage;
+}
+
+cec_logical_address CCECBusDevice::GetMyLogicalAddress(void) const
+{
+ return m_processor->GetLogicalAddress();