cec: only let SL bug out when the power state is requested twice in 5 seconds. don...
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 13 Feb 2012 09:28:14 +0000 (10:28 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Mon, 13 Feb 2012 09:48:44 +0000 (10:48 +0100)
src/lib/implementations/SLCommandHandler.cpp
src/lib/implementations/SLCommandHandler.h

index 5a76d286749cd4f19e2068e17ab75cab023a2c01..f1e3d7e229539980e1b34e9c71e74f32661c25ec 100644 (file)
@@ -88,8 +88,11 @@ bool CSLCommandHandler::InitHandler(void)
 
 bool CSLCommandHandler::ActivateSource(void)
 {
+  if (!m_bSLEnabled)
+    return true;
+
   if (m_bActiveSourceSent)
-    return false;
+    return true;
   m_bActiveSourceSent = true;
 
   CCECBusDevice *primary = m_processor->GetPrimaryDevice();
@@ -265,18 +268,29 @@ bool CSLCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command)
       bReturn = device->TransmitPowerState(command.initiator);
       device->SetPowerStatus(CEC_POWER_STATUS_ON);
     }
-    else if (!ActivateSource())
-    {
-      /* assume that we've bugged out */
-      CLibCEC::AddLog(CEC_LOG_NOTICE, "LG seems to have bugged out. resetting to 'in transition standby to on'");
-      m_bActiveSourceSent = false;
-      device->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
-      bReturn = device->TransmitPowerState(command.initiator);
-      device->SetPowerStatus(CEC_POWER_STATUS_ON);
-    }
     else
     {
-      bReturn = true;
+      if (!m_bActiveSourceSent)
+      {
+        device->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
+        bReturn = device->TransmitPowerState(command.initiator);
+        ActivateSource();
+      }
+      else if (m_resetPowerState.IsSet() && m_resetPowerState.TimeLeft() > 0)
+      {
+        /* assume that we've bugged out */
+        CLibCEC::AddLog(CEC_LOG_NOTICE, "LG seems to have bugged out. resetting to 'in transition standby to on'");
+        m_bActiveSourceSent = false;
+        device->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
+        bReturn = device->TransmitPowerState(command.initiator);
+        device->SetPowerStatus(CEC_POWER_STATUS_ON);
+        m_resetPowerState.Init(5000);
+      }
+      else
+      {
+        bReturn = device->TransmitPowerState(command.initiator);
+        m_resetPowerState.Init(5000);
+      }
     }
   }
 
index 8012f2e8913f1a59bca341ef148e4beaeb77d120..914083579f437f5a0bad49df2dc05c922c62e047 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include "CECCommandHandler.h"
+#include "../platform/util/timeutils.h"
 
 namespace CEC
 {
@@ -65,8 +66,9 @@ namespace CEC
     virtual bool HandleFeatureAbort(const cec_command &command);
     virtual bool HandleStandby(const cec_command &command);
 
-    bool    m_bSLEnabled;
-    bool    m_bPowerStateReset;
-    bool    m_bActiveSourceSent;
+    bool               m_bSLEnabled;
+    bool               m_bPowerStateReset;
+    bool               m_bActiveSourceSent;
+    PLATFORM::CTimeout m_resetPowerState;
   };
 };