From bb033e13e66263b9fa45e779e9a6435a85134e0e Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 26 Apr 2012 13:55:27 +0200 Subject: [PATCH] cec: don't try to match a device with PA 0xFFFF. don't change the power status of a device when changing the stream path --- src/lib/CECProcessor.cpp | 17 +++++++---------- src/lib/devices/CECBusDevice.cpp | 10 ++-------- src/lib/devices/CECBusDevice.h | 2 +- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 94d4c7a..8217e4e 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -816,20 +816,17 @@ uint8_t CCECProcessor::MuteAudio(bool bSendRelease /* = true */) CCECBusDevice *CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress, bool bSuppressUpdate /* = true */) { - if (m_configuration.logicalAddresses.primary != CECDEVICE_UNKNOWN) - { - if (m_busDevices[m_configuration.logicalAddresses.primary]->GetPhysicalAddress() == iPhysicalAddress) - return m_busDevices[m_configuration.logicalAddresses.primary]; - } + CCECBusDevice *device(NULL); - CCECBusDevice *device = NULL; - for (unsigned int iPtr = 0; iPtr < 16; iPtr++) + // invalid PA + if (iPhysicalAddress == 0xFFFF) + return device; + + // check each device until we found a match + for (unsigned int iPtr = 0; !device && iPtr < 16; iPtr++) { if (m_busDevices[iPtr]->GetPhysicalAddress(bSuppressUpdate) == iPhysicalAddress) - { device = m_busDevices[iPtr]; - break; - } } return device; diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index d7ee806..757204c 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -47,7 +47,7 @@ using namespace PLATFORM; CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogicalAddress, uint16_t iPhysicalAddress) : m_type (CEC_DEVICE_TYPE_RESERVED), m_iPhysicalAddress (iPhysicalAddress), - m_iStreamPath (0), + m_iStreamPath (0xFFFF), m_iLogicalAddress (iLogicalAddress), m_powerStatus (CEC_POWER_STATUS_UNKNOWN), m_processor (processor), @@ -637,7 +637,7 @@ void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress) } } -void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = 0 */) +void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = 0xFFFF */) { CLockObject lock(m_mutex); if (iNewAddress != m_iStreamPath) @@ -645,10 +645,6 @@ void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* 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; } - else - { - CLibCEC::AddLog(CEC_LOG_DEBUG, "%s (%X): stream path unchanged (%04x)", GetLogicalAddressName(), m_iLogicalAddress, m_iStreamPath); - } CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress); if (device) @@ -663,8 +659,6 @@ void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* if (device) device->SetInactiveSource(); } - - SetPowerStatus(CEC_POWER_STATUS_ON); } void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus) diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index 803f6f6..f6e0d82 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -85,7 +85,7 @@ namespace CEC virtual void SetDeviceStatus(const cec_bus_device_status newStatus); virtual void SetPhysicalAddress(uint16_t iNewAddress); - virtual void SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress = 0); + virtual void SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress = 0xFFFF); virtual void SetCecVersion(const cec_version newVersion); virtual void SetMenuLanguage(const cec_menu_language &menuLanguage); virtual void SetOSDName(CStdString strName); -- 2.34.1