send active source message when we received a routing change with a device that is...
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
index e9cc13b93f79974bbc34866687dfb1ac8352c8bc..3217f7151bbbaf64674827901a2c134f9f1f5a50 100644 (file)
@@ -1130,16 +1130,21 @@ void CCECBusDevice::SetActiveRoute(uint16_t iRoute)
   if (!map)
     return;
 
-  CCECBusDevice* previouslyActive = map->GetActiveSource();
-  if (!previouslyActive)
+  CCECBusDevice* newRoute = m_processor->GetDeviceByPhysicalAddress(iRoute, true);
+  if (newRoute && newRoute->IsHandledByLibCEC())
+  {
+    ActivateSource();
     return;
+  }
 
   CECDEVICEVEC devices;
   m_processor->GetDevices()->GetChildrenOf(devices, this);
 
   for (CECDEVICEVEC::iterator it = devices.begin(); it != devices.end(); it++)
   {
-    if (!CCECTypeUtils::PhysicalAddressIsIncluded(iRoute, (*it)->GetCurrentPhysicalAddress()))
+    if ((*it)->GetCurrentPhysicalAddress() == iRoute && (*it)->IsHandledByLibCEC())
+      (*it)->ActivateSource();
+    else if (!CCECTypeUtils::PhysicalAddressIsIncluded(iRoute, (*it)->GetCurrentPhysicalAddress()))
       (*it)->MarkAsInactiveSource();
   }
 }