cec: fixed - delayed source switch time was reset, resulting in an attempt every...
[deb_libcec.git] / src / lib / implementations / CECCommandHandler.cpp
index 05f5606b93b50fd5032a13e6a63fc7f766f5bc39..8fc844fca9a4629055bf947d3dbfc96db2889c41 100644 (file)
@@ -1114,9 +1114,6 @@ bool CCECCommandHandler::ActivateSource(bool bTransmitDelayedCommandsOnly /* = f
 
         LIB_CEC->AddLog(CEC_LOG_DEBUG, "transmitting delayed activate source command");
       }
-
-      // clear previous pending active source command
-      m_iActiveSourcePending = 0;
     }
 
     // update the power state and menu state
@@ -1155,10 +1152,14 @@ bool CCECCommandHandler::ActivateSource(bool bTransmitDelayedCommandsOnly /* = f
     if (bActiveSourceFailed || !bSourceSwitchAllowed)
     {
       LIB_CEC->AddLog(CEC_LOG_DEBUG, "failed to make '%s' the active source. will retry later", m_busDevice->GetLogicalAddressName());
-      CLockObject lock(m_mutex);
-      m_iActiveSourcePending = GetTimeMs() + (int64_t)CEC_ACTIVE_SOURCE_SWITCH_RETRY_TIME_MS;
       return false;
     }
+    else
+    {
+      CLockObject lock(m_mutex);
+      // clear previous pending active source command
+      m_iActiveSourcePending = 0;
+    }
 
     // mark the handler as initialised
     CLockObject lock(m_mutex);