X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fimplementations%2FSLCommandHandler.cpp;h=6066d3b9bb21dbf03591d8f7b0a3ef7057ae2bba;hb=42d28d15d07f893b491051970ade1bd56bb596eb;hp=e1632ee5d7e68faff2753fa5640658587570fc50;hpb=004b83822a351e1fb6e982a9183a12a430b0b769;p=deb_libcec.git diff --git a/src/lib/implementations/SLCommandHandler.cpp b/src/lib/implementations/SLCommandHandler.cpp index e1632ee..6066d3b 100644 --- a/src/lib/implementations/SLCommandHandler.cpp +++ b/src/lib/implementations/SLCommandHandler.cpp @@ -62,14 +62,6 @@ CSLCommandHandler::CSLCommandHandler(CCECBusDevice *busDevice) : m_bActiveSourceSent(false) { m_vendorId = CEC_VENDOR_LG; - CCECBusDevice *primary = m_processor->GetPrimaryDevice(); - - /* imitate LG devices */ - if (primary && m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress()) - { - primary->SetVendorId(CEC_VENDOR_LG); - primary->ReplaceHandler(false); - } /* LG devices don't always reply to CEC version requests, so just set it to 1.3a */ m_busDevice->SetCecVersion(CEC_VERSION_1_3A); @@ -87,16 +79,25 @@ bool CSLCommandHandler::InitHandler(void) return true; m_bHandlerInited = true; - if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV) + CCECBusDevice *primary = m_processor->GetPrimaryDevice(); + if (primary && primary->GetLogicalAddress() != CECDEVICE_UNREGISTERED) { - CCECBusDevice *primary = m_processor->GetPrimaryDevice(); + /* imitate LG devices */ + if (m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress()) + { + primary->SetVendorId(CEC_VENDOR_LG); + primary->ReplaceHandler(false); + } - /* start as 'in transition standby->on' */ - primary->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON); - primary->TransmitPowerState(CECDEVICE_TV); + if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV) + { + /* start as 'in transition standby->on' */ + primary->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON); + primary->TransmitPowerState(CECDEVICE_TV); - /* send the vendor id */ - primary->TransmitVendorID(CECDEVICE_BROADCAST); + /* send the vendor id */ + primary->TransmitVendorID(CECDEVICE_BROADCAST); + } } return true; @@ -133,9 +134,17 @@ bool CSLCommandHandler::HandleDeviceVendorId(const cec_command &command) if (!SLInitialised() && command.initiator == CECDEVICE_TV) { - cec_command response; - cec_command::Format(response, command.destination, command.initiator, CEC_OPCODE_FEATURE_ABORT); - return Transmit(response); + CCECBusDevice *destination = m_processor->GetDevice(command.destination); + if (destination && (destination->GetLogicalAddress() == CECDEVICE_BROADCAST || destination->IsHandledByLibCEC())) + { + cec_logical_address initiator = destination->GetLogicalAddress(); + if (initiator == CECDEVICE_BROADCAST) + initiator = m_processor->GetPrimaryDevice()->GetLogicalAddress(); + + cec_command response; + cec_command::Format(response, initiator, command.initiator, CEC_OPCODE_FEATURE_ABORT); + return Transmit(response); + } } return true; } @@ -245,7 +254,7 @@ void CSLCommandHandler::TransmitVendorCommandSetDeviceMode(const cec_logical_add bool CSLCommandHandler::HandleGiveDeckStatus(const cec_command &command) { - if (m_processor->IsRunning() && m_processor->IsHandledByLibCEC(command.destination)) + if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device && (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE)) @@ -275,7 +284,7 @@ bool CSLCommandHandler::HandleGiveDeckStatus(const cec_command &command) bool CSLCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command) { bool bReturn(false); - if (m_processor->IsRunning() && m_processor->IsHandledByLibCEC(command.destination) && command.initiator == CECDEVICE_TV) + if (m_processor->CECInitialised() && m_processor->IsHandledByLibCEC(command.destination) && command.initiator == CECDEVICE_TV) { CCECBusDevice *device = GetDevice(command.destination); if (device && device->GetCurrentPowerStatus() != CEC_POWER_STATUS_ON) @@ -317,7 +326,7 @@ bool CSLCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command) bool CSLCommandHandler::HandleRequestActiveSource(const cec_command &command) { - if (m_processor->IsRunning()) + if (m_processor->CECInitialised()) { if (ActiveSourceSent()) LIB_CEC->AddLog(CEC_LOG_DEBUG, ">> %i requests active source, ignored", (uint8_t) command.initiator);