cec: fixed - use the correct source device for broadcasts
authorLars Op den Kamp <lars@opdenkamp.eu>
Fri, 28 Oct 2011 22:45:35 +0000 (00:45 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Fri, 28 Oct 2011 22:45:35 +0000 (00:45 +0200)
src/lib/CECProcessor.cpp
src/lib/implementations/CECCommandHandler.cpp
src/lib/implementations/CECCommandHandler.h

index bb207511f5d277cd5c648185666eeabbb98347e3..4f696fdfa4d3b79e44db321ef216c29f6757da66 100644 (file)
@@ -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)
index df685bc4731297358623eca56adb24e1a86a464b..e1d34f688acd8f62492a4700b9a0626addc1a6a3 100644 (file)
@@ -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()];
+}
index 70c86eb2476ebab0f526468fa4f1294f2b5909a5..0da4dede4cc27b9748b99497b2af9fbd85344595 100644 (file)
@@ -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;
   };
 };