cec: pass unexpected replies to ParseMessage() in WaitForTransmitSucceeded(). added...
authorLars Op den Kamp <lars@opdenkamp.eu>
Tue, 1 Nov 2011 18:39:55 +0000 (19:39 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 1 Nov 2011 18:39:55 +0000 (19:39 +0100)
src/lib/AdapterCommunication.cpp
src/lib/CECProcessor.cpp

index 122565ee4093b87e6fddf618e9479a1afdf991cf..8fc70cd65f2ef129e29b8b2abcd0bd47e7e6c180 100644 (file)
@@ -310,6 +310,7 @@ void *CAdapterCommunication::Process(void)
   while (!IsStopped())
   {
     ReadFromDevice(500);
+    Sleep(5);
     WriteNextCommand();
     Sleep(5);
   }
index 8b8532d7c1d6d2c30df9673d8369fab56fe43e9b..35fb4aa03018772a9a6feb93fc9ae9d3663e24ea 100644 (file)
@@ -115,7 +115,10 @@ void *CCECProcessor::Process(void)
     {
       CLockObject lock(&m_mutex);
       if (m_communication->IsOpen() && m_communication->Read(msg, 50))
+      {
+        m_controller->AddLog(msg.is_error() ? CEC_LOG_WARNING : CEC_LOG_DEBUG, msg.ToString());
         bParseFrame = ParseMessage(msg) && !IsStopped();
+      }
 
       if (bParseFrame)
         command = m_currentframe;
@@ -124,13 +127,14 @@ void *CCECProcessor::Process(void)
     if (bParseFrame)
       ParseCommand(command);
 
+    Sleep(5);
+
     m_controller->CheckKeypressTimeout();
 
     for (unsigned int iDevicePtr = 0; iDevicePtr < 16; iDevicePtr++)
       m_busDevices[iDevicePtr]->PollVendorId();
 
-    if (!IsStopped())
-      Sleep(5);
+    Sleep(5);
   }
 
   return NULL;
@@ -318,6 +322,7 @@ bool CCECProcessor::WaitForTransmitSucceeded(uint8_t iLength, uint32_t iTimeout
       CStdString strLog;
       strLog.Format("received unexpected reply '%s' instead of ack", msg.MessageCodeAsString().c_str());
       m_controller->AddLog(CEC_LOG_WARNING, strLog);
+      ParseMessage(msg);
       bError = true;
       break;
     }
@@ -335,8 +340,6 @@ bool CCECProcessor::ParseMessage(const CCECAdapterMessage &msg)
   if (msg.empty())
     return bEom;
 
-  m_controller->AddLog(msg.is_error() ? CEC_LOG_WARNING : CEC_LOG_DEBUG, msg.ToString());
-
   switch(msg.message())
   {
   case MSGCODE_FRAME_START: