From: Lars Op den Kamp Date: Mon, 15 Oct 2012 11:26:45 +0000 (+0200) Subject: bit less bus and log spamming while waiting for the tv to power up X-Git-Tag: upstream/2.2.0~1^2~14^2^2~3 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=37383dcc860665341ec1c68e144d6c60551c2dc0;p=deb_libcec.git bit less bus and log spamming while waiting for the tv to power up --- diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index a33a9c3..5137cfb 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -618,7 +618,6 @@ bool CCECBusDevice::RequestPowerStatus(const cec_logical_address initiator, bool !IsUnsupportedFeature(CEC_OPCODE_GIVE_DEVICE_POWER_STATUS)) { MarkBusy(); - LIB_CEC->AddLog(CEC_LOG_DEBUG, "<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); bReturn = m_handler->TransmitRequestPowerStatus(initiator, m_iLogicalAddress, bWaitForResponse); MarkReady(); } diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index da578b1..831825d 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -48,6 +48,7 @@ using namespace PLATFORM; #define LIB_CEC m_busDevice->GetProcessor()->GetLib() #define ToString(p) CCECTypeUtils::ToString(p) +#define REQUEST_POWER_STATUS_TIMEOUT 5000 CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice, int32_t iTransmitTimeout /* = CEC_DEFAULT_TRANSMIT_TIMEOUT */, @@ -62,7 +63,8 @@ CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice, m_bHandlerInited(false), m_bOPTSendDeckStatusUpdateOnActiveSource(false), m_vendorId(CEC_VENDOR_UNKNOWN), - m_iActiveSourcePending(iActiveSourcePending) + m_iActiveSourcePending(iActiveSourcePending), + m_iPowerStatusRequested(0) { } @@ -868,6 +870,16 @@ bool CCECCommandHandler::TransmitRequestPhysicalAddress(const cec_logical_addres bool CCECCommandHandler::TransmitRequestPowerStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse /* = true */) { + if (iDestination == CECDEVICE_TV) + { + int64_t now(GetTimeMs()); + if (now - m_iPowerStatusRequested < REQUEST_POWER_STATUS_TIMEOUT) + return true; + m_iPowerStatusRequested = now; + } + + LIB_CEC->AddLog(CEC_LOG_DEBUG, "<< requesting power status of '%s' (%X)", m_busDevice->GetLogicalAddressName(), iDestination); + cec_command command; cec_command::Format(command, iInitiator, iDestination, CEC_OPCODE_GIVE_DEVICE_POWER_STATUS); @@ -1128,7 +1140,9 @@ bool CCECCommandHandler::ActivateSource(bool bTransmitDelayedCommandsOnly /* = f if (m_iActiveSourcePending == 0 || GetTimeMs() < m_iActiveSourcePending) return false; +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "transmitting delayed activate source command"); +#endif } } diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index fca8a96..1a6cd56 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -152,15 +152,16 @@ namespace CEC virtual bool SourceSwitchAllowed(void) { return true; } - CCECBusDevice * m_busDevice; - CCECProcessor * m_processor; - int32_t m_iTransmitTimeout; - int32_t m_iTransmitWait; - int8_t m_iTransmitRetries; - bool m_bHandlerInited; - bool m_bOPTSendDeckStatusUpdateOnActiveSource; - cec_vendor_id m_vendorId; - int64_t m_iActiveSourcePending; - PLATFORM::CMutex m_mutex; + CCECBusDevice * m_busDevice; + CCECProcessor * m_processor; + int32_t m_iTransmitTimeout; + int32_t m_iTransmitWait; + int8_t m_iTransmitRetries; + bool m_bHandlerInited; + bool m_bOPTSendDeckStatusUpdateOnActiveSource; + cec_vendor_id m_vendorId; + int64_t m_iActiveSourcePending; + PLATFORM::CMutex m_mutex; + int64_t m_iPowerStatusRequested; }; }; diff --git a/src/lib/implementations/VLCommandHandler.cpp b/src/lib/implementations/VLCommandHandler.cpp index d14bec6..b7cdb7a 100644 --- a/src/lib/implementations/VLCommandHandler.cpp +++ b/src/lib/implementations/VLCommandHandler.cpp @@ -45,8 +45,6 @@ #define VL_POWERED_DOWN 0x01 #define VL_UNKNOWN1 0x06 -#define VL_REQUEST_POWER_STATUS_TIMEOUT 5000 - using namespace CEC; using namespace PLATFORM; @@ -63,8 +61,7 @@ CVLCommandHandler::CVLCommandHandler(CCECBusDevice *busDevice, int64_t iActiveSourcePending /* = 0 */) : CCECCommandHandler(busDevice, iTransmitTimeout, iTransmitWait, iTransmitRetries, iActiveSourcePending), m_iPowerUpEventReceived(0), - m_bCapabilitiesSent(false), - m_iPowerStatusRequested(0) + m_bCapabilitiesSent(false) { m_vendorId = CEC_VENDOR_PANASONIC; } @@ -253,16 +250,9 @@ int CVLCommandHandler::HandleVendorCommand(const cec_command &command) return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CVLCommandHandler::TransmitRequestPowerStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse /* = true */) -{ - m_iPowerStatusRequested = GetTimeMs(); - return CCECCommandHandler::TransmitRequestPowerStatus(iInitiator, iDestination, bWaitForResponse); -} - bool CVLCommandHandler::SourceSwitchAllowed(void) { - int64_t now(GetTimeMs()); - if (!PowerUpEventReceived() && now - m_iPowerStatusRequested > VL_REQUEST_POWER_STATUS_TIMEOUT) + if (!PowerUpEventReceived()) TransmitRequestPowerStatus(m_processor->GetPrimaryDevice()->GetLogicalAddress(), CECDEVICE_TV, false); return PowerUpEventReceived(); diff --git a/src/lib/implementations/VLCommandHandler.h b/src/lib/implementations/VLCommandHandler.h index b878ca9..3ad80b4 100644 --- a/src/lib/implementations/VLCommandHandler.h +++ b/src/lib/implementations/VLCommandHandler.h @@ -55,7 +55,6 @@ namespace CEC bool PowerUpEventReceived(void); bool SupportsDeviceType(const cec_device_type type) const { return type != CEC_DEVICE_TYPE_RECORDING_DEVICE; }; cec_device_type GetReplacementDeviceType(const cec_device_type type) const { return type == CEC_DEVICE_TYPE_RECORDING_DEVICE ? CEC_DEVICE_TYPE_PLAYBACK_DEVICE : type; } - bool TransmitRequestPowerStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse = true); bool SourceSwitchAllowed(void); @@ -67,6 +66,5 @@ namespace CEC PLATFORM::CMutex m_mutex; uint64_t m_iPowerUpEventReceived; bool m_bCapabilitiesSent; - int64_t m_iPowerStatusRequested; }; };