cec: fixed - use the correct source device for broadcasts
[deb_libcec.git] / src / lib / implementations / CECCommandHandler.cpp
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()];
+}