bool CCECProcessor::AllocateLogicalAddresses(CECClientPtr client) { libcec_configuration &configuration = *client->GetConfiguration(); // mark as unregistered client->SetRegistered(false); // unregister this client from the old addresses CECDEVICEVEC devices; m_busDevices->GetByLogicalAddresses(devices, configuration.logicalAddresses); for (CECDEVICEVEC::const_iterator it = devices.begin(); it != devices.end(); it++) { // remove client entry CLockObject lock(m_mutex); m_clients.erase((*it)->GetLogicalAddress()); } // find logical addresses for this client if (!client->AllocateLogicalAddresses()) { m_libcec->AddLog(CEC_LOG_ERROR, "failed to find a free logical address for the client"); return false; } // refresh the address if (configuration.bAutodetectAddress) client->AutodetectPhysicalAddress(); // register this client on the new addresses devices.clear(); m_busDevices->GetByLogicalAddresses(devices, configuration.logicalAddresses); for (CECDEVICEVEC::const_iterator it = devices.begin(); it != devices.end(); it++) { // set the physical address of the device at this LA if (CLibCEC::IsValidPhysicalAddress(configuration.iPhysicalAddress)) (*it)->SetPhysicalAddress(configuration.iPhysicalAddress); // replace a previous client CLockObject lock(m_mutex); m_clients.erase((*it)->GetLogicalAddress()); m_clients.insert(make_pair((*it)->GetLogicalAddress(), client)); } // set the new ackmask SetLogicalAddresses(GetLogicalAddresses()); // resume outgoing communication m_bStallCommunication = false; return true; }
void CCECDeviceMap::GetChildrenOf(CECDEVICEVEC& devices, CCECBusDevice* device) const { devices.clear(); if (!device) return; uint16_t iPA = device->GetCurrentPhysicalAddress(); for (CECDEVICEMAP::const_iterator it = m_busDevices.begin(); it != m_busDevices.end(); it++) { uint16_t iCurrentPA = it->second->GetCurrentPhysicalAddress(); if (CCECTypeUtils::PhysicalAddressIsIncluded(iPA, iCurrentPA)) devices.push_back(it->second); } }