cec: mark device status as present when a command was received from a device
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
index 3d8feaf4379ec54e08dd160fe7c5e0362bbc9d81..689ff870b8e1d8a73cdeda66e3d847d145f3d1f0 100644 (file)
@@ -83,6 +83,8 @@ bool CCECBusDevice::HandleCommand(const cec_command &command)
   CLockObject lock(&m_transmitMutex);
   m_iLastActive = GetTimeMs();
   m_handler->HandleCommand(command);
+  if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC)
+    m_deviceStatus = CEC_DEVICE_STATUS_PRESENT;
   m_condition.Signal();
   return true;
 }
@@ -109,23 +111,19 @@ void CCECBusDevice::PollVendorId(void)
 
 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());
+   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);
+   cec_command command;
+   cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_IMAGE_VIEW_ON);
+   if (m_processor->Transmit(command))
+   {
+     GetPowerStatus();
+     return true;
   }
 
-  return true;
+  return false;
 }
 
 bool CCECBusDevice::Standby(void)