cec: wait 500 ms before trying to retransmit a command. always wait for the result...
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 30 Jan 2012 13:16:47 +0000 (14:16 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Mon, 30 Jan 2012 13:33:58 +0000 (14:33 +0100)
include/cectypes.h
src/lib/CECProcessor.cpp
src/lib/implementations/CECCommandHandler.cpp

index f3864c6aa4384b16167664f4351305132b8778a1..36057eb1f53d046b5c6212a5b63736bcd3f63b67 100644 (file)
@@ -73,9 +73,10 @@ namespace CEC {
 #define CEC_POWER_STATE_REFRESH_TIME 30000
 #define CEC_FW_VERSION_UNKNOWN       0xFFFF
 
-#define CEC_DEFAULT_TRANSMIT_TIMEOUT 1000
-#define CEC_DEFAULT_TRANSMIT_WAIT    2000
-#define CEC_DEFAULT_TRANSMIT_RETRIES 1
+#define CEC_DEFAULT_TRANSMIT_RETRY_WAIT 500
+#define CEC_DEFAULT_TRANSMIT_TIMEOUT    1000
+#define CEC_DEFAULT_TRANSMIT_WAIT       2000
+#define CEC_DEFAULT_TRANSMIT_RETRIES    1
 
 #define CEC_MIN_LIB_VERSION          1
 #define CEC_LIB_VERSION_MAJOR        1
index 0ad84d8168d86b8151654b696a1476798424459c..b54426cb5d255342fcee9b1bee435c1f26dda536 100644 (file)
@@ -324,7 +324,7 @@ bool CCECProcessor::ChangeDeviceType(cec_device_type from, cec_device_type to)
     if (previousDevice && newDevice)
     {
       newDevice->SetDeviceStatus(CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC);
-      previousDevice->SetDeviceStatus(CEC_DEVICE_STATUS_UNKNOWN);
+      previousDevice->SetDeviceStatus(CEC_DEVICE_STATUS_NOT_PRESENT);
 
       newDevice->SetCecVersion(previousDevice->GetCecVersion(false));
       previousDevice->SetCecVersion(CEC_VERSION_UNKNOWN);
@@ -474,6 +474,12 @@ bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RE
   {
     bReturn = m_busDevices[addr]->TransmitActiveSource();
 
+    if (bReturn)
+    {
+      m_busDevices[addr]->SetMenuState(CEC_MENU_STATE_ACTIVATED);
+      m_busDevices[addr]->TransmitMenuState(CECDEVICE_TV);
+    }
+
     if (bReturn && (m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE ||
         m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) &&
         m_busDevices[addr]->GetHandler()->SendDeckStatusUpdateOnActiveSource())
@@ -889,6 +895,8 @@ bool CCECProcessor::Transmit(CCECAdapterMessage *output)
       if (output->tries > 0)
         m_communication->SetLineTimeout(m_iRetryLineTimeout);
       bReturn = m_communication->Write(output);
+      if (!bReturn)
+        Sleep(CEC_DEFAULT_TRANSMIT_RETRY_WAIT);
     }while (!bReturn && output->transmit_timeout > 0 && output->NeedsRetry() && ++output->tries < output->maxTries);
   }
 
index 66bdfbd10b509f150df19d8a648024519c08767d..5fe3ebae6156aabd4c35812e882dffff33431e44 100644 (file)
@@ -959,12 +959,11 @@ bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /*
     while (!bReturn && ++iTries <= iMaxTries)
     {
       m_expectedResponse = expectedResponse;
-      if (m_processor->Transmit(command))
+      if ((bReturn = m_processor->Transmit(command)))
       {
         CLibCEC::AddLog(CEC_LOG_DEBUG, "command transmitted");
-        bReturn = bExpectResponse ?
-            m_condition.Wait(m_receiveMutex, m_iTransmitWait) :
-            true;
+        if (bExpectResponse)
+          bReturn = m_condition.Wait(m_receiveMutex, m_iTransmitWait);
       }
     }
     --m_iUseCounter;