From: Lars Op den Kamp Date: Fri, 17 Feb 2012 10:23:12 +0000 (+0100) Subject: cec: ensure that the vendor id is requested first when requesting info from a device... X-Git-Tag: upstream/2.2.0~1^2~35^2~13 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ebb6ddb38f42d6185faf3c30be8ccfeee1889ee2;p=deb_libcec.git cec: ensure that the vendor id is requested first when requesting info from a device, so we are using the correct handler --- diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 3c39371..33d472f 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -60,7 +60,8 @@ CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogi m_cecVersion(CEC_VERSION_UNKNOWN), m_deviceStatus(CEC_DEVICE_STATUS_UNKNOWN), m_iHandlerUseCount(0), - m_bAwaitingReceiveFailed(false) + m_bAwaitingReceiveFailed(false), + m_bVendorIdRequested(false) { m_handler = new CCECCommandHandler(this); @@ -160,7 +161,10 @@ cec_version CCECBusDevice::GetCecVersion(bool bUpdate /* = false */) } if (bRequestUpdate) + { + CheckVendorIdRequested(); RequestCecVersion(); + } CLockObject lock(m_mutex); return m_cecVersion; @@ -198,7 +202,10 @@ cec_menu_language &CCECBusDevice::GetMenuLanguage(bool bUpdate /* = false */) } if (bRequestUpdate) + { + CheckVendorIdRequested(); RequestMenuLanguage(); + } CLockObject lock(m_mutex); return m_menuLanguage; @@ -247,7 +254,10 @@ CStdString CCECBusDevice::GetOSDName(bool bUpdate /* = false */) } if (bRequestUpdate) + { + CheckVendorIdRequested(); RequestOSDName(); + } CLockObject lock(m_mutex); return m_strDeviceName; @@ -278,8 +288,12 @@ uint16_t CCECBusDevice::GetPhysicalAddress(bool bUpdate /* = false */) (m_iPhysicalAddress == 0xFFFF || bUpdate); } - if (bRequestUpdate && !RequestPhysicalAddress()) - CLibCEC::AddLog(CEC_LOG_ERROR, "failed to request the physical address"); + if (bRequestUpdate) + { + CheckVendorIdRequested(); + if (!RequestPhysicalAddress()) + CLibCEC::AddLog(CEC_LOG_ERROR, "failed to request the physical address"); + } CLockObject lock(m_mutex); return m_iPhysicalAddress; @@ -313,7 +327,10 @@ cec_power_status CCECBusDevice::GetPowerStatus(bool bUpdate /* = false */) } if (bRequestUpdate) + { + CheckVendorIdRequested(); RequestPowerStatus(); + } CLockObject lock(m_mutex); return m_powerStatus; @@ -975,4 +992,20 @@ bool CCECBusDevice::HandleReceiveFailed(void) return bReturn; } +void CCECBusDevice::CheckVendorIdRequested(void) +{ + bool bRequestVendorId(false); + { + CLockObject lock(m_mutex); + bRequestVendorId = !m_bVendorIdRequested; + m_bVendorIdRequested = true; + } + + if (bRequestVendorId) + { + ReplaceHandler(false); + GetVendorId(); + } +} + //@} diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index a4350da..5428ec1 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -109,6 +109,7 @@ namespace CEC virtual bool TransmitKeyRelease(bool bWait = true); protected: + void CheckVendorIdRequested(void); bool ReplaceHandler(bool bActivateSource = true); void MarkBusy(void); void MarkReady(void); @@ -145,5 +146,6 @@ namespace CEC PLATFORM::CEvent m_replacing; unsigned m_iHandlerUseCount; bool m_bAwaitingReceiveFailed; + bool m_bVendorIdRequested; }; };