Skip to content

Reduce initial playback stutter#69

Merged
kahrendt merged 2 commits into
mainfrom
initial-stutter-fixes
Jun 11, 2026
Merged

Reduce initial playback stutter#69
kahrendt merged 2 commits into
mainfrom
initial-stutter-fixes

Conversation

@kahrendt

@kahrendt kahrendt commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Two changes give the decode pipeline more slack at stream start:

  • Insert extra silence after the first playback notification, before the first decoded chunk reaches the sink, so the decoder has time to stay ahead. The amount is configurable via PlayerRoleConfig::extra_startup_silence_ms (default 50 ms; 0 disables).
  • On encoded ring-buffer underflow, feed silence to keep the DAC fed instead of letting it run dry. Gated on aligning so it only runs during startup/post-seek alignment, not in steady state where stuffing silence at stream end would pile up in the sink and delay a rapid restart.

Adds the frame_aligned_silence_bytes() helper and fill_underflow_silence() to keep the sync task readable, and documents the behavior in the integration guide and internals docs.

Breaking change: the PlayerRoleConfig has been modified with a new field inserted in the middle.

…low keepalive

Two changes give the decode pipeline more slack at stream start:

- Insert extra silence after the first playback notification, before the
  first decoded chunk reaches the sink, so the decoder has time to stay
  ahead. The amount is configurable via
  PlayerRoleConfig::extra_startup_silence_ms (default 50 ms; 0 disables).
- On encoded ring-buffer underflow, feed silence to keep the DAC fed
  instead of letting it run dry. Gated on `aligning` so it only runs
  during startup/post-seek alignment, not in steady state where stuffing
  silence at stream end would pile up in the sink and delay a rapid
  restart.

Adds the frame_aligned_silence_bytes() helper and fill_underflow_silence()
to keep the sync task readable, and documents the behavior in the
integration guide and internals docs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR reduces initial playback stutter by adding configurable extra startup silence and by bridging encoded-chunk underflows with short silence writes during alignment (startup/post-seek), keeping the DAC fed until data arrives.

Changes:

  • Add extra_startup_silence_ms to PlayerRoleConfig and document it in integration docs.
  • Introduce frame-aligned silence sizing and queue/drain extra startup silence after the first playback-progress callback.
  • During alignment, feed short “keepalive” silence slices on ring-buffer underflow to avoid DAC underruns.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/sync_task.h Declares fill_underflow_silence() and documents the new underflow-bridging behavior.
src/sync_task.cpp Implements frame-aligned silence calculation, extra startup silence draining, and alignment-only underflow silence fill.
include/sendspin/config.h Adds new public config knob extra_startup_silence_ms with a default.
docs/internals.md Updates state-machine docs to describe extra startup silence and alignment-only underflow fill.
docs/integration-guide.md Documents the new configuration option and shows it in example config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/sendspin/config.h
Comment thread src/sync_task.cpp
Comment thread src/sync_task.h
@kahrendt kahrendt enabled auto-merge (squash) June 11, 2026 14:52
@kahrendt kahrendt merged commit bf9e085 into main Jun 11, 2026
5 checks passed
@kahrendt kahrendt deleted the initial-stutter-fixes branch June 11, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants