fixed typo in CCECBusDevice::SetActiveRoute(). issue #89
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
index 3e44752cc7dd2adfabbbc4319857d4d7b41b5f6f..b7b08c71e5e16922bd74af9ba8043f2dbb162bb8 100644 (file)
@@ -1130,23 +1130,29 @@ 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())
+  {
+    newRoute->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();
   }
 }
 
 void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = CEC_INVALID_PHYSICAL_ADDRESS */)
 {
-  SetPowerStatus(CEC_POWER_STATUS_ON);
+  if (iNewAddress != CEC_INVALID_PHYSICAL_ADDRESS)
+    SetPowerStatus(CEC_POWER_STATUS_ON);
 
   CLockObject lock(m_mutex);
   if (iNewAddress != m_iStreamPath)