Browse Source

Preserve observed decoder lead while its pipeline drains

master
evgeny 4 days ago
parent
commit
c02222610b
  1. 3
      tools/chatgui-android/app/src/main/java/com/utun/chat/data/StreamDecodePump.kt
  2. 8
      tools/chatgui-android/app/src/test/java/com/utun/chat/data/StreamDecodePumpTest.kt

3
tools/chatgui-android/app/src/main/java/com/utun/chat/data/StreamDecodePump.kt

@ -70,7 +70,8 @@ internal class StreamDecodePump<F : StreamDecodePump.Frame>(
output = next
if (!next.empty) {
if (firstOutputPts == null) firstOutputPts = next.pts
outputCount++; decoderLeadUs = (lastInputPts - next.pts).coerceAtLeast(0)
// Опустевший хвост не уменьшает измеренный защитный запас текущего decoder.
outputCount++; decoderLeadUs = maxOf(decoderLeadUs, lastInputPts - next.pts)
while (submitted.isNotEmpty() && submitted.first <= next.pts) submitted.removeFirst()
}
waitingSince = now

8
tools/chatgui-android/app/src/test/java/com/utun/chat/data/StreamDecodePumpTest.kt

@ -87,4 +87,12 @@ class StreamDecodePumpTest {
codec.pump.step(40000, 160000); assertEquals(2, codec.released)
codec.pump.step(80000, 200000); assertEquals(3, codec.released)
}
@Test fun drainingDoesNotEraseTheObservedDecoderGuard() {
val codec = Codec(4)
repeat(4) { i -> codec.pump.offer(Frame(i * 40000L), i * 40000L); codec.pump.step(0, i * 40000L) }
assertEquals(120000L, codec.pump.decoderLeadUs); codec.finishing = true
codec.pump.step(120000, 200000)
assertEquals(4L, codec.pump.outputCount); assertEquals(120000L, codec.pump.decoderLeadUs)
}
}

Loading…
Cancel
Save