From 5e7add6dc81eebca12371fbc7a0fe6c13efd274c Mon Sep 17 00:00:00 2001 From: Moepchi Date: Fri, 16 Oct 2026 08:18:20 +0000 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU --- connector/src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/connector/src/main.rs b/connector/src/main.rs index ee990bf..f7e7d38 100644 --- a/connector/src/main.rs +++ b/connector/src/main.rs @@ -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,