cec: don't keep the mutex locked in CCECBusDevice when calling InitHandler
authorLars Op den Kamp <lars@opdenkamp.eu>
Sat, 11 Feb 2012 20:06:33 +0000 (21:06 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Sat, 11 Feb 2012 20:06:33 +0000 (21:06 +0100)
src/lib/devices/CECBusDevice.cpp

index c68fc0584b9ca744244965c26f175c06804df774..ed11d0c325e33d5d8d2d60d9e9b93a0fc6db6c75 100644 (file)
@@ -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;
 }