X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fimplementations%2FCECCommandHandler.cpp;h=0e00e4c2ef0107e654538aa4d2555321b1a6ed20;hb=0b83551352338fb45b285c44d6baccd867f05b6d;hp=5a2afb17143d9d95314de110a2068f1f95cc7ba1;hpb=d3caa81bbff5c84e49cdc9c4c1de5d0b583eb45d;p=deb_libcec.git diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 5a2afb1..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; @@ -385,12 +387,14 @@ int CCECCommandHandler::HandleGiveSystemAudioModeStatus(const cec_command &comma int CCECCommandHandler::HandleImageViewOn(const cec_command &command) { CCECBusDevice *device = GetDevice(command.destination); - if (device && (device->GetCurrentStatus() == CEC_DEVICE_STATUS_PRESENT || - device->GetCurrentStatus() == CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC)) + if (device && device->GetCurrentStatus() == CEC_DEVICE_STATUS_PRESENT) { if (device->GetCurrentPowerStatus() == CEC_POWER_STATUS_STANDBY || device->GetCurrentPowerStatus() == CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY) device->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON); + CCECBusDevice* tv = GetDevice(CECDEVICE_TV); + if (tv) + tv->OnImageViewOnSent(false); } return COMMAND_HANDLED; } @@ -571,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; @@ -703,7 +717,7 @@ int CCECCommandHandler::HandleUserControlPressed(const cec_command &command) { // we're not marked as active source, but the tv sends keypresses to us, so assume it forgot to activate us if (!device->IsActiveSource() && command.initiator == CECDEVICE_TV) - device->ActivateSource(); + device->MarkAsActiveSource(); } return COMMAND_HANDLED; @@ -1181,10 +1195,7 @@ bool CCECCommandHandler::ActivateSource(bool bTransmitDelayedCommandsOnly /* = f bool bTvPresent = (tv && tv->GetStatus() == CEC_DEVICE_STATUS_PRESENT); bool bActiveSourceFailed(false); if (bTvPresent) - { - if (tv->GetCurrentPowerStatus() != CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON) - bActiveSourceFailed = !m_busDevice->TransmitImageViewOn(); - } + bActiveSourceFailed = !m_busDevice->TransmitImageViewOn(); else LIB_CEC->AddLog(CEC_LOG_DEBUG, "TV not present, not sending 'image view on'");