From: Lars Op den Kamp Date: Mon, 23 Jan 2012 23:39:08 +0000 (+0100) Subject: cec: fixed - don't keep the mutex locked in CCECProcessor::Initialise() X-Git-Tag: upstream/2.2.0~1^2~39^2~20 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=2db8981f49fbd167ddbbf19c1fbadd064abc332a;p=deb_libcec.git cec: fixed - don't keep the mutex locked in CCECProcessor::Initialise() --- diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index c23cb93..efc4f2f 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -152,21 +152,29 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint return bReturn; } -bool CCECProcessor::Initialise(void) +void CCECProcessor::SetInitialised(bool bSetTo /* = true */) { - bool bReturn(false); CLockObject lock(m_mutex); - if (!m_logicalAddresses.IsEmpty()) - m_logicalAddresses.Clear(); + m_bInitialised = bSetTo; +} - if (!FindLogicalAddresses()) +bool CCECProcessor::Initialise(void) +{ + bool bReturn(false); { - m_controller->AddLog(CEC_LOG_ERROR, "could not detect our logical addresses"); - return bReturn; - } + CLockObject lock(m_mutex); + if (!m_logicalAddresses.IsEmpty()) + m_logicalAddresses.Clear(); + + if (!FindLogicalAddresses()) + { + m_controller->AddLog(CEC_LOG_ERROR, "could not detect our logical addresses"); + return bReturn; + } - /* only set our OSD name for the primary device */ - m_busDevices[m_logicalAddresses.primary]->m_strDeviceName = m_strDeviceName; + /* only set our OSD name for the primary device */ + m_busDevices[m_logicalAddresses.primary]->m_strDeviceName = m_strDeviceName; + } /* get the vendor id from the TV, so we are using the correct handler */ m_busDevices[CECDEVICE_TV]->RequestVendorId(); @@ -175,11 +183,11 @@ bool CCECProcessor::Initialise(void) if ((bReturn = SetHDMIPort(m_iBaseDevice, m_iHDMIPort, true)) == false) { CStdString strLog; - strLog.Format("unable to set the correct HDMI port (HDMI %d on %s(%x)", m_iHDMIPort, ToString(m_iBaseDevice), (uint8_t)m_iBaseDevice); + strLog.Format("unable to set HDMI port %d on %s (%x)", m_iHDMIPort, ToString(m_iBaseDevice), (uint8_t)m_iBaseDevice); m_controller->AddLog(CEC_LOG_ERROR, strLog); } - else - m_bInitialised = true; + + SetInitialised(bReturn); return bReturn; } diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 2d6ca5e..e4f0a6b 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -136,6 +136,7 @@ namespace CEC private: bool OpenConnection(const char *strPort, uint16_t iBaudRate, uint32_t iTimeoutMs); bool Initialise(void); + void SetInitialised(bool bSetTo = true); void ReplaceHandlers(void); void ScanCECBus(void);