cec: moved the autodetect address api call to libcec_configuration. only send power...
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
index a5d884e5e397b7424d66e78d397cf9277af8effe..3f82da62667b627c2dfe8262ba8e2680015db625 100644 (file)
@@ -117,11 +117,20 @@ bool CCECBusDevice::PowerOn(void)
   GetVendorId(); // ensure that we got the vendor id, because the implementations vary per vendor
 
   MarkBusy();
-  CLibCEC::AddLog(CEC_LOG_NOTICE, "<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
-  if (m_handler->PowerOn(GetMyLogicalAddress(), m_iLogicalAddress))
+  cec_power_status currentStatus = GetPowerStatus(false);
+  if (currentStatus != CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON &&
+    currentStatus != CEC_POWER_STATUS_ON)
   {
-    SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
-    bReturn = true;
+    CLibCEC::AddLog(CEC_LOG_NOTICE, "<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+    if (m_handler->PowerOn(GetMyLogicalAddress(), m_iLogicalAddress))
+    {
+      SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
+      bReturn = true;
+    }
+  }
+  else
+  {
+    CLibCEC::AddLog(CEC_LOG_NOTICE, "'%s' (%X) is already '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(currentStatus));
   }
 
   MarkReady();