X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fdevices%2FCECBusDevice.cpp;h=fc44ebddb2b8294b3b956760074db385c0b55ed5;hb=d211708bee728fa319db6b108196bcda85c2fdeb;hp=340602c3a22cb06043580c595ac27bc9e87231a5;hpb=37acf382b4a151ba018ecd3558fdd5b8cc585077;p=deb_libcec.git 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;