cec: fixed - set power state to powered off when a device handled by libcec is made...
[deb_libcec.git] / src / lib / implementations / CECCommandHandler.cpp
index 57233fd3cc08aad07b346a8200e5f0771611765e..80bc280a3bb9b8af47e7be43582baa8ef9f22111 100644 (file)
@@ -463,6 +463,14 @@ bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command)
     CStdString strLog;
     strLog.Format(">> %i sets stream path to physical address %04x", command.initiator, iStreamAddress);
     m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
+
+    /* one of the device handled by libCEC has been made active */
+    CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamAddress);
+    if (device && m_busDevice->MyLogicalAddressContains(device->GetLogicalAddress()))
+    {
+      device->SetActiveSource();
+      device->TransmitActiveSource();
+    }
   }
   return false;
 }
@@ -556,7 +564,18 @@ bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command)
       {
         CCECBusDevice *device = GetDevice(command.destination);
         if (device)
+        {
           device->SetPowerStatus(CEC_POWER_STATUS_ON);
+          if (device->MyLogicalAddressContains(device->GetLogicalAddress()))
+          {
+            device->SetActiveSource();
+            device->TransmitActiveSource();
+
+            if (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE ||
+                device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE)
+              ((CCECPlaybackDevice *)device)->TransmitDeckStatus(command.initiator);
+          }
+        }
       }
 
       m_processor->SetCurrentButton((cec_user_control_code) command.parameters[0]);