cec: fix venodor id change. fix physical address change
authorLars Op den Kamp <lars@opdenkamp.eu>
Sun, 4 Dec 2011 23:36:51 +0000 (00:36 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Sun, 4 Dec 2011 23:36:51 +0000 (00:36 +0100)
src/lib/devices/CECBusDevice.cpp
src/lib/devices/CECBusDevice.h
src/lib/implementations/SLCommandHandler.cpp

index 340602c3a22cb06043580c595ac27bc9e87231a5..fc44ebddb2b8294b3b956760074db385c0b55ed5 100644 (file)
@@ -566,46 +566,41 @@ void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus)
   }
 }
 
-void CCECBusDevice::SetVendorId(uint64_t iVendorId)
+void CCECBusDevice::SetVendorId(uint64_t iVendorId, bool bInitHandler /* = true */)
 {
+  bool bVendorChanged(false);
+
   {
     CLockObject lock(&m_writeMutex);
+    bVendorChanged = (m_vendor != (cec_vendor_id)iVendorId);
     m_vendor = (cec_vendor_id)iVendorId;
 
+    if (bVendorChanged)
+      delete m_handler;
+
     switch (iVendorId)
     {
     case CEC_VENDOR_SAMSUNG:
-      if (m_handler->GetVendorId() != CEC_VENDOR_SAMSUNG)
-      {
-        delete m_handler;
+      if (bVendorChanged)
         m_handler = new CANCommandHandler(this);
-      }
       break;
     case CEC_VENDOR_LG:
-      if (m_handler->GetVendorId() != CEC_VENDOR_LG)
-      {
-        delete m_handler;
+      if (bVendorChanged)
         m_handler = new CSLCommandHandler(this);
-      }
       break;
     case CEC_VENDOR_PANASONIC:
-      if (m_handler->GetVendorId() != CEC_VENDOR_PANASONIC)
-      {
-        delete m_handler;
+      if (bVendorChanged)
         m_handler = new CVLCommandHandler(this);
-      }
       break;
     default:
-      if (m_handler->GetVendorId() != CEC_VENDOR_UNKNOWN)
-      {
-        delete m_handler;
+      if (bVendorChanged)
         m_handler = new CCECCommandHandler(this);
-      }
       break;
     }
   }
 
-  m_handler->InitHandler();
+  if (bVendorChanged && bInitHandler)
+    m_handler->InitHandler();
 
   CStdString strLog;
   strLog.Format("%s (%X): vendor = %s (%06x)", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_vendor), m_vendor);
@@ -731,7 +726,7 @@ bool CCECBusDevice::TransmitPhysicalAddress(void)
 {
   CLockObject lock(&m_writeMutex);
 
-  if (m_iPhysicalAddress = 0xffff)
+  if (m_iPhysicalAddress == 0xffff)
     return false;
 
   CStdString strLog;
index 0097dd4f28eb49e0e45cf7472be1bcdffa37886a..eb48b343cea0b96c97141e4fce809bd3e3ee9b3a 100644 (file)
@@ -91,7 +91,7 @@ namespace CEC
     virtual void SetMenuLanguage(const cec_menu_language &menuLanguage);
     virtual void SetOSDName(CStdString strName);
     virtual void SetMenuState(const cec_menu_state state);
-    virtual void SetVendorId(uint64_t iVendorId);
+    virtual void SetVendorId(uint64_t iVendorId, bool bInitHandler = true);
     virtual void SetPowerStatus(const cec_power_status powerStatus);
     virtual void SetTransmitTimeout(uint32_t iTimeout) { m_iTransmitTimeout = iTimeout; }
 
index 32ff88940fb10d0fbd54547979954fde50171ed7..05cbf51fbef05dd0b6b1e066f0caa2023291545e 100644 (file)
@@ -199,7 +199,8 @@ bool CSLCommandHandler::InitHandler(void)
   m_bSLEnabled = true;
 
   CCECBusDevice *primary = m_busDevice->GetProcessor()->m_busDevices[m_busDevice->GetProcessor()->GetLogicalAddresses().primary];
-  primary->SetVendorId(CEC_VENDOR_LG);
+  if (m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
+    primary->SetVendorId(CEC_VENDOR_LG, false);
 
   if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
   {