cec: added a couple of debug lines
[deb_libcec.git] / src / lib / implementations / SLCommandHandler.cpp
index f1e3d7e229539980e1b34e9c71e74f32661c25ec..4d95fad47e4d11b9ff945dbdc824187dffb5176d 100644 (file)
@@ -51,7 +51,8 @@ CSLCommandHandler::CSLCommandHandler(CCECBusDevice *busDevice) :
     CCECCommandHandler(busDevice),
     m_bSLEnabled(false),
     m_bPowerStateReset(false),
-    m_bActiveSourceSent(false)
+    m_bActiveSourceSent(false),
+    m_bVendorIdSent(false)
 {
   m_vendorId = CEC_VENDOR_LG;
   CCECBusDevice *primary = m_processor->GetPrimaryDevice();
@@ -77,19 +78,31 @@ bool CSLCommandHandler::InitHandler(void)
     return true;
   m_bHandlerInited = true;
 
-  /* reply with LGs vendor id */
   CCECBusDevice *primary = m_processor->GetPrimaryDevice();
   if (m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
-    primary->TransmitVendorID(CECDEVICE_BROADCAST, false);
+  {
+    /* start as 'in transition standby->on' */
+    primary->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
+    primary->TransmitPowerState(CECDEVICE_TV);
+  }
 
-  primary->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
   return true;
 }
 
 bool CSLCommandHandler::ActivateSource(void)
 {
+  /* reply with LGs vendor id */
+  if (!m_bVendorIdSent)
+  {
+    m_bVendorIdSent = true;
+    m_processor->GetPrimaryDevice()->TransmitVendorID(CECDEVICE_BROADCAST, false);
+  }
+
   if (!m_bSLEnabled)
+  {
+    CLibCEC::AddLog(CEC_LOG_NOTICE, "not activating the source until SL has been initialised");
     return true;
+  }
 
   if (m_bActiveSourceSent)
     return true;
@@ -107,7 +120,10 @@ bool CSLCommandHandler::HandleActiveSource(const cec_command &command)
   {
     uint16_t iAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
     if (iAddress != m_busDevice->GetPhysicalAddress(false))
+    {
+      CLibCEC::AddLog(CEC_LOG_NOTICE, "resetting SL initialised state");
       m_bSLEnabled = false;
+    }
     return m_processor->SetActiveSource(iAddress);
   }
 
@@ -322,6 +338,7 @@ bool CSLCommandHandler::HandleStandby(const cec_command &command)
 {
   if (command.initiator == CECDEVICE_TV)
   {
+    CLibCEC::AddLog(CEC_LOG_NOTICE, "resetting SL initialised state");
     m_bSLEnabled = false;
     m_bPowerStateReset = false;
     m_bActiveSourceSent = false;