From: Lars Op den Kamp Date: Sat, 11 Feb 2012 20:06:33 +0000 (+0100) Subject: cec: don't keep the mutex locked in CCECBusDevice when calling InitHandler X-Git-Tag: upstream/2.2.0~1^2~35^2~98 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=104125dc8316fb58253c34f417ded1e85b22c9f8;p=deb_libcec.git cec: don't keep the mutex locked in CCECBusDevice when calling InitHandler --- diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index c68fc05..ed11d0c 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -613,6 +613,9 @@ bool CCECBusDevice::ReplaceHandler(bool bActivateSource /* = true */) if (m_iHandlerUseCount > 0) return false; + bool bInitHandler(false); + MarkBusy(); + if (m_vendor != m_handler->GetVendorId()) { if (CCECCommandHandler::HasSpecificHandler(m_vendor)) @@ -637,13 +640,20 @@ 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() && IsActiveSource()) - m_handler->ActivateSource(); + bInitHandler = true; } } + if (bInitHandler) + { + m_handler->InitHandler(); + + if (bActivateSource && m_processor->GetLogicalAddresses().IsSet(m_iLogicalAddress) && m_processor->IsInitialised() && IsActiveSource()) + m_handler->ActivateSource(); + } + + MarkReady(); + return true; }