From: Lars Op den Kamp Date: Sun, 4 Dec 2011 23:36:51 +0000 (+0100) Subject: cec: fix venodor id change. fix physical address change X-Git-Tag: upstream/2.2.0~1^2~44^2~39 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d211708bee728fa319db6b108196bcda85c2fdeb;p=deb_libcec.git cec: fix venodor id change. fix physical address change --- diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 340602c..fc44ebd 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -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; diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index 0097dd4..eb48b34 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -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; } diff --git a/src/lib/implementations/SLCommandHandler.cpp b/src/lib/implementations/SLCommandHandler.cpp index 32ff889..05cbf51 100644 --- a/src/lib/implementations/SLCommandHandler.cpp +++ b/src/lib/implementations/SLCommandHandler.cpp @@ -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) {