Skip to content

fix(linux-audio): cap the pw-cat backlog so overflow cannot lock audio into concealment - #1454

Open
etgbrown wants to merge 1 commit into
OpenCloudGaming:devfrom
etgbrown:linux-audio-backlog-cap
Open

etgbrown wants to merge 1 commit into
OpenCloudGaming:devfrom
etgbrown:linux-audio-backlog-cap

Conversation

@etgbrown

Copy link
Copy Markdown

Problem

On Linux the pw-cat stdin pipe filled to its 160 ms limit and stayed there. A sample taken while audio still sounded fine showed a median of 154 ms. pw-cat drains the pipe only in real time, so every write blocked.

A burst of packets then overflowed the 12-packet audio queue, and conceal_before refilled each dropped packet with Opus concealment of the same length. A drop therefore never shortened the backlog, and the worker stayed behind.

In one session this lasted 14 minutes. For that whole time, 140–170 of about 200 audio packets per second were dropped and replaced by concealment. The audio sounded robotic while video stayed fine.

Fix

Once more than twice the 40 ms lead is queued, drop new audio until the pipe is back at the lead.

  • Writes no longer block on a full pipe, so the worker keeps up and the trap cannot form.
  • A pipe that stays above the lead for the 250 ms write timeout is still reported as a stalled pw-cat (DeviceLost), as before.

Evidence

This is one session before and one after, on the same machine (PipeWire 1.6).

Before After
Audio queued in the pw-cat pipe median 154 ms (max 160) median 27 ms, p95 50 ms, max 82 ms
Audio queue overflows thousands per minute during the episode none in the session

Tests

  • New test: pipewire_backlog_is_dropped_back_down_to_the_lead.
  • cargo test --workspace with linux-ffmpeg-bundled,linux-vaapi: 1534 passed, 0 failed, 27 ignored.

🤖 Generated with Claude Code

…o into concealment

pw-cat drains its stdin pipe only in real time, so anything queued past the
40 ms lead stays as permanent latency. In a live session the pipe sat at its
160 ms limit even while audio sounded fine, so every write blocked. A burst
then overflowed the 12-packet audio queue, and each dropped packet came back
as Opus concealment of equal length. The backlog never shrank, and for
14 minutes 140-170 of every 200 packets per second were replaced by
concealment (robotic audio).

Drop new audio once more than twice the lead is queued, until the pipe is
back at the lead. Writes no longer block on a full pipe, so the worker keeps
up and the trap cannot form. A pipe that stays above the lead for the full
write timeout is still reported as a stalled pw-cat.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 146a0dbf-defe-4927-aee4-cbc6cdb38215

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant