Drain queued packets before audio ticks in the connector

After a stall (CPU steal on the host), the missed 20 ms ticks fire in a
burst. With an unbiased select a tick could run before the already
received voice packets were processed, find an empty queue and play Opus
loss concealment, which sounds like a slowed-down tape.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
MoepchiandClaude Opus 5.5 committed 2026-10-16 08:18:20 +00:00
1 parent 983ce1e105
commit 5e7add6dc8
1 file changed
+4
+4
View File
@@ -1148,6 +1148,10 @@ async fn run(args: Args) -> Result<()> {
loop {
let mut events = con.events();
let outcome = tokio::select! {
// After a stall (e.g. CPU steal) the missed audio ticks fire in a burst.
// Polling in order drains the queued packets first, otherwise a tick can
// find an empty queue and play Opus loss concealment instead.
biased;
line = stdin_lines.next_line() => LoopOutcome::StdinLine(line),
ev = events.next() => LoopOutcome::ConEvent(ev),
_ = audio_ticker.tick() => LoopOutcome::AudioTick,