Share media playback devices and await cleanup before calls
This commit is contained in:
1 parent
a893f6b4f2
commit
bebc579180
3 files changed
+21
-3
No files matched your search
@@ -6,6 +6,7 @@ import java.util.ArrayDeque
|
||||
|
||||
class StreamAudioOutputTest {
|
||||
private class Device(override val threshold: Int = 1) : StreamAudioOutput.Sink {
|
||||
override var routeChanging = false
|
||||
override val bufferFrames = maxOf(960, threshold)
|
||||
override var head = 0L
|
||||
override val description: String get() = "fake threshold=$threshold"
|
||||
@@ -84,6 +85,19 @@ class StreamAudioOutputTest {
|
||||
assertTrue(p.output.drained)
|
||||
}
|
||||
|
||||
@Test fun routeSwitchPreservesPlayerAndClockUntilOutputResumes() {
|
||||
val p = Player(); p.input.add(ShortArray(960) { 7 }); p.step(0)
|
||||
p.device.routeChanging = true
|
||||
var videoSteps = 0
|
||||
for (ms in 5L..30000L step 5) { p.step(ms); videoSteps++ }
|
||||
assertEquals(6000, videoSteps)
|
||||
assertFalse(p.device.closed); assertEquals(0L, p.output.played)
|
||||
assertEquals(List(960) { 7.toShort() }, p.device.samples)
|
||||
p.device.routeChanging = false
|
||||
p.device.head = 480; p.step(30005)
|
||||
assertTrue(p.output.drained)
|
||||
}
|
||||
|
||||
@Test fun intentionalPausePreservesPartialPcmAndSuspendsWatchdog() {
|
||||
val p = Player(); val pcm = ShortArray(960) { it.toShort() }; p.input.add(pcm); p.device.limit = 120
|
||||
p.step(0); p.step(5, true); p.step(10000, true)
|
||||
|
||||
Reference in new issue
Block a user