+
+bool CSLCommandHandler::HandleFeatureAbort(const cec_command &command)
+{
+ if (command.parameters.size == 0 && m_processor->GetPrimaryDevice()->GetCurrentPowerStatus() == CEC_POWER_STATUS_ON && !SLInitialised() &&
+ command.initiator == CECDEVICE_TV)
+ {
+ m_processor->GetPrimaryDevice()->TransmitPowerState(command.initiator);
+ m_processor->GetPrimaryDevice()->TransmitVendorID(CECDEVICE_BROADCAST, false);
+ }
+
+ return CCECCommandHandler::HandleFeatureAbort(command);
+}
+
+bool CSLCommandHandler::HandleStandby(const cec_command &command)
+{
+ if (command.initiator == CECDEVICE_TV)
+ {
+ CLockObject lock(m_SLMutex);
+ m_bActiveSourceSent = false;
+ }
+
+ return CCECCommandHandler::HandleStandby(command);
+}
+
+void CSLCommandHandler::ResetSLState(void)
+{
+ LIB_CEC->AddLog(CEC_LOG_NOTICE, "resetting SL initialised state");
+ CLockObject lock(m_SLMutex);
+ m_bSLEnabled = false;
+ m_bActiveSourceSent = false;
+ m_processor->GetPrimaryDevice()->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
+}
+
+void CSLCommandHandler::SetSLInitialised(void)
+{
+ LIB_CEC->AddLog(CEC_LOG_NOTICE, "SL initialised");
+ CLockObject lock(m_SLMutex);
+ m_bSLEnabled = true;
+}
+
+bool CSLCommandHandler::SLInitialised(void)
+{
+ CLockObject lock(m_SLMutex);
+ return m_bSLEnabled;
+}
+
+bool CSLCommandHandler::ActiveSourceSent(void)
+{
+ CLockObject lock(m_SLMutex);
+ return m_bActiveSourceSent;
+}
+
+bool CSLCommandHandler::PowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination)
+{
+ if (iDestination != CECDEVICE_TV)
+ {
+ /* LG devices only allow themselves to be woken up by the TV with a vendor command */
+ cec_command command;
+
+ if (!m_bSLEnabled)
+ TransmitVendorID(CECDEVICE_TV, CEC_VENDOR_LG);
+
+ cec_command::Format(command, CECDEVICE_TV, iDestination, CEC_OPCODE_VENDOR_COMMAND);
+ command.PushBack(SL_COMMAND_POWER_ON);
+ command.PushBack(0);
+ return Transmit(command);
+ }
+
+ return CCECCommandHandler::PowerOn(iInitiator, iDestination);
+}