Let late voice packets teach the jitter buffer

A packet arriving after playback passed its slot was dropped before the
buffer saw it, so the buffer never learned how late packets ran and did
not grow to cover them. The official client puts every packet, however
late; such packets now reach the buffer too, without starting a new
talk burst.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-06 20:17:13 +00:00
co-authored by Claude Opus 5.5
parent 853681fcaa
commit 6cd75eb1cd
2 changed files with 45 additions and 2 deletions
@@ -125,8 +125,12 @@ final class VoiceStream {
markStop(ticks);
return false;
}
// Playback already went past it; the buffer would only drop it.
if (!fresh && ticks - jitter.position() < 0) return false;
// Playback already went past it, but the buffer still learns how late it ran, as in
// the official client; that is what grows the delay to wait for redundant copies.
if (!fresh && ticks - jitter.position() < 0) {
jitter.put(data, ticks, FRAME_TICKS);
return false;
}
channels = channelsFor(codec);
jitter.put(data, ticks, FRAME_TICKS);