fixed - update the active source status correct on stream path changes
[deb_libcec.git] / src / lib / implementations / CECCommandHandler.cpp
index d1af939188fbf86386295827a6652d1a065f2613..3423c283b1960195a2ffb5f9bb3988ef2fe2b353 100644 (file)
@@ -573,11 +573,21 @@ int CCECCommandHandler::HandleSetStreamPath(const cec_command &command)
 
     /* one of the device handled by libCEC has been made active */
     CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamAddress);
-    if (device && device->IsHandledByLibCEC())
+    if (device)
     {
-      device->ActivateSource();
+      if (device->IsHandledByLibCEC())
+        device->ActivateSource();
+      else
+        device->MarkAsActiveSource();
       return COMMAND_HANDLED;
     }
+    else
+    {
+      cec_logical_address previousSource = m_processor->GetActiveSource(false);
+      CCECBusDevice* device = m_processor->GetDevice(previousSource);
+      if (device && device->GetCurrentPhysicalAddress() != iStreamAddress)
+        device->MarkAsInactiveSource();
+    }
   }
 
   return CEC_ABORT_REASON_INVALID_OPERAND;
@@ -705,7 +715,7 @@ int CCECCommandHandler::HandleUserControlPressed(const cec_command &command)
   {
     // we're not marked as active source, but the tv sends keypresses to us, so assume it forgot to activate us
     if (!device->IsActiveSource() && command.initiator == CECDEVICE_TV)
-      device->ActivateSource();
+      device->MarkAsActiveSource();
   }
 
   return COMMAND_HANDLED;