X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fdevices%2FCECBusDevice.cpp;h=3e44752cc7dd2adfabbbc4319857d4d7b41b5f6f;hb=ebcedb051be7d8e1e19ecd3f0aa164baae252400;hp=3be7adf618786f2b08d68f71374b07d7d2b53c29;hpb=a582c2bb93a3f186e083efb12ff54d143aa7d920;p=deb_libcec.git diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 3be7adf..3e44752 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -39,6 +39,7 @@ #include "lib/implementations/CECCommandHandler.h" #include "lib/implementations/SLCommandHandler.h" #include "lib/implementations/VLCommandHandler.h" +#include "lib/implementations/PHCommandHandler.h" #include "lib/LibCEC.h" #include "lib/CECTypeUtils.h" #include "lib/platform/util/timeutils.h" @@ -75,7 +76,8 @@ CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogi m_iHandlerUseCount (0), m_bAwaitingReceiveFailed(false), m_bVendorIdRequested (false), - m_waitForResponse (new CWaitForResponse) + m_waitForResponse (new CWaitForResponse), + m_bImageViewOnSent (false) { m_handler = new CCECCommandHandler(this); @@ -131,6 +133,9 @@ bool CCECBusDevice::ReplaceHandler(bool bActivateSource /* = true */) case CEC_VENDOR_PANASONIC: m_handler = new CVLCommandHandler(this, iTransmitTimeout, iTransmitWait, iTransmitRetries, iActiveSourcePending); break; + case CEC_VENDOR_PHILIPS: + m_handler = new CPHCommandHandler(this, iTransmitTimeout, iTransmitWait, iTransmitRetries, iActiveSourcePending); + break; default: m_handler = new CCECCommandHandler(this, iTransmitTimeout, iTransmitWait, iTransmitRetries, iActiveSourcePending); break; @@ -610,6 +615,25 @@ void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus) } } +void CCECBusDevice::OnImageViewOnSent(bool bSentByLibCEC) +{ + CLockObject lock(m_mutex); + m_bImageViewOnSent = bSentByLibCEC; + + if (m_powerStatus != CEC_POWER_STATUS_ON && m_powerStatus != CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON) + { + m_iLastPowerStateUpdate = GetTimeMs(); + LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X): power status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_powerStatus), ToString(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON)); + m_powerStatus = CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON; + } +} + +bool CCECBusDevice::ImageViewOnSent(void) +{ + CLockObject lock(m_mutex); + return m_bImageViewOnSent; +} + bool CCECBusDevice::RequestPowerStatus(const cec_logical_address initiator, bool bWaitForResponse /* = true */) { bool bReturn(false); @@ -619,6 +643,8 @@ bool CCECBusDevice::RequestPowerStatus(const cec_logical_address initiator, bool { MarkBusy(); bReturn = m_handler->TransmitRequestPowerStatus(initiator, m_iLogicalAddress, bWaitForResponse); + if (!bReturn) + SetPowerStatus(CEC_POWER_STATUS_UNKNOWN); MarkReady(); } return bReturn; @@ -957,6 +983,10 @@ void CCECBusDevice::MarkAsActiveSource(void) m_bActiveSource = true; } + CCECBusDevice* tv = m_processor->GetDevice(CECDEVICE_TV); + if (tv) + tv->OnImageViewOnSent(false); + // mark other devices as inactive sources CECDEVICEVEC devices; m_processor->GetDevices()->Get(devices); @@ -966,7 +996,8 @@ void CCECBusDevice::MarkAsActiveSource(void) if (bWasActivated) { - m_processor->SetActiveSource(true, false); + if (IsHandledByLibCEC()) + m_processor->SetActiveSource(true, false); CCECClient *client = GetClient(); if (client) client->SourceActivated(m_iLogicalAddress); @@ -988,7 +1019,8 @@ void CCECBusDevice::MarkAsInactiveSource(bool bClientUnregistered /* = false */) if (bWasDeactivated) { - m_processor->SetActiveSource(false, bClientUnregistered); + if (IsHandledByLibCEC()) + m_processor->SetActiveSource(false, bClientUnregistered); CCECClient *client = GetClient(); if (client) client->SourceDeactivated(m_iLogicalAddress); @@ -1043,10 +1075,27 @@ bool CCECBusDevice::TransmitImageViewOn(void) } } + CCECBusDevice* tv = m_processor->GetDevice(CECDEVICE_TV); + if (!tv) + { + LIB_CEC->AddLog(CEC_LOG_ERROR, "%s - couldn't get TV instance", __FUNCTION__); + return false; + } + + if (tv->ImageViewOnSent()) + { + LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - 'image view on' already sent", __FUNCTION__); + return true; + } + bool bImageViewOnSent(false); MarkBusy(); bImageViewOnSent = m_handler->TransmitImageViewOn(m_iLogicalAddress, CECDEVICE_TV); MarkReady(); + + if (bImageViewOnSent) + tv->OnImageViewOnSent(true); + return bImageViewOnSent; } @@ -1075,6 +1124,8 @@ bool CCECBusDevice::TransmitPendingActiveSourceCommands(void) void CCECBusDevice::SetActiveRoute(uint16_t iRoute) { + SetPowerStatus(CEC_POWER_STATUS_ON); + CCECDeviceMap* map = m_processor->GetDevices(); if (!map) return; @@ -1095,6 +1146,8 @@ void CCECBusDevice::SetActiveRoute(uint16_t iRoute) void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = CEC_INVALID_PHYSICAL_ADDRESS */) { + SetPowerStatus(CEC_POWER_STATUS_ON); + CLockObject lock(m_mutex); if (iNewAddress != m_iStreamPath) {