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; }
bool CCECProcessor::ActivateSource(uint16_t iStreamPath) { bool bReturn(false); // find the device with the given PA CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamPath); // and make it the active source when found if (device) bReturn = device->ActivateSource(); else m_libcec->AddLog(CEC_LOG_DEBUG, "device with PA '%04x' not found", iStreamPath); return bReturn; }
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 && newRoute->IsHandledByLibCEC() && !newRoute->IsActiveSource()) { // we were made the active source, send notification newRoute->ActivateSource(); } }
bool CCECClient::SetDevicePhysicalAddress(const uint16_t iPhysicalAddress) { if (!CLibCEC::IsValidPhysicalAddress(iPhysicalAddress)) { LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - not setting invalid physical address %04x", __FUNCTION__, iPhysicalAddress); return false; } // reconfigure all devices cec_logical_address reactivateSource(CECDEVICE_UNKNOWN); CECDEVICEVEC devices; m_processor->GetDevices()->GetByLogicalAddresses(devices, m_configuration.logicalAddresses); for (CECDEVICEVEC::iterator it = devices.begin(); it != devices.end(); it++) { // if this device was the active source, reactivate it afterwards if ((*it)->IsActiveSource()) reactivateSource = (*it)->GetLogicalAddress(); // mark the device as inactive source if (IsInitialised()) (*it)->MarkAsInactiveSource(); // set the new physical address (*it)->SetPhysicalAddress(iPhysicalAddress); // and transmit it if (IsInitialised()) (*it)->TransmitPhysicalAddress(false); } // reactivate the previous active source if (reactivateSource != CECDEVICE_UNKNOWN && m_processor->CECInitialised() && IsInitialised()) { CCECBusDevice *device = m_processor->GetDevice(reactivateSource); if (device) device->ActivateSource(); } // persist the new configuration PersistConfiguration(m_configuration); return true; }
bool CCECClient::SetConfiguration(const libcec_configuration &configuration) { bool bIsRunning(m_processor && m_processor->CECInitialised()); CCECBusDevice *primary = bIsRunning ? GetPrimaryDevice() : NULL; uint16_t iPA = primary ? primary->GetCurrentPhysicalAddress() : CEC_INVALID_PHYSICAL_ADDRESS; // update the callbacks if (configuration.callbacks) EnableCallbacks(configuration.callbackParam, configuration.callbacks); // update the client version SetClientVersion((cec_client_version)configuration.clientVersion); // update the OSD name CStdString strOSDName(configuration.strDeviceName); SetOSDName(strOSDName); // update the TV vendor override SetTVVendorOverride((cec_vendor_id)configuration.tvVendor); // just copy these { CLockObject lock(m_mutex); m_configuration.bUseTVMenuLanguage = configuration.bUseTVMenuLanguage; m_configuration.bActivateSource = configuration.bActivateSource; m_configuration.bGetSettingsFromROM = configuration.bGetSettingsFromROM; m_configuration.wakeDevices = configuration.wakeDevices; m_configuration.powerOffDevices = configuration.powerOffDevices; m_configuration.bPowerOffScreensaver = configuration.bPowerOffScreensaver; m_configuration.bPowerOffOnStandby = configuration.bPowerOffOnStandby; // client version 1.5.1 if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_5_1) m_configuration.bSendInactiveSource = configuration.bSendInactiveSource; // client version 1.6.0 if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_6_0) { m_configuration.bPowerOffDevicesOnStandby = configuration.bPowerOffDevicesOnStandby; m_configuration.bShutdownOnStandby = configuration.bShutdownOnStandby; } // client version 1.6.2 if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_6_2) { memcpy(m_configuration.strDeviceLanguage, configuration.strDeviceLanguage, 3); } // client version 1.6.3 if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_6_3) { m_configuration.bMonitorOnly = configuration.bMonitorOnly; } // client version 1.8.0 if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_8_0) m_configuration.cecVersion = configuration.cecVersion; // client version 1.8.2 if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_8_2) m_configuration.adapterType = configuration.adapterType; // ensure that there is at least 1 device type set if (m_configuration.deviceTypes.IsEmpty()) m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE); } bool bNeedReinit(false); // device types if (SetDeviceTypes(configuration.deviceTypes)) { // the device type changed. just copy the rest, and re-register { CLockObject lock(m_mutex); m_configuration.iPhysicalAddress = configuration.iPhysicalAddress; m_configuration.baseDevice = configuration.baseDevice; m_configuration.iHDMIPort = configuration.iHDMIPort; bNeedReinit = true; } } else { // set the physical address SetPhysicalAddress(configuration); } // persist the new configuration PersistConfiguration(m_configuration); if (!primary) primary = GetPrimaryDevice(); if (bNeedReinit || !primary || primary->GetCurrentPhysicalAddress() != iPA) { // PA or device type changed m_processor->RegisterClient(this); } else if (primary && configuration.bActivateSource == 1 && bIsRunning && !primary->IsActiveSource()) { // activate the source if we're not already the active source primary->ActivateSource(); } return true; }