cec: set the retry timeout to 3 (default)
authorLars Op den Kamp <lars@opdenkamp.eu>
Sun, 4 Dec 2011 23:58:50 +0000 (00:58 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Sun, 4 Dec 2011 23:58:50 +0000 (00:58 +0100)
src/lib/CECProcessor.cpp
src/lib/CECProcessor.h
src/lib/implementations/SLCommandHandler.cpp

index 11065ebfec6e5b6bb7198986825db3f93d8c9bd9..3db53f62d083b5d42dd0d00e837a76edeacadfec 100644 (file)
@@ -55,7 +55,9 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, cec
     m_strDeviceName(strDeviceName),
     m_controller(controller),
     m_bMonitor(false),
-    m_busScan(NULL)
+    m_busScan(NULL),
+    m_iStandardLineTimeout(3),
+    m_iRetryLineTimeout(3)
 {
   m_communication = new CAdapterCommunication(this);
   m_logicalAddresses.Clear();
@@ -72,7 +74,9 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, con
     m_strDeviceName(strDeviceName),
     m_types(types),
     m_controller(controller),
-    m_bMonitor(false)
+    m_bMonitor(false),
+    m_iStandardLineTimeout(3),
+    m_iRetryLineTimeout(3)
 {
   m_communication = new CAdapterCommunication(this);
   m_logicalAddresses.Clear();
@@ -333,6 +337,18 @@ bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RE
   return bReturn;
 }
 
+void CCECProcessor::SetStandardLineTimeout(uint8_t iTimeout)
+{
+  CLockObject lock(&m_mutex);
+  m_iStandardLineTimeout = iTimeout;
+}
+
+void CCECProcessor::SetRetryLineTimeout(uint8_t iTimeout)
+{
+  CLockObject lock(&m_mutex);
+  m_iRetryLineTimeout = iTimeout;
+}
+
 bool CCECProcessor::SetActiveSource(cec_logical_address iAddress)
 {
   return SetStreamPath(m_busDevices[iAddress]->GetPhysicalAddress(false));
@@ -674,12 +690,12 @@ bool CCECProcessor::Transmit(CCECAdapterMessage *output)
   bool bReturn(false);
   CLockObject lock(&m_mutex);
   {
-    m_communication->SetLineTimeout(3);
+    m_communication->SetLineTimeout(m_iStandardLineTimeout);
 
     do
     {
       if (output->tries > 0)
-        m_communication->SetLineTimeout(5);
+        m_communication->SetLineTimeout(m_iRetryLineTimeout);
 
       CLockObject msgLock(&output->mutex);
       if (!m_communication || !m_communication->Write(output))
@@ -704,7 +720,7 @@ bool CCECProcessor::Transmit(CCECAdapterMessage *output)
     }while (output->transmit_timeout > 0 && output->needs_retry() && ++output->tries <= output->maxTries);
   }
 
-  m_communication->SetLineTimeout(3);
+  m_communication->SetLineTimeout(m_iStandardLineTimeout);
 
   return bReturn;
 }
index 052dc993834a62d1b656ba30d33d4ec75580efd6..37a77392f195d8e35318803dbf50792fb1ef693b 100644 (file)
@@ -92,6 +92,8 @@ namespace CEC
       virtual bool SendKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait = false);
       virtual bool SendKeyRelease(cec_logical_address iDestination, bool bWait = false);
       virtual bool EnablePhysicalAddressDetection(void) { return false; };
+      void SetStandardLineTimeout(uint8_t iTimeout);
+      void SetRetryLineTimeout(uint8_t iTimeout);
 
       bool SetLineTimeout(uint8_t iTimeout);
 
@@ -155,6 +157,8 @@ namespace CEC
       cec_keypress           m_previousKey;
       CThread *              m_busScan;
       uint8_t                m_iLineTimeout;
+      uint8_t                m_iStandardLineTimeout;
+      uint8_t                m_iRetryLineTimeout;
   };
 
   class CCECBusScan : public CThread
index 05cbf51fbef05dd0b6b1e066f0caa2023291545e..e3789c62d07b36bf9c93f92058afe273d5089aa0 100644 (file)
@@ -198,6 +198,9 @@ bool CSLCommandHandler::InitHandler(void)
     return true;
   m_bSLEnabled = true;
 
+  m_busDevice->GetProcessor()->SetStandardLineTimeout(3);
+  m_busDevice->GetProcessor()->SetRetryLineTimeout(3);
+
   CCECBusDevice *primary = m_busDevice->GetProcessor()->m_busDevices[m_busDevice->GetProcessor()->GetLogicalAddresses().primary];
   if (m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
     primary->SetVendorId(CEC_VENDOR_LG, false);