+ if (m_bHandlerInited)
+ return true;
+ m_bHandlerInited = true;
+
+ if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
+ {
+ CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+
+ /* 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);
+ }
+
+ return true;
+}
+
+bool CSLCommandHandler::ActivateSource(void)
+{
+ if (!m_processor->GetPrimaryDevice()->IsActiveSource())
+ {
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "not activating the source because we're not marked as active");
+ return true;
+ }
+
+ {
+ CLockObject lock(m_SLMutex);
+ m_bActiveSourceSent = true;
+ }
+
+ CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+ primary->SetActiveSource();
+ primary->SetPowerStatus(CEC_POWER_STATUS_ON);
+ primary->TransmitPowerState(CECDEVICE_TV);
+ primary->TransmitImageViewOn();
+ primary->TransmitActiveSource();
+ return true;
+}
+
+bool CSLCommandHandler::HandleActiveSource(const cec_command &command)
+{
+ if (command.parameters.size == 2)
+ {
+ uint16_t iAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
+ CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+ bool bSendPowerOffState(iAddress != primary->GetPhysicalAddress(false) && primary->IsActiveSource());
+
+ m_processor->SetActiveSource(iAddress);
+ if (bSendPowerOffState)
+ {
+ {
+ CLockObject lock(m_SLMutex);
+ m_bActiveSourceSent = false;
+ }
+ primary->TransmitPowerState(CECDEVICE_TV);
+ }
+ }
+
+ return true;
+
+}
+
+bool CSLCommandHandler::HandleDeviceVendorId(const cec_command &command)
+{
+ SetVendorId(command);
+
+ if (!SLInitialised() && command.initiator == CECDEVICE_TV)