From b993bd9aef2dbe3a5677c5600521b05e11a512a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Tue, 31 May 2022 15:53:05 +0200 Subject: [PATCH] Fix crash when asking for Mic permissions, stopRecord is called with no codec --- .../java/im/vector/app/features/voice/VoiceRecorderL.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/voice/VoiceRecorderL.kt b/vector/src/main/java/im/vector/app/features/voice/VoiceRecorderL.kt index 69de911d60..8816ffafbd 100644 --- a/vector/src/main/java/im/vector/app/features/voice/VoiceRecorderL.kt +++ b/vector/src/main/java/im/vector/app/features/voice/VoiceRecorderL.kt @@ -118,12 +118,13 @@ class VoiceRecorderL( } override fun stopRecord() { + val recorder = this.audioRecorder ?: return recordingJob?.cancel() - if (audioRecorder?.state == AudioRecord.STATE_INITIALIZED) { - audioRecorder?.stop() + if (recorder.state == AudioRecord.STATE_INITIALIZED) { + recorder.stop() } - audioRecorder?.release() + recorder.release() audioRecorder = null noiseSuppressor?.release()