cec: ping the adapter every 15 seconds. bugzid: 541
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 8 Mar 2012 14:19:44 +0000 (15:19 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 8 Mar 2012 14:19:44 +0000 (15:19 +0100)
src/lib/adapter/USBCECAdapterCommunication.cpp

index f56bdf4b1f029a233cce849e74df727ba905918f..85c92f350ec147617cb29e8ceca9c61612f78764 100644 (file)
@@ -40,6 +40,8 @@ using namespace std;
 using namespace CEC;
 using namespace PLATFORM;
 
+#define CEC_ADAPTER_PING_TIMEOUT 15000
+
 void *CUSBCECAdapterProcessor::Process(void)
 {
   cec_command command;
@@ -221,6 +223,7 @@ void *CUSBCECAdapterCommunication::Process(void)
   cec_command command;
   command.Clear();
   bool bCommandReceived(false);
+  CTimeout pingTimeout(CEC_ADAPTER_PING_TIMEOUT);
   while (!IsStopped())
   {
     {
@@ -233,6 +236,13 @@ void *CUSBCECAdapterCommunication::Process(void)
     if (!IsStopped() && bCommandReceived)
       m_messageProcessor->AddCommand(command);
 
+    /* ping the adapter every 15 seconds */
+    if (pingTimeout.TimeLeft() == 0)
+    {
+      pingTimeout.Init(CEC_ADAPTER_PING_TIMEOUT);
+      PingAdapter();
+    }
+
     if (!IsStopped())
     {
       Sleep(5);