From: Lars Op den Kamp Date: Tue, 22 Jan 2013 00:11:53 +0000 (+0100) Subject: update the active source status correctly after a manual switch to another source... X-Git-Tag: upstream/2.2.0~1^2~6^2~19 X-Git-Url: https://git.piment-noir.org/?p=deb_libcec.git;a=commitdiff_plain;h=2ff07c6755cf06f25e06e3e5597ea9dc8f7b8f34 update the active source status correctly after a manual switch to another source. closes #124 --- diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index fa063f4..83c9b4c 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -1134,8 +1134,26 @@ void CCECBusDevice::SetActiveRoute(uint16_t iRoute) return; CCECBusDevice* newRoute = m_processor->GetDeviceByPhysicalAddress(iRoute, true); - if (newRoute && newRoute->IsHandledByLibCEC()) - newRoute->ActivateSource(); + if (newRoute) + { + // we were made the active source, send notification + if (newRoute->IsHandledByLibCEC()) + newRoute->ActivateSource(); + // another device was made active + else + newRoute->MarkAsActiveSource(); + } + else + { + // get the current active source and it's physical address + CCECBusDevice *device = m_processor->GetDevices()->GetActiveSource(); + uint16_t iPhysicalAddress(device ? device->GetCurrentPhysicalAddress() : CEC_INVALID_PHYSICAL_ADDRESS); + + // check whether the route below the device changed + if (CLibCEC::IsValidPhysicalAddress(iPhysicalAddress) && + !CCECTypeUtils::PhysicalAddressIsIncluded(iPhysicalAddress, iRoute)) + device->MarkAsInactiveSource(); + } } void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = CEC_INVALID_PHYSICAL_ADDRESS */)