From: Lars Op den Kamp Date: Sun, 26 Feb 2012 21:49:43 +0000 (+0100) Subject: cec: don't add data to the input buffer in CUSBCECAdapterCommunication before it... X-Git-Tag: upstream/2.2.0~1^2~33^2~32 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=cccd272430983d79cc06de7441b96be33ca2c607;p=deb_libcec.git cec: don't add data to the input buffer in CUSBCECAdapterCommunication before it's fully initialised --- diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index 95c4694..c12ee54 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -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 */ diff --git a/src/lib/adapter/USBCECAdapterCommunication.h b/src/lib/adapter/USBCECAdapterCommunication.h index 8cc701f..513900d 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.h +++ b/src/lib/adapter/USBCECAdapterCommunication.h @@ -117,5 +117,6 @@ namespace CEC bool m_bGotStart; IAdapterCommunicationCallback * m_callback; CUSBCECAdapterProcessor * m_messageProcessor; + bool m_bInitialised; }; };