rpi: handle VC_CEC_LOGICAL_ADDR_LOST in the rpi communication class itself, don't...
[deb_libcec.git] / src / lib / CECProcessor.cpp
index b4445f42f921881edb6361d57f45a7498c62136f..1eb272aa7197ba51db4c851b3cad825a0b706f36 100644 (file)
@@ -887,10 +887,18 @@ void CCECProcessor::SwitchMonitoring(bool bSwitchTo)
     UnregisterClients();
 }
 
-void CCECProcessor::HandleLogicalAddressLost(cec_logical_address address)
+void CCECProcessor::HandleLogicalAddressLost(cec_logical_address oldAddress, cec_logical_address newAddress)
 {
-  m_libcec->AddLog(CEC_LOG_NOTICE, "logical address %x was taken by another device, re-registering the client");
-  CCECClient* client = GetClient(address);
+  m_libcec->AddLog(CEC_LOG_NOTICE, "logical address %x was taken by another device, changed to %x", oldAddress, newAddress);
+  CCECClient* client = GetClient(oldAddress);
   if (client)
-    RegisterClient(client);
+  {
+    if (newAddress == CECDEVICE_UNKNOWN)
+      UnregisterClient(client);
+    else
+    {
+      client->m_configuration.logicalAddresses.Unset(oldAddress);
+      client->m_configuration.logicalAddresses.Set(newAddress);
+    }
+  }
 }