diff --git a/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/platform/RecAndPlay.android.kt b/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/platform/RecAndPlay.android.kt index e5dda23f0f..d2b3e19164 100644 --- a/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/platform/RecAndPlay.android.kt +++ b/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/platform/RecAndPlay.android.kt @@ -78,15 +78,12 @@ actual class RecorderNative: RecorderInterface { runCatching { recorder?.release() } - // Await coroutine finishes in order to send real duration to it's listener - runBlocking { - progressJob?.cancelAndJoin() - } + progressJob?.cancel() progressJob = null filePath = null recorder = null keepScreenOn(false) - return (realDuration(path) ?: 0).also { recStartedAt = null } + return (progress() ?: 0).also { recStartedAt = null } } private fun progress(): Int? = recStartedAt?.let { (System.currentTimeMillis() - it).toInt() } diff --git a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/RecAndPlay.desktop.kt b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/RecAndPlay.desktop.kt index 59d71a83f1..f5cb714997 100644 --- a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/RecAndPlay.desktop.kt +++ b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/RecAndPlay.desktop.kt @@ -70,11 +70,11 @@ actual class RecorderNative: RecorderInterface { RecorderInterface.stopRecording = null runCatching { player?.controls()?.stop() } runCatching { player?.release() } - runBlocking { progressJob?.cancelAndJoin() } + progressJob?.cancel() progressJob = null filePath = null player = null - return (realDuration(path) ?: 0).also { recStartedAt = null } + return (progress() ?: 0).also { recStartedAt = null } } private fun progress(): Int? = recStartedAt?.let { (System.currentTimeMillis() - it).toInt() }