Skip to content

Discard buffered frames when seeking while paused - #163

Merged
tesselode merged 2 commits into
tesselode:mainfrom
nnmarcoo:fix-streaming-seek-while-paused
Aug 9, 2026
Merged

Discard buffered frames when seeking while paused#163
tesselode merged 2 commits into
tesselode:mainfrom
nnmarcoo:fix-streaming-seek-while-paused

Conversation

@nnmarcoo

@nnmarcoo nnmarcoo commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #162

Seeking while a StreamingSound is paused doesn't discard the audio the decode scheduler already buffered ahead of the playhead, so frames from the old position play before any frame from the new one.

This implements the on_sync approach you suggested in the issue: seek_to and seek_by on the handle now also notify the StreamingSound, which drains the frame ringbuffer when playback isn't advancing. The scheduler can't drain it itself, since only the consumer side can pop.

Tests

  • seek_while_paused_discards_stale_frames reproduces the issue and fails on main with the original symptom.
  • seek_while_playing_keeps_buffered_frames covers the case where draining would be wrong. Removing the is_advancing guard makes it fail with silence where audio should be.

Note

  • handle.position() briefly reports the pre-seek position after seeking, until the scheduler pushes frames from the new position. Position is derived from the index of frames in the ringbuffer rather than from the seek itself, so this predates this change and happens on main too. Mentioning it since it's adjacent, but it looked like a separate minor issue.

Let me know if you'd like a changelog entry. I wasn't sure whether those get written at release time.

@tesselode

Copy link
Copy Markdown
Owner

looks good, thanks!

i'll take care of the changelog

@tesselode
tesselode merged commit ccc1712 into tesselode:main Aug 9, 2026
24 checks passed
@nnmarcoo
nnmarcoo deleted the fix-streaming-seek-while-paused branch August 10, 2026 01:46
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.

Seeking while paused stream replays ~0.37s of the old position on resume

2 participants