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() }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user