From dbad810a5713fdd10c3aece6f3bedf39c83be826 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sun, 10 Jun 2012 11:40:37 +0200 Subject: [PATCH] cec: TransmitImageViewOn() and TransmitActiveSource() always returned true, even if sending the command failed, so the retry for failed source activations was never triggered --- src/lib/CECProcessor.cpp | 2 +- src/lib/devices/CECBusDevice.cpp | 11 +++++----- src/lib/implementations/CECCommandHandler.cpp | 20 ++++++++++++------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 034c7e6..ca323fc 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -51,7 +51,7 @@ using namespace std; using namespace PLATFORM; #define CEC_PROCESSOR_SIGNAL_WAIT_TIME 1000 -#define ACTIVE_SOURCE_CHECK_TIMEOUT 10000 +#define ACTIVE_SOURCE_CHECK_TIMEOUT 15000 #define ToString(x) CCECTypeUtils::ToString(x) diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 6fd0770..8f966a2 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -952,15 +952,15 @@ bool CCECBusDevice::TransmitActiveSource(void) LIB_CEC->AddLog(CEC_LOG_DEBUG, "<< %s (%X) is not the active source", GetLogicalAddressName(), m_iLogicalAddress); } + bool bActiveSourceSent(false); if (bSendActiveSource) { MarkBusy(); - m_handler->TransmitActiveSource(m_iLogicalAddress, m_iPhysicalAddress); + bActiveSourceSent = m_handler->TransmitActiveSource(m_iLogicalAddress, m_iPhysicalAddress); MarkReady(); - return true; } - return false; + return bActiveSourceSent; } bool CCECBusDevice::TransmitImageViewOn(void) @@ -974,10 +974,11 @@ bool CCECBusDevice::TransmitImageViewOn(void) } } + bool bImageViewOnSent(false); MarkBusy(); - m_handler->TransmitImageViewOn(m_iLogicalAddress, CECDEVICE_TV); + bImageViewOnSent = m_handler->TransmitImageViewOn(m_iLogicalAddress, CECDEVICE_TV); MarkReady(); - return true; + return bImageViewOnSent; } bool CCECBusDevice::TransmitInactiveSource(void) diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 77b94a4..a240c90 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -1069,19 +1069,25 @@ bool CCECCommandHandler::ActivateSource(void) m_busDevice->SetPowerStatus(CEC_POWER_STATUS_ON); m_busDevice->SetMenuState(CEC_MENU_STATE_ACTIVATED); - if (!m_busDevice->TransmitImageViewOn() || - !m_busDevice->TransmitActiveSource() || - !m_busDevice->TransmitMenuState(CECDEVICE_TV)) + bool bActiveSourceFailed = !m_busDevice->TransmitImageViewOn() || + !m_busDevice->TransmitActiveSource() || + !m_busDevice->TransmitMenuState(CECDEVICE_TV); + + if (!bActiveSourceFailed) { + CCECPlaybackDevice *playbackDevice = m_busDevice->AsPlaybackDevice(); + if (playbackDevice && SendDeckStatusUpdateOnActiveSource()) + bActiveSourceFailed = !playbackDevice->TransmitDeckStatus(CECDEVICE_TV); + } + + if (bActiveSourceFailed) + { + LIB_CEC->AddLog(CEC_LOG_DEBUG, "failed to make '%s' the active source. will retry later", m_busDevice->GetLogicalAddressName()); CLockObject lock(m_mutex); m_bActiveSourcePending = true; return false; } - CCECPlaybackDevice *playbackDevice = m_busDevice->AsPlaybackDevice(); - if (playbackDevice && SendDeckStatusUpdateOnActiveSource()) - playbackDevice->TransmitDeckStatus(CECDEVICE_TV); - m_bHandlerInited = true; } return true; -- 2.34.1