Browse Source

Keep Android capture ownership until device release and update busy messages

master
evgeny 3 days ago
parent
commit
d766a50447
  1. 6
      tools/chatgui-android/app/src/main/java/com/utun/chat/data/MicrophoneCapture.kt
  2. 2
      tools/chatgui-android/app/src/main/res/values-ru/strings.xml
  3. 2
      tools/chatgui-android/app/src/main/res/values/strings.xml

6
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<Subscription>()
@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() }
}
}

2
tools/chatgui-android/app/src/main/res/values-ru/strings.xml

@ -36,7 +36,7 @@
<string name="stream_close_view">Закрыть просмотр</string>
<string name="stream_front_camera">Фронтальная камера</string>
<string name="stream_back_camera">Задняя камера</string>
<string name="stream_resources_busy">Остановите активный звонок, рацию, запись или трансляцию перед новым захватом</string>
<string name="stream_resources_busy">Остановите активный звонок, запись или трансляцию перед новым захватом</string>
<string name="microphone_permission_calls">"Для звонков и PTT разрешите доступ к микрофону"</string>
<string name="microphone_request_failed">"Не удалось запросить доступ к микрофону"</string>
<string name="microphone_permission_settings">"Доступ к микрофону запрещён. Разрешите его в настройках приложения, затем повторите звонок или нажатие PTT."</string>

2
tools/chatgui-android/app/src/main/res/values/strings.xml

@ -36,7 +36,7 @@
<string name="stream_close_view">Close player</string>
<string name="stream_front_camera">Front camera</string>
<string name="stream_back_camera">Back camera</string>
<string name="stream_resources_busy">Stop the active call, radio, recording or stream before starting another capture</string>
<string name="stream_resources_busy">Stop the active call, recording or stream before starting another capture</string>
<string name="microphone_permission_calls">"Allow microphone access for calls and PTT"</string>
<string name="microphone_request_failed">"Could not request microphone access"</string>
<string name="microphone_permission_settings">"Microphone access is denied. Allow it in app settings, then try the call or PTT again."</string>

Loading…
Cancel
Save