From: Lars Op den Kamp Date: Sat, 11 Feb 2012 20:28:58 +0000 (+0100) Subject: cec: fix 104125dc8316fb58253c34f417ded1e85b22c9f8 X-Git-Tag: upstream/2.2.0~1^2~35^2~97 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=94e9a2afff9e6bfc18fa401fc9824432475a5927;p=deb_libcec.git cec: fix 104125dc8316fb58253c34f417ded1e85b22c9f8 --- diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index ed11d0c..0fc486f 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -605,42 +605,44 @@ void CCECBusDevice::MarkReady(void) bool CCECBusDevice::ReplaceHandler(bool bActivateSource /* = true */) { - CTryLockObject lock(m_mutex); - if (!lock.IsLocked()) - return false; + bool bInitHandler(false); + { + CTryLockObject lock(m_mutex); + if (!lock.IsLocked()) + return false; - CLockObject handlerLock(m_handlerMutex); - if (m_iHandlerUseCount > 0) - return false; + CLockObject handlerLock(m_handlerMutex); + if (m_iHandlerUseCount > 0) + return false; - bool bInitHandler(false); - MarkBusy(); + MarkBusy(); - if (m_vendor != m_handler->GetVendorId()) - { - if (CCECCommandHandler::HasSpecificHandler(m_vendor)) + if (m_vendor != m_handler->GetVendorId()) { - CLibCEC::AddLog(CEC_LOG_DEBUG, "replacing the command handler for device '%s' (%x)", GetLogicalAddressName(), GetLogicalAddress()); - delete m_handler; - - switch (m_vendor) + if (CCECCommandHandler::HasSpecificHandler(m_vendor)) { - case CEC_VENDOR_SAMSUNG: - m_handler = new CANCommandHandler(this); - break; - case CEC_VENDOR_LG: - m_handler = new CSLCommandHandler(this); - break; - case CEC_VENDOR_PANASONIC: - m_handler = new CVLCommandHandler(this); - break; - default: - m_handler = new CCECCommandHandler(this); - break; + CLibCEC::AddLog(CEC_LOG_DEBUG, "replacing the command handler for device '%s' (%x)", GetLogicalAddressName(), GetLogicalAddress()); + delete m_handler; + + switch (m_vendor) + { + case CEC_VENDOR_SAMSUNG: + m_handler = new CANCommandHandler(this); + break; + case CEC_VENDOR_LG: + m_handler = new CSLCommandHandler(this); + break; + case CEC_VENDOR_PANASONIC: + m_handler = new CVLCommandHandler(this); + break; + default: + m_handler = new CCECCommandHandler(this); + break; + } + + m_handler->SetVendorId(m_vendor); + bInitHandler = true; } - - m_handler->SetVendorId(m_vendor); - bInitHandler = true; } } diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 9f9c882..8c18958 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -962,8 +962,8 @@ bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /* CLibCEC::AddLog(CEC_LOG_DEBUG, "command transmitted"); if (bExpectResponse) bReturn = m_condition.Wait(m_receiveMutex, m_bRcvSignal, m_iTransmitWait); - if (bReturn) - m_bRcvSignal = false; + m_bRcvSignal = false; + CLibCEC::AddLog(CEC_LOG_DEBUG, bReturn ? "expected response received" : "expected response not received"); } } }