Keep Android capture ownership until device release and update busy messages
This commit is contained in:
1 parent
829e4d41fa
commit
d766a50447
3 files changed
+6
-4
No files matched your search
@@ -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() }
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user