cec: don't make libCEC the active source when changing the physical address. don...
authorLars Op den Kamp <lars@opdenkamp.eu>
Tue, 3 Jan 2012 13:27:15 +0000 (14:27 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 3 Jan 2012 13:27:21 +0000 (14:27 +0100)
src/lib/CECProcessor.cpp
src/lib/devices/CECBusDevice.cpp
src/lib/implementations/ANCommandHandler.cpp

index c13a29bddf0120372651835afcc08b8afb4205b2..dd7b2fec7147ab86ce0a1240b43aa945140a7c31 100644 (file)
@@ -176,16 +176,9 @@ bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */,
     bReturn = SetHDMIPort(m_iBaseDevice, m_iHDMIPort, true);
   }
 
-  /* make the primary device the active source */
   if (bReturn)
   {
     m_bInitialised = true;
-    m_busDevices[m_logicalAddresses.primary]->m_bActiveSource = true;
-    bReturn = m_busDevices[CECDEVICE_TV]->ActivateSource();
-  }
-
-  if (bReturn)
-  {
     m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started");
   }
   else
@@ -606,17 +599,20 @@ bool CCECProcessor::SetMenuState(cec_menu_state state, bool bSendUpdate /* = tru
 
 bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress)
 {
+  bool bWasActiveSource(false);
   CLockObject lock(&m_mutex);
   if (!m_logicalAddresses.IsEmpty())
   {
     for (uint8_t iPtr = 0; iPtr < 15; iPtr++)
       if (m_logicalAddresses[iPtr])
       {
+        bWasActiveSource |= m_busDevices[iPtr]->IsActiveSource();
         m_busDevices[iPtr]->SetInactiveSource();
         m_busDevices[iPtr]->SetPhysicalAddress(iPhysicalAddress);
         m_busDevices[iPtr]->TransmitPhysicalAddress();
       }
-    return SetActiveView();
+
+    return bWasActiveSource ? SetActiveView() : true;
   }
   return false;
 }
index b42967d12613cdbaf48634aed0466b47032cf6e3..9e9145c0e76af2f4b2abcd70c60182f189166722 100644 (file)
@@ -513,6 +513,12 @@ void CCECBusDevice::SetInactiveSource(void)
 void CCECBusDevice::SetActiveSource(void)
 {
   CLockObject lock(&m_mutex);
+  if (!m_bActiveSource)
+  {
+    CStdString strLog;
+    strLog.Format("making %s (%x) the active source", GetLogicalAddressName(), m_iLogicalAddress);
+    AddLog(CEC_LOG_DEBUG, strLog);
+  }
 
   for (int iPtr = 0; iPtr < 16; iPtr++)
     if (iPtr != m_iLogicalAddress)
@@ -660,7 +666,7 @@ bool CCECBusDevice::ReplaceHandler(bool bActivateSource /* = true */)
       m_handler->SetVendorId(m_vendor);
       m_handler->InitHandler();
 
-      if (bActivateSource && m_processor->GetLogicalAddresses().IsSet(m_iLogicalAddress) && m_processor->IsInitialised())
+      if (bActivateSource && m_processor->GetLogicalAddresses().IsSet(m_iLogicalAddress) && m_processor->IsInitialised() && IsActiveSource())
         m_handler->ActivateSource();
     }
   }
index e9674baafb22f84ca8f575d46e407884156cf8a4..a313819ca581cc79c1baef56da150ac57126a2b6 100644 (file)
@@ -40,6 +40,7 @@ using namespace CEC;
 CANCommandHandler::CANCommandHandler(CCECBusDevice *busDevice) :
     CCECCommandHandler(busDevice)
 {
+  m_vendorId = CEC_VENDOR_SAMSUNG;
 }
 
 bool CANCommandHandler::HandleVendorRemoteButtonDown(const cec_command &command)