cec: shorter lock times. copy currentframe while locked before processing it
authorLars Op den Kamp <lars@opdenkamp.eu>
Sat, 8 Oct 2011 01:17:16 +0000 (03:17 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Sat, 8 Oct 2011 01:17:16 +0000 (03:17 +0200)
src/lib/AdapterCommunication.cpp
src/lib/CECProcessor.cpp
src/lib/CECProcessor.h

index 627ce27a476ecfab70cc2186aafc0a6be61533ec..68f31a42ee9c3249aec52e25b7f64c1018122abf 100644 (file)
@@ -132,7 +132,7 @@ void *CAdapterCommunication::Process(void)
     {
       CLockObject lock(&m_mutex, true);
       if (lock.IsLocked())
-        bSignal = ReadFromDevice(100);
+        bSignal = ReadFromDevice(50);
     }
 
     if (bSignal)
index 29daf532f27ca9b81fd6a566676baa5d71e4be59..4f2caa70d38ba7526f1bb31bae26bc58ac6cf319 100644 (file)
@@ -85,17 +85,23 @@ void *CCECProcessor::Process(void)
   while (!IsStopped())
   {
     bool bParseFrame(false);
+    cec_frame msg;
+    msg.clear();
+
     {
       CLockObject lock(&m_mutex);
-      cec_frame msg;
-      msg.clear();
-
-      if (m_communication->IsOpen() && m_communication->Read(msg, CEC_BUTTON_TIMEOUT))
+      if (m_communication->IsOpen() && m_communication->Read(msg, 50))
         bParseFrame = ParseMessage(msg) && !IsStopped();
+
+      if (bParseFrame)
+      {
+        msg.clear();
+        msg = m_currentframe;
+      }
     }
 
     if (bParseFrame)
-      ParseCurrentFrame();
+      ParseCurrentFrame(msg);
 
     m_controller->CheckKeypressTimeout();
 
@@ -489,11 +495,8 @@ bool CCECProcessor::ParseMessage(cec_frame &msg)
   return bReturn;
 }
 
-void CCECProcessor::ParseCurrentFrame(void)
+void CCECProcessor::ParseCurrentFrame(cec_frame &frame)
 {
-  cec_frame frame = m_currentframe;
-  m_currentframe.clear();
-
   uint8_t initiator = frame.data[0] >> 4;
   uint8_t destination = frame.data[0] & 0xF;
 
index 5c8d8ab2651340e8a0a752027e44c2f221b61e60..660fee0ffc98053507a1f5142e0f8f326a27a200 100644 (file)
@@ -74,7 +74,7 @@ namespace CEC
     private:
       bool WaitForAck(uint32_t iTimeout = 1000);
       bool ParseMessage(cec_frame &msg);
-      void ParseCurrentFrame(void);
+      void ParseCurrentFrame(cec_frame &frame);
 
       cec_frame                  m_currentframe;
       uint16_t                   m_physicaladdress;