From 7860f2dbb406f3497075cd097b9b5ed6648601a7 Mon Sep 17 00:00:00 2001 From: Julius Linus Date: Mon, 20 Nov 2023 09:14:25 -0600 Subject: [PATCH] Found the bug, partial fix Signed-off-by: rapterjet2004 --- .../java/com/nextcloud/talk/chat/ChatActivity.kt | 12 ++++++------ .../main/java/com/nextcloud/talk/utils/AudioUtils.kt | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index 32223d561c6..996dfcc20be 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -2183,16 +2183,16 @@ class ChatActivity : recorder?.apply { try { Log.d(TAG, "recording stopped with $voiceRecordDuration") - if (voiceRecordDuration > MINIMUM_VOICE_RECORD_TO_STOP) { + try { stop() + isVoiceRecordingInProgress = false + Log.d(TAG, "stopped recorder. isVoiceRecordingInProgress = false") + } catch (e: java.lang.RuntimeException) { + Log.e(TAG, "error while stopping recorder!" + e) } release() - isVoiceRecordingInProgress = false - Log.d(TAG, "stopped recorder. isVoiceRecordingInProgress = false") } catch (e: java.lang.IllegalStateException) { - error("error while stopping recorder!" + e) - } catch (e: java.lang.RuntimeException) { - error("error while stopping recorder!" + e) + Log.e(TAG, "error while stopping recorder!" + e) } VibrationUtils.vibrateShort(context) diff --git a/app/src/main/java/com/nextcloud/talk/utils/AudioUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/AudioUtils.kt index 8151ad39e7e..343b71fb622 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/AudioUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/AudioUtils.kt @@ -78,7 +78,7 @@ object AudioUtils : DefaultLifecycleObserver { val path = file.path val mediaExtractor = MediaExtractor() mediaExtractor.setDataSource(path) - + // TODO this function assumes that the file is not null. Fix it. // Basically just boilerplate to set up meta data for the audio file val mediaFormat = mediaExtractor.getTrackFormat(0) // Frame rate is required for encoders, optional for decoders. So we set it to null here.