cec: don't add data to the input buffer in CUSBCECAdapterCommunication before it...
authorLars Op den Kamp <lars@opdenkamp.eu>
Sun, 26 Feb 2012 21:49:43 +0000 (22:49 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Sun, 26 Feb 2012 21:49:43 +0000 (22:49 +0100)
src/lib/adapter/USBCECAdapterCommunication.cpp
src/lib/adapter/USBCECAdapterCommunication.h

index 95c46946c70fd5638c4add7688e63e83929ec717..c12ee546b1a3e1a11e8e75efefeb0f657b469ed7 100644 (file)
@@ -67,7 +67,8 @@ CUSBCECAdapterCommunication::CUSBCECAdapterCommunication(CCECProcessor *processo
     m_lastInitiator(CECDEVICE_UNKNOWN),
     m_bNextIsEscaped(false),
     m_bGotStart(false),
-    m_messageProcessor(NULL)
+    m_messageProcessor(NULL),
+    m_bInitialised(false)
 {
   m_port = new PLATFORM::CSerialPort(strPort, iBaudRate);
 }
@@ -119,6 +120,11 @@ bool CUSBCECAdapterCommunication::CheckAdapter(uint32_t iTimeoutMs /* = 10000 */
   else
     bReturn = true;
 
+  {
+    CLockObject lock(m_mutex);
+    m_bInitialised = bReturn;
+  }
+
   return bReturn;
 }
 
@@ -208,7 +214,7 @@ void *CUSBCECAdapterCommunication::Process(void)
     {
       CLockObject lock(m_mutex);
       ReadFromDevice(50);
-      bCommandReceived = m_callback && Read(command, 0);
+      bCommandReceived = m_callback && Read(command, 0) && m_bInitialised;
     }
 
     /* push the next command to the callback method if there is one */
index 8cc701f094d353c017a3271f2d02358c91cc247f..513900d5be28d8584d3e7431002913c2d6ec977b 100644 (file)
@@ -117,5 +117,6 @@ namespace CEC
     bool                                         m_bGotStart;
     IAdapterCommunicationCallback *              m_callback;
     CUSBCECAdapterProcessor *                    m_messageProcessor;
+    bool                                         m_bInitialised;
   };
 };