X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fimplementations%2FCECCommandHandler.cpp;h=0e00e4c2ef0107e654538aa4d2555321b1a6ed20;hb=e75e09bfc2b9799a6a57f9c4ca8cff4984e8fc99;hp=ad2488750b129cbe784fa3f186757d3cf46f47d0;hpb=ecc633c51b6c69bebaff4932e90245665ca06373;p=deb_libcec.git diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index ad24887..0e00e4c 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -209,10 +209,12 @@ int CCECCommandHandler::HandleActiveSource(const cec_command &command) if (command.parameters.size == 2) { uint16_t iAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]); - m_processor->GetDevices()->SetActiveSource(iAddress); - CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iAddress); + CCECBusDevice *device = m_processor->GetDevice(command.initiator); if (device) + { + device->SetPhysicalAddress(iAddress); device->MarkAsActiveSource(); + } m_processor->GetDevices()->SignalAll(command.opcode); return COMMAND_HANDLED; @@ -573,11 +575,21 @@ int CCECCommandHandler::HandleSetStreamPath(const cec_command &command) /* one of the device handled by libCEC has been made active */ CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamAddress); - if (device && device->IsHandledByLibCEC()) + if (device) { - device->ActivateSource(); + if (device->IsHandledByLibCEC()) + device->ActivateSource(); + else + device->MarkAsActiveSource(); return COMMAND_HANDLED; } + else + { + cec_logical_address previousSource = m_processor->GetActiveSource(false); + CCECBusDevice* device = m_processor->GetDevice(previousSource); + if (device && device->GetCurrentPhysicalAddress() != iStreamAddress) + device->MarkAsInactiveSource(); + } } return CEC_ABORT_REASON_INVALID_OPERAND;