update the active source status correctly after a manual switch to another source...
authorLars Op den Kamp <lars@opdenkamp.eu>
Tue, 22 Jan 2013 00:11:53 +0000 (01:11 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 22 Jan 2013 00:17:52 +0000 (01:17 +0100)
src/lib/devices/CECBusDevice.cpp

index fa063f4e52d47209bf3b223228c939b683602652..83c9b4cd6140323f4ec9ea6defd23e74b4bafbd2 100644 (file)
@@ -1134,8 +1134,26 @@ void CCECBusDevice::SetActiveRoute(uint16_t iRoute)
     return;
 
   CCECBusDevice* newRoute = m_processor->GetDeviceByPhysicalAddress(iRoute, true);
-  if (newRoute && newRoute->IsHandledByLibCEC())
-    newRoute->ActivateSource();
+  if (newRoute)
+  {
+    // we were made the active source, send notification
+    if (newRoute->IsHandledByLibCEC())
+      newRoute->ActivateSource();
+    // another device was made active
+    else
+      newRoute->MarkAsActiveSource();
+  }
+  else
+  {
+    // get the current active source and it's physical address
+    CCECBusDevice *device = m_processor->GetDevices()->GetActiveSource();
+    uint16_t iPhysicalAddress(device ? device->GetCurrentPhysicalAddress() : CEC_INVALID_PHYSICAL_ADDRESS);
+
+    // check whether the route below the device changed
+    if (CLibCEC::IsValidPhysicalAddress(iPhysicalAddress) &&
+        !CCECTypeUtils::PhysicalAddressIsIncluded(iPhysicalAddress, iRoute))
+      device->MarkAsInactiveSource();
+  }
 }
 
 void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = CEC_INVALID_PHYSICAL_ADDRESS */)