cec: don't try to match a device with PA 0xFFFF. don't change the power status of...
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
index 3f5185e25dc6aa5a51b83546b6c1afaa446e5026..757204cb3ed31ed3b3fb4aae727e2c8c295ac68c 100644 (file)
@@ -47,7 +47,7 @@ using namespace PLATFORM;
 CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogicalAddress, uint16_t iPhysicalAddress) :
   m_type                  (CEC_DEVICE_TYPE_RESERVED),
   m_iPhysicalAddress      (iPhysicalAddress),
-  m_iStreamPath           (0),
+  m_iStreamPath           (0xFFFF),
   m_iLogicalAddress       (iLogicalAddress),
   m_powerStatus           (CEC_POWER_STATUS_UNKNOWN),
   m_processor             (processor),
@@ -533,9 +533,6 @@ void CCECBusDevice::SetInactiveSource(void)
       CLibCEC::AddLog(CEC_LOG_DEBUG, "marking %s (%X) as inactive source", GetLogicalAddressName(), m_iLogicalAddress);
     m_bActiveSource = false;
   }
-
-  if (MyLogicalAddressContains(m_iLogicalAddress))
-    SetPowerStatus(CEC_POWER_STATUS_STANDBY);
 }
 
 void CCECBusDevice::SetActiveSource(void)
@@ -543,6 +540,8 @@ void CCECBusDevice::SetActiveSource(void)
   CLockObject lock(m_mutex);
   if (!m_bActiveSource)
     CLibCEC::AddLog(CEC_LOG_DEBUG, "making %s (%x) the active source", GetLogicalAddressName(), m_iLogicalAddress);
+  else
+    CLibCEC::AddLog(CEC_LOG_DEBUG, "%s (%x) was already marked as active source", GetLogicalAddressName(), m_iLogicalAddress);
 
   for (int iPtr = 0; iPtr < 16; iPtr++)
     if (iPtr != m_iLogicalAddress)
@@ -577,10 +576,11 @@ void CCECBusDevice::ResetDeviceStatus(void)
   SetVendorId      (CEC_VENDOR_UNKNOWN);
   SetMenuState     (CEC_MENU_STATE_ACTIVATED);
   SetCecVersion    (CEC_VERSION_UNKNOWN);
-  SetStreamPath    (0);
+  SetStreamPath    (0xFFFF);
   SetOSDName       (ToString(m_iLogicalAddress));
   SetInactiveSource();
   m_iLastActive = 0;
+  m_unsupportedFeatures.clear();
 }
 
 void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus)
@@ -602,7 +602,7 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus)
       SetVendorId      (CEC_VENDOR_UNKNOWN);
       SetMenuState     (CEC_MENU_STATE_ACTIVATED);
       SetCecVersion    (CEC_VERSION_1_3A);
-      SetStreamPath    (0);
+      SetStreamPath    (0xFFFF);
       SetInactiveSource();
       m_iLastActive   = 0;
       m_deviceStatus  = newStatus;
@@ -637,34 +637,27 @@ void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress)
   }
 }
 
-void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = 0 */)
+void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = 0xFFFF */)
 {
   CLockObject lock(m_mutex);
-  if (iNewAddress > 0)
+  if (iNewAddress != m_iStreamPath)
   {
     CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): stream path changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, iOldAddress == 0 ? m_iStreamPath : iOldAddress, iNewAddress);
     m_iStreamPath = iNewAddress;
+  }
 
-    // suppress polls when searching for a device
-    CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress);
+  CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress);
+  if (device)
+  {
+    // if a device is found with the new physical address, mark it as active, which will automatically mark all other devices as inactive
+    device->SetActiveSource();
+  }
+  else
+  {
+    // try to find the device with the old address, and mark it as inactive when found
+    device = m_processor->GetDeviceByPhysicalAddress(iOldAddress);
     if (device)
-    {
-      // if a device is found with the new physical address, mark it as active, which will automatically mark all other devices as inactive
-      device->SetActiveSource();
-    }
-    else
-    {
-      // try to find the device with the old address, and mark it as inactive when found
-      device = m_processor->GetDeviceByPhysicalAddress(iOldAddress);
-      if (device)
-        device->SetInactiveSource();
-    }
-
-    if (iNewAddress > 0)
-    {
-      lock.Unlock();
-      SetPowerStatus(CEC_POWER_STATUS_ON);
-    }
+      device->SetInactiveSource();
   }
 }