From 06252394770c25ded00a908438b5741907d9d4f0 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 30 Jan 2025 10:55:08 +0100 Subject: [PATCH] Conference listener onActiveSpeakerParticipantDevice signature has changed --- .../viewmodel/ConferenceViewModel.kt | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/linphone/ui/call/conference/viewmodel/ConferenceViewModel.kt b/app/src/main/java/org/linphone/ui/call/conference/viewmodel/ConferenceViewModel.kt index 0b8ef5ecf..ea4132f2d 100644 --- a/app/src/main/java/org/linphone/ui/call/conference/viewmodel/ConferenceViewModel.kt +++ b/app/src/main/java/org/linphone/ui/call/conference/viewmodel/ConferenceViewModel.kt @@ -134,22 +134,36 @@ class ConferenceViewModel @WorkerThread override fun onActiveSpeakerParticipantDevice( conference: Conference, - participantDevice: ParticipantDevice + participantDevice: ParticipantDevice? ) { activeSpeaker.value?.isActiveSpeaker?.postValue(false) - val found = participantDevices.value.orEmpty().find { - it.device.address.equal(participantDevice.address) - } - if (found != null) { - Log.i("$TAG Newly active speaker participant is [${found.name}]") - found.isActiveSpeaker.postValue(true) - activeSpeaker.postValue(found!!) + if (participantDevice != null) { + val found = participantDevices.value.orEmpty().find { + it.device.address.equal(participantDevice.address) + } + if (found != null) { + Log.i("$TAG Newly active speaker participant is [${found.name}]") + found.isActiveSpeaker.postValue(true) + activeSpeaker.postValue(found!!) + } else { + Log.i("$TAG Failed to find actively speaking participant...") + val model = ConferenceParticipantDeviceModel(participantDevice) + model.isActiveSpeaker.postValue(true) + activeSpeaker.postValue(model) + } } else { - Log.i("$TAG Failed to find actively speaking participant...") - val model = ConferenceParticipantDeviceModel(participantDevice) - model.isActiveSpeaker.postValue(true) - activeSpeaker.postValue(model) + Log.w("$TAG Notified active speaker participant device is null, using first one that's not us") + val firstNotUs = participantDevices.value.orEmpty().find { + it.isMe == false + } + if (firstNotUs != null) { + Log.i("$TAG Newly active speaker participant is [${firstNotUs.name}]") + firstNotUs.isActiveSpeaker.postValue(true) + activeSpeaker.postValue(firstNotUs!!) + } else { + Log.i("$TAG No participant device that's not us found, expected if we're alone") + } } }