cec: don't call ReadFromDevice() separately in CUSBCECAdapterCommunication. bugzid...
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 11 Apr 2012 15:40:49 +0000 (17:40 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 11 Apr 2012 15:48:35 +0000 (17:48 +0200)
src/lib/adapter/USBCECAdapterCommunication.cpp
src/lib/adapter/USBCECAdapterCommunication.h

index ab26d84550f30f010113f12a0228cc55cb330219..fc64c761c8f5352710c218313b1d8b2196f9d15a 100644 (file)
@@ -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()));
index 4ca8e87e1810c794c088dc4a15a7c053422e129c..c41f081cd23774502a79f8e5c3d242000bb638cd 100644 (file)
@@ -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);