cec: removed framebuffer in CCECProcessor. any other packet is an unexpected reply
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 31 Oct 2011 00:40:13 +0000 (01:40 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Mon, 31 Oct 2011 00:40:13 +0000 (01:40 +0100)
src/lib/AdapterCommunication.cpp
src/lib/AdapterCommunication.h
src/lib/CECProcessor.cpp
src/lib/CECProcessor.h

index 74597665cfb98910423ea35f01562adce47c2dc6..0fee28b50c3a187c7d05268c162b0ba5dc0a7e32 100644 (file)
@@ -85,6 +85,7 @@ CCECAdapterMessage::CCECAdapterMessage(const cec_command &command)
 CCECAdapterMessage &CCECAdapterMessage::operator =(const CCECAdapterMessage &msg)
 {
   packet = msg.packet;
+  state  = msg.state;
   return *this;
 }
 
index 2ec6e3b60c3481597f22b6f4894dc6ec6f16bbca..73b3bd22633bc4203d49945f86970f806ad150d6 100644 (file)
@@ -55,6 +55,7 @@ namespace CEC
   public:
     CCECAdapterMessage(void) { clear(); }
     CCECAdapterMessage(const cec_command &command);
+    CCECAdapterMessage &operator =(const CCECAdapterMessage &msg);
 
     bool                    empty(void) const             { return packet.empty(); }
     uint8_t                 operator[](uint8_t pos) const { return packet[pos]; }
@@ -74,9 +75,6 @@ namespace CEC
     cec_adapter_message_state state;
     CMutex                    mutex;
     CCondition                condition;
-
-  private:
-    CCECAdapterMessage &operator =(const CCECAdapterMessage &msg);
   };
   typedef boost::shared_ptr<CCECAdapterMessage> CCECAdapterMessagePtr;
 
index 79cee667a9bd5f497d0cfcf0229cb9688993bf76..f0f951eba37fdb66358250a7079f9c436bdde09e 100644 (file)
@@ -114,13 +114,9 @@ void *CCECProcessor::Process(void)
 
     {
       CLockObject lock(&m_mutex);
-      CCECAdapterMessagePtr msgPtr;
-      if (m_frameBuffer.Pop(msgPtr))
-        bParseFrame = ParseMessage(*msgPtr.get());
-      else if (m_communication->IsOpen() && m_communication->Read(msg, 50))
-        bParseFrame = ParseMessage(msg);
+      if (m_communication->IsOpen() && m_communication->Read(msg, 50))
+        bParseFrame = ParseMessage(msg) && !IsStopped();
 
-      bParseFrame &= !IsStopped();
       if (bParseFrame)
         command = m_currentframe;
     }
@@ -365,8 +361,10 @@ bool CCECProcessor::WaitForAck(bool *bError, uint8_t iLength, uint32_t iTimeout
       *bError = true;
       break;
     default:
-      CCECAdapterMessagePtr msgPtr = CCECAdapterMessagePtr(new CCECAdapterMessage(msg));
-      m_frameBuffer.Push(msgPtr);
+      CStdString strLog;
+      strLog.Format("received unexpected reply '%2x'", msg.message());
+      m_controller->AddLog(CEC_LOG_WARNING, strLog);
+      *bError = true;
       break;
     }
 
index 6c62c9f283c5b998210a7cd6625da51b619b57da..fa5d6fefeabecec5d81a674661b17aee26e571a2 100644 (file)
@@ -87,7 +87,6 @@ namespace CEC
 
       cec_command                      m_currentframe;
       cec_logical_address              m_iLogicalAddress;
-      CecBuffer<CCECAdapterMessagePtr> m_frameBuffer;
       std::string                      m_strDeviceName;
       CMutex                           m_mutex;
       CCondition                       m_startCondition;