cec: make sure that a device is really powered on
authorLars Op den Kamp <lars@opdenkamp.eu>
Tue, 29 Nov 2011 00:55:09 +0000 (01:55 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 29 Nov 2011 00:55:09 +0000 (01:55 +0100)
src/lib/devices/CECBusDevice.cpp

index 439fc05fbf01d27b677eab7f7828f8fabb98bec4..7fe92a451236ec893e89ef47fd213e5ae164fb56 100644 (file)
@@ -99,7 +99,16 @@ bool CCECBusDevice::PowerOn(void)
   cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_IMAGE_VIEW_ON);
   if (m_processor->Transmit(command))
   {
-    RequestPowerStatus();
+    {
+      CLockObject lock(&m_mutex);
+      m_powerStatus = CEC_POWER_STATUS_UNKNOWN;
+    }
+    cec_power_status status = GetPowerStatus();
+    if (status == CEC_POWER_STATUS_STANDBY || status == CEC_POWER_STATUS_UNKNOWN)
+    {
+      SendKeypress(CEC_USER_CONTROL_CODE_POWER, true);
+      return SendKeyRelease(false);
+    }
     return true;
   }