- if ((*it)->GetCurrentPhysicalAddress() == iRoute && (*it)->IsHandledByLibCEC())
- (*it)->ActivateSource();
- else if (!CCECTypeUtils::PhysicalAddressIsIncluded(iRoute, (*it)->GetCurrentPhysicalAddress()))
- (*it)->MarkAsInactiveSource();
+ // 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();