feat: add single-call action protocol and Android stage interfaces
This commit is contained in:
@@ -31,7 +31,12 @@ fun main() {
|
||||
val errors = CopyOnWriteArrayList<Exception>()
|
||||
capture.start(onFrame = frames::add, onError = errors::add)
|
||||
check(AudioRecord.partialReady.await(2, TimeUnit.SECONDS))
|
||||
capture.stop()
|
||||
val confirmed = CountDownLatch(1)
|
||||
capture.stopAndConfirm { stopped ->
|
||||
check(stopped && AudioRecord.activeDevices.get()==0)
|
||||
confirmed.countDown()
|
||||
}
|
||||
check(confirmed.await(2, TimeUnit.SECONDS))
|
||||
check(AudioRecord.released.await(2, TimeUnit.SECONDS))
|
||||
check(errors.isEmpty())
|
||||
check(frames.size == expectedCount) // 100B unfinished tail must not be sent
|
||||
|
||||
@@ -19,9 +19,9 @@ class AudioRecord(source: Int, rate: Int, channel: Int, encoding: Int, buffer: I
|
||||
init { if (activeDevices.incrementAndGet() > 1) overlaps.incrementAndGet() }
|
||||
private val mode = scenario
|
||||
val state = if (mode == "init") 0 else STATE_INITIALIZED
|
||||
val recordingState = RECORDSTATE_RECORDING
|
||||
var recordingState = 1
|
||||
val audioSessionId = 1
|
||||
fun startRecording() { if (mode == "start") throw SecurityException("synthetic mic revocation") }
|
||||
fun startRecording() { if (mode == "start") throw SecurityException("synthetic mic revocation"); recordingState = RECORDSTATE_RECORDING }
|
||||
private val stopped = java.util.concurrent.CountDownLatch(1)
|
||||
private val ready = partialReady
|
||||
private val done = released
|
||||
@@ -45,6 +45,6 @@ class AudioRecord(source: Int, rate: Int, channel: Int, encoding: Int, buffer: I
|
||||
streamOffset += count
|
||||
return count
|
||||
}
|
||||
fun stop() { stopped.countDown() }
|
||||
fun stop() { recordingState = 1; stopped.countDown() }
|
||||
fun release() { Thread.sleep(20); activeDevices.decrementAndGet(); done.countDown() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user