From: Lars Op den Kamp Date: Wed, 11 Apr 2012 15:40:49 +0000 (+0200) Subject: cec: don't call ReadFromDevice() separately in CUSBCECAdapterCommunication. bugzid... X-Git-Tag: upstream/2.2.0~1^2~31^2~8 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=e07df89779002c323bc7d4b1319f7fac233f2794;p=deb_libcec.git cec: don't call ReadFromDevice() separately in CUSBCECAdapterCommunication. bugzid: 654 --- diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index ab26d84..fc64c76 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -229,7 +229,6 @@ void *CUSBCECAdapterCommunication::Process(void) { { CLockObject lock(m_mutex); - ReadFromDevice(5); bCommandReceived = m_callback && Read(command, 0) && m_bInitialised; } @@ -326,9 +325,10 @@ bool CUSBCECAdapterCommunication::Read(cec_command &command, uint32_t iTimeout) return false; } -bool CUSBCECAdapterCommunication::Read(CCECAdapterMessage &msg, uint32_t iTimeout) +bool CUSBCECAdapterCommunication::Read(CCECAdapterMessage &msg, uint32_t iTimeout, size_t iLen) { CLockObject lock(m_mutex); + ReadFromDevice(iTimeout, iLen); msg.Clear(); CCECAdapterMessage *buf(NULL); @@ -778,9 +778,8 @@ bool CUSBCECAdapterCommunication::WaitForAck(CCECAdapterMessage &message) while (!bTransmitSucceeded && !bError && iNow < iTargetTime) { - ReadFromDevice(50); CCECAdapterMessage msg; - if (!Read(msg, 0)) + if (!Read(msg, 50)) { iNow = GetTimeMs(); continue; @@ -1008,9 +1007,8 @@ cec_datapacket CUSBCECAdapterCommunication::GetSetting(cec_adapter_messagecode m return retVal; } - ReadFromDevice(CEC_DEFAULT_TRANSMIT_WAIT, iResponseLength + 3 /* start + msgcode + iResponseLength + end */); CCECAdapterMessage input; - if (Read(input, 0)) + if (Read(input, CEC_DEFAULT_TRANSMIT_WAIT, iResponseLength + 3 /* start + msgcode + iResponseLength + end */)) { if (input.Message() != msgCode) CLibCEC::AddLog(CEC_LOG_ERROR, "invalid response to %s received (%s)", CCECAdapterMessage::ToString(msgCode), CCECAdapterMessage::ToString(input.Message())); diff --git a/src/lib/adapter/USBCECAdapterCommunication.h b/src/lib/adapter/USBCECAdapterCommunication.h index 4ca8e87..c41f081 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.h +++ b/src/lib/adapter/USBCECAdapterCommunication.h @@ -104,7 +104,7 @@ namespace CEC bool CheckAdapter(uint32_t iTimeoutMs = 10000); bool Write(CCECAdapterMessage *data); - bool Read(CCECAdapterMessage &msg, uint32_t iTimeout = 1000); + bool Read(CCECAdapterMessage &msg, uint32_t iTimeout = 1000, size_t iLen = 64); bool ParseMessage(const CCECAdapterMessage &msg); void SendMessageToAdapter(CCECAdapterMessage *msg); void AddData(uint8_t *data, size_t iLen);