cec: fix handler init
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 21 Dec 2011 23:55:45 +0000 (00:55 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 21 Dec 2011 23:56:37 +0000 (00:56 +0100)
src/lib/CECProcessor.cpp
src/lib/implementations/CECCommandHandler.cpp
src/lib/implementations/CECCommandHandler.h
src/lib/implementations/SLCommandHandler.cpp

index 770b24bab6bfc937125b974f6acabd4204943092..5b1c06ea98b39e2da2da9f206a7803243452680d 100644 (file)
@@ -170,9 +170,8 @@ bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */,
 
     if (SetHDMIPort(m_iBaseDevice, m_iHDMIPort, true))
     {
-      /* init the default handler */
-      if (m_busDevices[CECDEVICE_TV]->GetHandler()->GetVendorId() == CEC_VENDOR_UNKNOWN)
-        m_busDevices[CECDEVICE_TV]->GetHandler()->InitHandler();
+      /* init the handler */
+      m_busDevices[CECDEVICE_TV]->GetHandler()->InitHandler();
 
       m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started");
       return true;
index 8d16a02fded9c611518c66207693ea95e29385d0..ef8a8f28f789c160839608641bfaa6b21ea3828b 100644 (file)
@@ -44,7 +44,8 @@ CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice) :
     m_processor(m_busDevice->GetProcessor()),
     m_iTransmitTimeout(CEC_DEFAULT_TRANSMIT_TIMEOUT),
     m_iTransmitWait(CEC_DEFAULT_TRANSMIT_WAIT),
-    m_iTransmitRetries(CEC_DEFAULT_TRANSMIT_RETRIES)
+    m_iTransmitRetries(CEC_DEFAULT_TRANSMIT_RETRIES),
+    m_bHandlerInited(false)
 {
 }
 
@@ -946,8 +947,12 @@ bool CCECCommandHandler::InitHandler(void)
     primary->SetPowerStatus(CEC_POWER_STATUS_ON);
     primary->SetMenuState(CEC_MENU_STATE_ACTIVATED);
 
-    m_processor->SetActiveSource();
-    primary->TransmitMenuState(m_busDevice->GetLogicalAddress());
+    if (m_processor->GetPrimaryDevice()->GetPhysicalAddress(false) != 0xffff)
+    {
+      m_processor->SetActiveSource();
+      primary->TransmitMenuState(m_busDevice->GetLogicalAddress());
+      m_bHandlerInited = true;
+    }
   }
   return true;
 }
index 762052bc6050c752e56fd0a7d16650f0a492fb55..0469b31e0eaf6412360f6ced970c8f4cad619a4e 100644 (file)
@@ -130,6 +130,7 @@ namespace CEC
     int32_t        m_iTransmitTimeout;
     int32_t        m_iTransmitWait;
     int8_t         m_iTransmitRetries;
+    bool           m_bHandlerInited;
     CMutex         m_receiveMutex;
     CCondition     m_condition;
   };
index e63f1bb08a2df0db064fdb151ec1e71c4a138c98..f86a644f2db452804a19baa3c32f4e37fa83d7ba 100644 (file)
@@ -246,6 +246,10 @@ bool CSLCommandHandler::HandleReceiveFailed(void)
 
 bool CSLCommandHandler::InitHandler(void)
 {
+  if (m_bHandlerInited)
+    return true;
+  m_bHandlerInited = true;
+
   m_processor->SetStandardLineTimeout(3);
   m_processor->SetRetryLineTimeout(3);