From 6685ae0785b7c20af2ddb380e3068a2550cdf978 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sun, 6 Nov 2011 15:08:32 +0100 Subject: [PATCH] cec: send a reply from the correct device when the stream path is requested --- src/lib/devices/CECBusDevice.cpp | 4 +-- src/lib/implementations/CECCommandHandler.cpp | 26 ++++++++++++++----- src/lib/implementations/CECCommandHandler.h | 1 + 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 7c2f6bf..999270b 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -340,7 +340,7 @@ void CCECBusDevice::SetVendorId(uint64_t iVendorId, uint8_t iVendorClass /* = 0 bool CCECBusDevice::TransmitActiveSource(void) { CStdString strLog; - strLog.Format("<< %x -> broadcast: active source", m_iLogicalAddress); + strLog.Format("<< %x -> broadcast: active source (%4x)", m_iLogicalAddress, m_iPhysicalAddress); AddLog(CEC_LOG_NOTICE, strLog); cec_command command; @@ -354,7 +354,7 @@ bool CCECBusDevice::TransmitActiveSource(void) bool CCECBusDevice::TransmitActiveView(void) { CStdString strLog; - strLog.Format("<< %x -> broadcast: active view", m_iLogicalAddress); + strLog.Format("<< %x -> broadcast: active view (%4x)", m_iLogicalAddress, m_iPhysicalAddress); AddLog(CEC_LOG_NOTICE, strLog); cec_command command; diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 9434867..a424bca 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -313,13 +313,9 @@ bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command) CStdString strLog; strLog.Format(">> %i requests stream path from physical address %04x", command.initiator, streamaddr); m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str()); - if (streamaddr == m_busDevice->GetMyPhysicalAddress()) - { - CCECBusDevice *device = GetDevice(command.destination); - if (device) - return device->TransmitActiveSource(); - return false; - } + CCECBusDevice *device = GetDeviceByPhysicalAddress(streamaddr); + if (device) + return device->TransmitActiveSource(); } return true; } @@ -364,3 +360,19 @@ CCECBusDevice *CCECCommandHandler::GetDevice(cec_logical_address iLogicalAddress return device; } + +CCECBusDevice *CCECCommandHandler::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const +{ + CCECBusDevice *device = NULL; + + for (unsigned int iPtr = 0; iPtr < 16; iPtr++) + { + if (m_busDevice->GetProcessor()->m_busDevices[iPtr]->GetPhysicalAddress() == iPhysicalAddress) + { + device = m_busDevice->GetProcessor()->m_busDevices[iPtr]; + break; + } + } + + return device; +} diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index 6be4b70..96f6db5 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -68,6 +68,7 @@ namespace CEC virtual void UnhandledCommand(const cec_command &command); virtual CCECBusDevice *GetDevice(cec_logical_address iLogicalAddress) const; + virtual CCECBusDevice *GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const; CCECBusDevice *m_busDevice; }; }; -- 2.34.1