From 5f2068fe56399458a0cee36b6d2271a3671ee227 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 26 Apr 2012 13:04:50 +0200 Subject: [PATCH] cec: fixed stream path changes when changed to the TV source (PA 0) --- src/lib/devices/CECBusDevice.cpp | 35 ++++++++----------- src/lib/implementations/CECCommandHandler.cpp | 2 ++ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index d26e694..d4a8bb0 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -641,32 +641,27 @@ void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress) void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = 0 */) { CLockObject lock(m_mutex); - if (iNewAddress > 0) + if (iNewAddress != m_iStreamPath) { CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): stream path changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, iOldAddress == 0 ? m_iStreamPath : iOldAddress, iNewAddress); m_iStreamPath = iNewAddress; + } - // suppress polls when searching for a device - CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress); + CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress); + if (device) + { + // if a device is found with the new physical address, mark it as active, which will automatically mark all other devices as inactive + device->SetActiveSource(); + } + else + { + // try to find the device with the old address, and mark it as inactive when found + device = m_processor->GetDeviceByPhysicalAddress(iOldAddress); if (device) - { - // if a device is found with the new physical address, mark it as active, which will automatically mark all other devices as inactive - device->SetActiveSource(); - } - else - { - // try to find the device with the old address, and mark it as inactive when found - device = m_processor->GetDeviceByPhysicalAddress(iOldAddress); - if (device) - device->SetInactiveSource(); - } - - if (iNewAddress > 0) - { - lock.Unlock(); - SetPowerStatus(CEC_POWER_STATUS_ON); - } + device->SetInactiveSource(); } + + SetPowerStatus(CEC_POWER_STATUS_ON); } void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus) diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 5fa83ed..1e47782 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -460,6 +460,8 @@ bool CCECCommandHandler::HandleRoutingChange(const cec_command &command) CCECBusDevice *device = GetDevice(command.initiator); if (device) device->SetStreamPath(iNewAddress, iOldAddress); + else + CLibCEC::AddLog(CEC_LOG_DEBUG, "initiator device not found"); } return true; } -- 2.34.1