void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = CEC_INVALID_PHYSICAL_ADDRESS */) { if (iNewAddress != CEC_INVALID_PHYSICAL_ADDRESS) SetPowerStatus(CEC_POWER_STATUS_ON); CLockObject lock(m_mutex); if (iNewAddress != m_iStreamPath) { LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X): stream path changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, iOldAddress == 0 ? m_iStreamPath : iOldAddress, iNewAddress); m_iStreamPath = iNewAddress; } if (!LIB_CEC->IsValidPhysicalAddress(iNewAddress)) return; CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress); if (device) { // if a device is found with the new physical address, mark it as active, which will automatically mark all other devices as inactive device->MarkAsActiveSource(); // respond with an active source message if this device is handled by libCEC if (device->IsHandledByLibCEC()) device->TransmitActiveSource(true); } else { // try to find the device with the old address, and mark it as inactive when found device = m_processor->GetDeviceByPhysicalAddress(iOldAddress); if (device) device->MarkAsInactiveSource(); } }
bool CCECClient::SendSetActiveSource(const cec_device_type type /* = CEC_DEVICE_TYPE_RESERVED */) { // get the devices that are controlled by us CECDEVICEVEC devices; m_processor->GetDevices()->GetByLogicalAddresses(devices, m_configuration.logicalAddresses); // filter out the device that matches the given type if (type != CEC_DEVICE_TYPE_RESERVED) CCECDeviceMap::FilterType(type, devices); // no devices left, re-fetch the list of devices that are controlled by us if (devices.empty()) m_processor->GetDevices()->GetByLogicalAddresses(devices, m_configuration.logicalAddresses); if (!devices.empty()) { // get the first device from the list CCECBusDevice *device = *devices.begin(); // and activate it if (!m_processor->CECInitialised()) device->MarkAsActiveSource(); else if (device->HasValidPhysicalAddress()) return device->ActivateSource(); } return false; }
void CCECBusDevice::SetActiveRoute(uint16_t iRoute) { SetPowerStatus(CEC_POWER_STATUS_ON); CCECDeviceMap* map = m_processor->GetDevices(); if (!map) return; CCECBusDevice* newRoute = m_processor->GetDeviceByPhysicalAddress(iRoute, true); if (newRoute) { // we were made the active source, send notification if (newRoute->IsHandledByLibCEC()) newRoute->ActivateSource(); // another device was made active else newRoute->MarkAsActiveSource(); } }
int 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 *device = m_processor->GetDeviceByPhysicalAddress(iAddress); if (device) device->MarkAsActiveSource(); { CLockObject lock(m_SLMutex); m_bActiveSourceSent = false; } return COMMAND_HANDLED; } return CEC_ABORT_REASON_INVALID_OPERAND; }
void CSLCommandHandler::HandleVendorCommandPowerOn(const cec_command &command) { if (command.initiator != CECDEVICE_TV) return; CCECBusDevice *device = m_processor->GetPrimaryDevice(); if (device) { SetSLInitialised(); device->MarkAsActiveSource(); device->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON); device->TransmitPowerState(command.initiator, true); CEvent::Sleep(2000); device->SetPowerStatus(CEC_POWER_STATUS_ON); device->TransmitPowerState(command.initiator, false); device->TransmitPhysicalAddress(false); { CLockObject lock(m_SLMutex); m_bActiveSourceSent = false; } } }