cec: moved the timed ping to a separate thread. bugzid: 654
[deb_libcec.git] / src / lib / adapter / USBCECAdapterCommunication.h
index 227a7e2625c3753a05a3034510d896e103aaa93e..4ca8e87e1810c794c088dc4a15a7c053422e129c 100644 (file)
@@ -45,6 +45,7 @@ namespace PLATFORM
 namespace CEC
 {
   class CCECProcessor;
+  class CAdapterPingThread;
 
   class CUSBCECAdapterCommunication : public IAdapterCommunication, private PLATFORM::CThread
   {
@@ -106,7 +107,6 @@ namespace CEC
     bool Read(CCECAdapterMessage &msg, uint32_t iTimeout = 1000);
     bool ParseMessage(const CCECAdapterMessage &msg);
     void SendMessageToAdapter(CCECAdapterMessage *msg);
-    void WriteNextCommand(void);
     void AddData(uint8_t *data, size_t iLen);
     bool ReadFromDevice(uint32_t iTimeout, size_t iSize = 256);
     bool WaitForAck(CCECAdapterMessage &message);
@@ -114,7 +114,6 @@ namespace CEC
     PLATFORM::ISocket *                          m_port;
     CCECProcessor *                              m_processor;
     PLATFORM::SyncedBuffer<CCECAdapterMessage *> m_inBuffer;
-    PLATFORM::SyncedBuffer<CCECAdapterMessage *> m_outBuffer;
     PLATFORM::CMutex                             m_mutex;
     PLATFORM::CCondition<volatile bool>          m_rcvCondition;
     volatile bool                                m_bHasData;
@@ -128,5 +127,20 @@ namespace CEC
     IAdapterCommunicationCallback *              m_callback;
     bool                                         m_bInitialised;
     bool                                         m_bWaitingForAck[15];
+    CAdapterPingThread *                         m_pingThread;
+  };
+
+  class CAdapterPingThread : public PLATFORM::CThread
+  {
+  public:
+    CAdapterPingThread(CUSBCECAdapterCommunication *com, uint32_t iTimeout) :
+        m_com(com),
+        m_timeout(iTimeout){}
+    virtual ~CAdapterPingThread(void) {}
+
+    virtual void* Process(void);
+  private:
+    CUSBCECAdapterCommunication *m_com;
+    PLATFORM::CTimeout           m_timeout;
   };
 };