From: Lars Op den Kamp Date: Tue, 24 Apr 2012 20:29:54 +0000 (+0200) Subject: cec: use the vlcommandhandler for the primary device that is handled by libCEC when... X-Git-Tag: upstream/2.2.0~1^2~29^2^2~46 X-Git-Url: https://git.piment-noir.org/?p=deb_libcec.git;a=commitdiff_plain;h=b47f66afc453fb3fdbad051aceb44941a49965ba cec: use the vlcommandhandler for the primary device that is handled by libCEC when a panasonic tv is detected, so delayed activate source commands are using the correct handler. bugzid: 723 --- diff --git a/src/lib/implementations/VLCommandHandler.cpp b/src/lib/implementations/VLCommandHandler.cpp index 87a3037..5914697 100644 --- a/src/lib/implementations/VLCommandHandler.cpp +++ b/src/lib/implementations/VLCommandHandler.cpp @@ -48,6 +48,17 @@ CVLCommandHandler::CVLCommandHandler(CCECBusDevice *busDevice) : m_bPowerUpEventReceived(false) { m_vendorId = CEC_VENDOR_PANASONIC; + + /* use the VL commandhandler for the primary device that is handled by libCEC */ + if (busDevice->GetLogicalAddress() == CECDEVICE_TV) + { + CCECBusDevice *primary = m_processor->GetPrimaryDevice(); + if (primary && m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress()) + { + primary->SetVendorId(CEC_VENDOR_PANASONIC); + primary->ReplaceHandler(false); + } + } } bool CVLCommandHandler::InitHandler(void) @@ -89,15 +100,11 @@ bool CVLCommandHandler::TransmitActiveSource(const cec_logical_address iInitiato { bool bPowerUpEventReceived(false); + CCECBusDevice *tv = m_processor->m_busDevices[CECDEVICE_TV]; + if (tv && tv->GetVendorId(false) == CEC_VENDOR_PANASONIC) { - CLockObject lock(m_mutex); - if (!m_bPowerUpEventReceived) - { - // just assume it's been sent when the tv is powered on - cec_power_status powerStatus = m_processor->m_busDevices[CECDEVICE_TV]->GetPowerStatus(); - m_bPowerUpEventReceived = (powerStatus == CEC_POWER_STATUS_ON); - } - bPowerUpEventReceived = m_bPowerUpEventReceived; + CVLCommandHandler *handler = static_cast(tv->GetHandler()); + bPowerUpEventReceived = handler ? handler->PowerUpEventReceived() : false; } if (!bPowerUpEventReceived) @@ -130,3 +137,18 @@ bool CVLCommandHandler::TransmitPendingActiveSourceCommands(void) } return true; } + +bool CVLCommandHandler::PowerUpEventReceived(void) +{ + { + CLockObject lock(m_mutex); + if (m_bPowerUpEventReceived) + return true; + } + + cec_power_status powerStatus = m_busDevice->GetPowerStatus(); + + CLockObject lock(m_mutex); + m_bPowerUpEventReceived = (powerStatus == CEC_POWER_STATUS_ON); + return m_bPowerUpEventReceived; +} diff --git a/src/lib/implementations/VLCommandHandler.h b/src/lib/implementations/VLCommandHandler.h index 18b7507..6770947 100644 --- a/src/lib/implementations/VLCommandHandler.h +++ b/src/lib/implementations/VLCommandHandler.h @@ -46,6 +46,8 @@ namespace CEC virtual bool TransmitActiveSource(const cec_logical_address iInitiator, uint16_t iPhysicalAddress); virtual bool TransmitPendingActiveSourceCommands(void); + bool PowerUpEventReceived(void); + private: PLATFORM::CMutex m_mutex; bool m_bActiveSourcePending;