Prevent race condition crash with VuMeter when call is ending

This commit is contained in:
Sylvain Berfini 2025-06-19 12:02:13 +02:00
parent 42fbbc51fd
commit fd3f746e3d

View file

@ -1260,8 +1260,12 @@ class CurrentCallViewModel
if (corePreferences.showMicrophoneAndSpeakerVuMeters) {
volumeVuMeterTickerFlow().onEach {
coreContext.postOnCoreThread {
microphoneRecordingVolume.postValue(computeVuMeterValue(currentCall.recordVolume))
playbackVolume.postValue(computeVuMeterValue(currentCall.playVolume))
val call = currentCall
val state = call.state
if (state == Call.State.End || state == Call.State.Released) return@postOnCoreThread
microphoneRecordingVolume.postValue(computeVuMeterValue(call.recordVolume))
playbackVolume.postValue(computeVuMeterValue(call.playVolume))
}
}.launchIn(viewModelScope)
}