From ff684fefaafa31a52e1b785623f36dba2ee52f81 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Tue, 3 Jan 2012 14:27:15 +0100 Subject: [PATCH] cec: don't make libCEC the active source when changing the physical address. don't send active source messages on startup, when not the active source. fixes unwanted device power ups --- src/lib/CECProcessor.cpp | 12 ++++-------- src/lib/devices/CECBusDevice.cpp | 8 +++++++- src/lib/implementations/ANCommandHandler.cpp | 1 + 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index c13a29b..dd7b2fe 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -176,16 +176,9 @@ bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */, bReturn = SetHDMIPort(m_iBaseDevice, m_iHDMIPort, true); } - /* make the primary device the active source */ if (bReturn) { m_bInitialised = true; - m_busDevices[m_logicalAddresses.primary]->m_bActiveSource = true; - bReturn = m_busDevices[CECDEVICE_TV]->ActivateSource(); - } - - if (bReturn) - { m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started"); } else @@ -606,17 +599,20 @@ bool CCECProcessor::SetMenuState(cec_menu_state state, bool bSendUpdate /* = tru bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress) { + bool bWasActiveSource(false); CLockObject lock(&m_mutex); if (!m_logicalAddresses.IsEmpty()) { for (uint8_t iPtr = 0; iPtr < 15; iPtr++) if (m_logicalAddresses[iPtr]) { + bWasActiveSource |= m_busDevices[iPtr]->IsActiveSource(); m_busDevices[iPtr]->SetInactiveSource(); m_busDevices[iPtr]->SetPhysicalAddress(iPhysicalAddress); m_busDevices[iPtr]->TransmitPhysicalAddress(); } - return SetActiveView(); + + return bWasActiveSource ? SetActiveView() : true; } return false; } diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index b42967d..9e9145c 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -513,6 +513,12 @@ void CCECBusDevice::SetInactiveSource(void) void CCECBusDevice::SetActiveSource(void) { CLockObject lock(&m_mutex); + if (!m_bActiveSource) + { + CStdString strLog; + strLog.Format("making %s (%x) the active source", GetLogicalAddressName(), m_iLogicalAddress); + AddLog(CEC_LOG_DEBUG, strLog); + } for (int iPtr = 0; iPtr < 16; iPtr++) if (iPtr != m_iLogicalAddress) @@ -660,7 +666,7 @@ bool CCECBusDevice::ReplaceHandler(bool bActivateSource /* = true */) m_handler->SetVendorId(m_vendor); m_handler->InitHandler(); - if (bActivateSource && m_processor->GetLogicalAddresses().IsSet(m_iLogicalAddress) && m_processor->IsInitialised()) + if (bActivateSource && m_processor->GetLogicalAddresses().IsSet(m_iLogicalAddress) && m_processor->IsInitialised() && IsActiveSource()) m_handler->ActivateSource(); } } diff --git a/src/lib/implementations/ANCommandHandler.cpp b/src/lib/implementations/ANCommandHandler.cpp index e9674ba..a313819 100644 --- a/src/lib/implementations/ANCommandHandler.cpp +++ b/src/lib/implementations/ANCommandHandler.cpp @@ -40,6 +40,7 @@ using namespace CEC; CANCommandHandler::CANCommandHandler(CCECBusDevice *busDevice) : CCECCommandHandler(busDevice) { + m_vendorId = CEC_VENDOR_SAMSUNG; } bool CANCommandHandler::HandleVendorRemoteButtonDown(const cec_command &command) -- 2.34.1