Match stream audio queue to device buffer and document playback ownership
This commit is contained in:
1 parent
0fdc6e435b
commit
ded0d401c7
3 files changed
+24
-2
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 val bufferFrames = maxOf(960, threshold)
|
||||
override var head = 0L
|
||||
override val description: String get() = "fake threshold=$threshold"
|
||||
val samples = ArrayList<Short>()
|
||||
@@ -59,6 +60,14 @@ class StreamAudioOutputTest {
|
||||
assertEquals(100L, p.output.written); assertEquals(0L, p.output.played)
|
||||
}
|
||||
|
||||
@Test fun feedsHardwareBufferEvenWhenStartThresholdIsSmall() {
|
||||
val p = Player(); repeat(4) { p.input.add(ShortArray(960)) }
|
||||
p.step(0); p.step(5); p.step(10)
|
||||
assertEquals(960L, p.output.written); assertEquals(2, p.pulls)
|
||||
p.device.head = 480; p.step(15)
|
||||
assertEquals(1440L, p.output.written); assertEquals(3, p.pulls)
|
||||
}
|
||||
|
||||
@Test fun clockDoesNotAdvanceWithWallTimeAndStalledDeviceFails() {
|
||||
val p = Player(); p.input.add(ShortArray(960)); p.step(0); p.step(1999)
|
||||
assertEquals(0L, p.output.played)
|
||||
|
||||
Reference in new issue
Block a user