From: Lars Op den Kamp Date: Fri, 28 Oct 2011 22:45:35 +0000 (+0200) Subject: cec: fixed - use the correct source device for broadcasts X-Git-Tag: upstream/2.2.0~1^2~193 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=09c10b66e7700acd20c62eb3a553fe2d36a6907e;p=deb_libcec.git cec: fixed - use the correct source device for broadcasts --- diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index bb20751..4f696fd 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -49,9 +49,7 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, CAdapterCommunication *serComm m_bMonitor(false) { for (unsigned int iPtr = 0; iPtr < 16; iPtr++) - m_busDevices[iPtr] = new CCECBusDevice(this, (cec_logical_address) iPtr, 0); - - m_busDevices[m_iLogicalAddress]->SetPhysicalAddress(iPhysicalAddress); + m_busDevices[iPtr] = new CCECBusDevice(this, (cec_logical_address) iPtr, iPtr == iLogicalAddress ? iPhysicalAddress : 0); } CCECProcessor::~CCECProcessor(void) diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index df685bc..e1d34f6 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -190,7 +190,11 @@ bool CCECCommandHandler::HandleGiveOSDName(const cec_command &command) bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command) { - return m_busDevice->BroadcastPhysicalAddress(); + CCECBusDevice *device = GetThisDevice(); + if (device) + return device->BroadcastPhysicalAddress(); + + return false; } bool CCECCommandHandler::HandleMenuRequest(const cec_command &command) @@ -209,8 +213,10 @@ bool CCECCommandHandler::HandleRequestActiveSource(const cec_command &command) CStdString strLog; strLog.Format(">> %i requests active source", (uint8_t) command.initiator); m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str()); - m_busDevice->BroadcastActiveSource(); - return true; + CCECBusDevice *device = GetThisDevice(); + if (device) + return device->BroadcastActiveSource(); + return false; } bool CCECCommandHandler::HandleRoutingChange(const cec_command &command) @@ -236,7 +242,12 @@ bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command) 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()) - m_busDevice->BroadcastActiveSource(); + { + CCECBusDevice *device = GetThisDevice(); + if (device) + return device->BroadcastActiveSource(); + return false; + } } return true; } @@ -279,3 +290,8 @@ CCECBusDevice *CCECCommandHandler::GetDevice(cec_logical_address iLogicalAddress return device; } + +CCECBusDevice *CCECCommandHandler::GetThisDevice(void) const +{ + return m_busDevice->GetProcessor()->m_busDevices[m_busDevice->GetMyLogicalAddress()]; +} diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index 70c86eb..0da4ded 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -64,6 +64,7 @@ namespace CEC void UnhandledCommand(const cec_command &command); CCECBusDevice *GetDevice(cec_logical_address iLogicalAddress) const; + CCECBusDevice *GetThisDevice(void) const; CCECBusDevice *m_busDevice; }; };