cec: renamed WaitForTransmitSucceeded() to WaitForAck(). don't wait for an ack when...
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 25 Jan 2012 19:27:53 +0000 (20:27 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 25 Jan 2012 19:27:53 +0000 (20:27 +0100)
src/lib/adapter/AdapterCommunication.cpp
src/lib/adapter/AdapterCommunication.h

index 77c90326377b4832d5b40ca0c80f0a8f9fb0a1cb..05ab9b836dd1f6c7ebea9744bcfb8fc7f238ada8 100644 (file)
@@ -153,10 +153,9 @@ bool CAdapterCommunication::Write(CCECAdapterMessage *data)
   {
     CLibCEC::AddLog(CEC_LOG_ERROR, "command was not sent");
   }
-
-  if (data->expectControllerAck)
+  else if (data->expectControllerAck)
   {
-    bReturn = WaitForTransmitSucceeded(data);
+    bReturn = WaitForAck(*data);
     if (bReturn)
     {
       if (data->isTransmission)
@@ -362,20 +361,20 @@ bool CAdapterCommunication::IsOpen(void)
   return !IsStopped() && m_port->IsOpen() && IsRunning();
 }
 
-bool CAdapterCommunication::WaitForTransmitSucceeded(CCECAdapterMessage *message)
+bool CAdapterCommunication::WaitForAck(CCECAdapterMessage &message)
 {
   bool bError(false);
   bool bTransmitSucceeded(false);
-  uint8_t iPacketsLeft(message->Size() / 4);
+  uint8_t iPacketsLeft(message.Size() / 4);
 
   int64_t iNow = GetTimeMs();
-  int64_t iTargetTime = iNow + message->transmit_timeout;
+  int64_t iTargetTime = iNow + message.transmit_timeout;
 
-  while (!bTransmitSucceeded && !bError && (message->transmit_timeout == 0 || iNow < iTargetTime))
+  while (!bTransmitSucceeded && !bError && (message.transmit_timeout == 0 || iNow < iTargetTime))
   {
     CCECAdapterMessage msg;
     int32_t iWait = (int32_t)(iTargetTime - iNow);
-    if (iWait <= 5 || message->transmit_timeout <= 5)
+    if (iWait <= 5 || message.transmit_timeout <= 5)
       iWait = CEC_DEFAULT_TRANSMIT_WAIT;
 
     if (!Read(msg, iWait))
@@ -401,7 +400,7 @@ bool CAdapterCommunication::WaitForTransmitSucceeded(CCECAdapterMessage *message
     bError = msg.IsError();
     if (bError)
     {
-      message->reply = msg.Message();
+      message.reply = msg.Message();
       CLibCEC::AddLog(CEC_LOG_DEBUG, msg.ToString());
     }
     else
@@ -412,14 +411,14 @@ bool CAdapterCommunication::WaitForTransmitSucceeded(CCECAdapterMessage *message
         CLibCEC::AddLog(CEC_LOG_DEBUG, msg.ToString());
         if (iPacketsLeft > 0)
           iPacketsLeft--;
-        if (!message->isTransmission && iPacketsLeft == 0)
+        if (!message.isTransmission && iPacketsLeft == 0)
           bTransmitSucceeded = true;
         break;
       case MSGCODE_TRANSMIT_SUCCEEDED:
         CLibCEC::AddLog(CEC_LOG_DEBUG, msg.ToString());
         bTransmitSucceeded = (iPacketsLeft == 0);
         bError = !bTransmitSucceeded;
-        message->reply = MSGCODE_TRANSMIT_SUCCEEDED;
+        message.reply = MSGCODE_TRANSMIT_SUCCEEDED;
         break;
       default:
         // ignore other data while waiting
index 5178e4f4c3717678c06b48940e7e84a2e101c30d..f7979548c6b41cdf4aadcffab64af7cd855320ab 100644 (file)
@@ -65,7 +65,7 @@ namespace CEC
     bool PingAdapter(void);
     uint16_t GetFirmwareVersion(void);
 
-    bool WaitForTransmitSucceeded(CCECAdapterMessage *message);
+    bool WaitForAck(CCECAdapterMessage &message);
 
   private:
     void SendMessageToAdapter(CCECAdapterMessage *msg);