From: Lars Op den Kamp Date: Wed, 8 Feb 2012 22:32:56 +0000 (+0100) Subject: cec: don't try to read or write in CUSBCECAdapterCommunication when the connection... X-Git-Tag: upstream/2.2.0~1^2~35^2~135 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=9f68cc28b0e8e5d9caca7194a1ec53a78fa26d27;p=deb_libcec.git cec: don't try to read or write in CUSBCECAdapterCommunication when the connection has been closed --- diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index 1d9f562..924c65a 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -216,6 +216,8 @@ void *CUSBCECAdapterCommunication::Process(void) cec_adapter_message_state CUSBCECAdapterCommunication::Write(const cec_command &data, uint8_t iMaxTries, uint8_t iLineTimeout /* = 3 */, uint8_t iRetryLineTimeout /* = 3 */) { cec_adapter_message_state retVal(ADAPTER_MESSAGE_STATE_UNKNOWN); + if (!IsRunning()) + return retVal; CCECAdapterMessage *output = new CCECAdapterMessage(data); @@ -261,6 +263,9 @@ bool CUSBCECAdapterCommunication::Write(CCECAdapterMessage *data) bool CUSBCECAdapterCommunication::Read(cec_command &command, uint32_t iTimeout) { + if (!IsRunning()) + return false; + CCECAdapterMessage msg; if (Read(msg, iTimeout)) {