cec: mark the correct device as active source after a stream path change. if the...
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 19 Mar 2012 14:21:29 +0000 (15:21 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Mon, 19 Mar 2012 14:21:29 +0000 (15:21 +0100)
src/lib/devices/CECBusDevice.cpp

index 429d73fbd162f137870f8c5ed3b479c7fbe80504..814f58a63237b9cbb00456bcd54ace9f2b0cdf88 100644 (file)
@@ -625,6 +625,20 @@ void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /*
     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;
 
+    CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress, false);
+    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, false);
+      if (device)
+        device->SetInactiveSource();
+    }
+
     if (iNewAddress > 0)
     {
       lock.Unlock();