Skip to content

Cli audio playback against jittery sinks and flaky streams#85

Closed
LilDojd wants to merge 10 commits into
mpiorowski:mainfrom
LilDojd:fix/cli-buffering
Closed

Cli audio playback against jittery sinks and flaky streams#85
LilDojd wants to merge 10 commits into
mpiorowski:mainfrom
LilDojd:fix/cli-buffering

Conversation

@LilDojd
Copy link
Copy Markdown
Contributor

@LilDojd LilDojd commented Apr 22, 2026

Addresses #68. Root cause on the reporter's setup is WSLg's PulseAudio-over-RDP bridge (microsoft/wslg#908, #1429) upstream. We can't fix that, but we can stop the CLI from making it worse. The audio pipeline also had a few latent correctness/perf bugs worth clearing out while in here (cross-referenced with pdeljanov/Symphonia#260).

  • Lock-free SPSC queue. Replaced Arc<Mutex<VecDeque<f32>>> with ringbuf::HeapRb.

  • Reuse SampleBuffer instead of frequently allocating

  • Fixed cpal output buffer on Linux: BufferSize::Fixed(2048)

  • Ran make check

LilDojd added 8 commits April 22, 2026 16:00
Signed-off-by: LilDojd <yawner@pm.me>
Change-Id: I12ccb6472c6f339f647a2cfb88a591f16a6a6964
Signed-off-by: LilDojd <yawner@pm.me>
Change-Id: I7d07ef1a96beb0a83680f3cf882562fd6a6a6964
Signed-off-by: LilDojd <yawner@pm.me>
Change-Id: I44fe3bc8f324287fb9be1c3e702b3aa56a6a6964
Signed-off-by: LilDojd <yawner@pm.me>
Change-Id: I7cf0d2f5d8e4c86d472e37227223a5346a6a6964
Signed-off-by: LilDojd <yawner@pm.me>
Change-Id: Iac0a8c00cb8cbf9dddc3588290697a8e6a6a6964
Signed-off-by: LilDojd <yawner@pm.me>
Change-Id: I728c87651d23dc46dbfff58dce2509fd6a6a6964
Signed-off-by: LilDojd <yawner@pm.me>
Change-Id: I49c115c247f2fcc8f2bd8f52bd4f9f096a6a6964
Signed-off-by: LilDojd <yawner@pm.me>
Change-Id: Ic46c756bb5482d968a5ffdfd84cc27e86a6a6964
@LilDojd LilDojd requested a review from mpiorowski as a code owner April 22, 2026 12:21
Copy link
Copy Markdown
Owner

@mpiorowski mpiorowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I havent dive deep into review, but AI throw me a fast high:

High: late-cli/src/audio/decoder_thread.rs:89 now feeds the ring buffer with push_slice(pending), which can split the interleaved sample stream at any sample boundary. The consumer in late-cli/src/audio/output.rs:173 assumes it can pop a whole source_channels frame; when it gets only part of one, it drops the partial frame and outputs silence. On stereo this can turn L,R,L,R into L dropped, then R treated as the next frame’s left channel, so under pressure you get sample loss and channel skew. The old mutex queue avoided this by enqueuing whole chunks atomically. This needs frame-aligned writes or a consumer-side partial-frame stash.

@mpiorowski
Copy link
Copy Markdown
Owner

fix on another pr :)

@mpiorowski mpiorowski closed this May 3, 2026
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.

2 participants