- CLockObject lock(m_mutex);
- CECDEVICEVEC devices;
- m_busDevices->GetByLogicalAddresses(devices, client->GetConfiguration()->logicalAddresses);
- for (CECDEVICEVEC::const_iterator it = devices.begin(); it != devices.end(); it++)
+ if (!client)
+ return false;
+
+ if (client->IsRegistered())
+ m_libcec->AddLog(CEC_LOG_NOTICE, "unregistering client: %s", client->GetConnectionInfo().c_str());
+
+ // notify the client that it will be unregistered
+ client->OnUnregister();
+
+ {
+ CLockObject lock(m_mutex);
+ // find all devices that match the LA's of this client
+ CECDEVICEVEC devices;
+ m_busDevices->GetByLogicalAddresses(devices, client->GetConfiguration()->logicalAddresses);
+ for (CECDEVICEVEC::const_iterator it = devices.begin(); it != devices.end(); it++)
+ {
+ // find the client
+ map<cec_logical_address, CCECClient *>::iterator entry = m_clients.find((*it)->GetLogicalAddress());
+ // unregister the client
+ if (entry != m_clients.end())
+ m_clients.erase(entry);
+
+ // reset the device status
+ (*it)->ResetDeviceStatus();
+ }
+ }
+
+ // set the new ackmask
+ cec_logical_addresses addresses = GetLogicalAddresses();
+ if (SetLogicalAddresses(addresses))