From d766a50447b84c55fa02648b838878397d4c366d Mon Sep 17 00:00:00 2001 From: evgeny Date: Fri, 16 Oct 2026 01:34:37 +0200 Subject: [PATCH] Keep Android capture ownership until device release and update busy messages --- .../src/main/java/com/utun/chat/data/MicrophoneCapture.kt | 6 ++++-- .../chatgui-android/app/src/main/res/values-ru/strings.xml | 2 +- tools/chatgui-android/app/src/main/res/values/strings.xml | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/chatgui-android/app/src/main/java/com/utun/chat/data/MicrophoneCapture.kt b/tools/chatgui-android/app/src/main/java/com/utun/chat/data/MicrophoneCapture.kt index 89642c40..474da5a7 100644 --- a/tools/chatgui-android/app/src/main/java/com/utun/chat/data/MicrophoneCapture.kt +++ b/tools/chatgui-android/app/src/main/java/com/utun/chat/data/MicrophoneCapture.kt @@ -19,9 +19,10 @@ class MicrophoneCapture(private val device: Device, private val log: (String, St data class Ptt(val pressed: Boolean) : Event private val consumers = mutableListOf() @Volatile private var reading = true + @Volatile private var disposed = false @Volatile private var failure: Exception? = null private var worker: Thread? = null - val closed: Boolean get() = !reading + val closed: Boolean get() = disposed val inputId: Int? get() = device.inputId val channels: Int get() = device.channels @@ -83,6 +84,7 @@ class MicrophoneCapture(private val device: Device, private val log: (String, St if (!last) return try { device.stop() } catch (e: Exception) { log("WARN", "capture stop failed: ${e.message}") } worker?.join() - try { device.close() } finally { released() } + try { device.close() } catch (e: Exception) { log("ERROR", "capture release failed: ${e.message}") } + finally { disposed = true; released() } } } diff --git a/tools/chatgui-android/app/src/main/res/values-ru/strings.xml b/tools/chatgui-android/app/src/main/res/values-ru/strings.xml index fc5157f8..c8d0f849 100644 --- a/tools/chatgui-android/app/src/main/res/values-ru/strings.xml +++ b/tools/chatgui-android/app/src/main/res/values-ru/strings.xml @@ -36,7 +36,7 @@ Закрыть просмотр Фронтальная камера Задняя камера - Остановите активный звонок, рацию, запись или трансляцию перед новым захватом + Остановите активный звонок, запись или трансляцию перед новым захватом "Для звонков и PTT разрешите доступ к микрофону" "Не удалось запросить доступ к микрофону" "Доступ к микрофону запрещён. Разрешите его в настройках приложения, затем повторите звонок или нажатие PTT." diff --git a/tools/chatgui-android/app/src/main/res/values/strings.xml b/tools/chatgui-android/app/src/main/res/values/strings.xml index 40cdec22..0e6139ba 100644 --- a/tools/chatgui-android/app/src/main/res/values/strings.xml +++ b/tools/chatgui-android/app/src/main/res/values/strings.xml @@ -36,7 +36,7 @@ Close player Front camera Back camera - Stop the active call, radio, recording or stream before starting another capture + Stop the active call, recording or stream before starting another capture "Allow microphone access for calls and PTT" "Could not request microphone access" "Microphone access is denied. Allow it in app settings, then try the call or PTT again."