+
+ // set the new ackmask
+ cec_logical_addresses addresses = GetLogicalAddresses();
+ if (SetLogicalAddresses(addresses))
+ {
+ // no more clients left, disable controlled mode
+ if (addresses.IsEmpty() && !m_bMonitor)
+ m_communication->SetControlledMode(false);
+
+ return true;
+ }
+
+ return false;
+}
+
+void CCECProcessor::UnregisterClients(void)
+{
+ m_libcec->AddLog(CEC_LOG_NOTICE, "unregistering all CEC clients");
+
+ vector<CCECClient *> clients = m_libcec->GetClients();
+ for (vector<CCECClient *>::iterator client = clients.begin(); client != clients.end(); client++)
+ UnregisterClient(*client);
+
+ CLockObject lock(m_mutex);
+ m_clients.clear();
+}
+
+CCECClient *CCECProcessor::GetClient(const cec_logical_address address)
+{
+ CLockObject lock(m_mutex);
+ map<cec_logical_address, CCECClient *>::const_iterator client = m_clients.find(address);
+ if (client != m_clients.end())
+ return client->second;
+ return NULL;
+}
+
+CCECClient *CCECProcessor::GetPrimaryClient(void)
+{
+ CLockObject lock(m_mutex);
+ map<cec_logical_address, CCECClient *>::const_iterator client = m_clients.begin();
+ if (client != m_clients.end())
+ return client->second;
+ return NULL;
+}
+
+CCECBusDevice *CCECProcessor::GetPrimaryDevice(void)
+{
+ return m_busDevices->At(GetLogicalAddress());
+}
+
+cec_logical_address CCECProcessor::GetLogicalAddress(void)
+{
+ cec_logical_addresses addresses = GetLogicalAddresses();
+ return addresses.primary;
+}
+
+cec_logical_addresses CCECProcessor::GetLogicalAddresses(void)
+{
+ CLockObject lock(m_mutex);
+ cec_logical_addresses addresses;
+ addresses.Clear();
+ for (map<cec_logical_address, CCECClient *>::const_iterator client = m_clients.begin(); client != m_clients.end(); client++)
+ addresses.Set(client->first);
+
+ return addresses;
+}
+
+bool CCECProcessor::IsHandledByLibCEC(const cec_logical_address address) const
+{
+ CCECBusDevice *device = GetDevice(address);
+ return device && device->IsHandledByLibCEC();
+}
+
+bool CCECProcessor::IsRunningLatestFirmware(void)
+{
+ return m_communication && m_communication->IsOpen() ?
+ m_communication->IsRunningLatestFirmware() :
+ true;
+}
+
+void CCECProcessor::SwitchMonitoring(bool bSwitchTo)
+{