cec: fixed - set power state to powered off when a device handled by libcec is made...
authorLars Op den Kamp <lars@opdenkamp.eu>
Fri, 9 Dec 2011 12:28:37 +0000 (13:28 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Fri, 9 Dec 2011 12:28:37 +0000 (13:28 +0100)
src/lib/CECProcessor.cpp
src/lib/devices/CECBusDevice.cpp
src/lib/devices/CECBusDevice.h
src/lib/implementations/CECCommandHandler.cpp

index 565d226493e08c96a316338180332befaa4aa5f4..60a6d1921944c1bbb6be47cfb610867003b91e32 100644 (file)
@@ -530,7 +530,7 @@ bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress)
     for (uint8_t iPtr = 0; iPtr < 15; iPtr++)
       if (m_logicalAddresses[iPtr])
       {
-        m_busDevices[iPtr]->SetInactiveDevice();
+        m_busDevices[iPtr]->SetInactiveSource();
         m_busDevices[iPtr]->SetPhysicalAddress(iPhysicalAddress);
         m_busDevices[iPtr]->TransmitPhysicalAddress();
       }
index f03f0cba0bbf590fd6d2baa325a5b6d56a595df2..41643a3519263a238d025fe92c6b2adc68750dde 100644 (file)
@@ -434,10 +434,15 @@ void CCECBusDevice::SetMenuState(const cec_menu_state state)
   }
 }
 
-void CCECBusDevice::SetInactiveDevice(void)
+void CCECBusDevice::SetInactiveSource(void)
 {
-  CLockObject lock(&m_writeMutex);
-  m_bActiveSource = false;
+  {
+    CLockObject lock(&m_writeMutex);
+    m_bActiveSource = false;
+  }
+
+  if (MyLogicalAddressContains(m_iLogicalAddress))
+    SetPowerStatus(CEC_POWER_STATUS_STANDBY);
 }
 
 void CCECBusDevice::SetActiveSource(void)
@@ -446,7 +451,7 @@ void CCECBusDevice::SetActiveSource(void)
 
   for (int iPtr = 0; iPtr < 16; iPtr++)
     if (iPtr != m_iLogicalAddress)
-      m_processor->m_busDevices[iPtr]->SetInactiveDevice();
+      m_processor->m_busDevices[iPtr]->SetInactiveSource();
 
   m_bActiveSource = true;
   m_powerStatus   = CEC_POWER_STATUS_ON;
index f1786f948d7725008aa1135501846f1974d2948b..b8a9aa94f74a59bc524415c433808a7503d5c45e 100644 (file)
@@ -75,7 +75,7 @@ namespace CEC
     virtual bool                  IsActiveSource(void) const { return m_bActiveSource; }
 
 
-    virtual void SetInactiveDevice(void);
+    virtual void SetInactiveSource(void);
     virtual void SetActiveSource(void);
     virtual bool TryLogicalAddress(void);
 
index 11d550c32adf7bdd6874eab1bef9d3e544e9789a..80bc280a3bb9b8af47e7be43582baa8ef9f22111 100644 (file)
@@ -564,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]);