Fix crash when asking for Mic permissions, stopRecord is called with no codec

This commit is contained in:
Jorge Martín 2022-05-31 15:53:05 +02:00
parent fa2d9e90ed
commit b993bd9aef

View File

@ -118,12 +118,13 @@ class VoiceRecorderL(
} }
override fun stopRecord() { override fun stopRecord() {
val recorder = this.audioRecorder ?: return
recordingJob?.cancel() recordingJob?.cancel()
if (audioRecorder?.state == AudioRecord.STATE_INITIALIZED) { if (recorder.state == AudioRecord.STATE_INITIALIZED) {
audioRecorder?.stop() recorder.stop()
} }
audioRecorder?.release() recorder.release()
audioRecorder = null audioRecorder = null
noiseSuppressor?.release() noiseSuppressor?.release()