Skip to content

Queue: let try_seek reach a source that was appended but not yet started - #941

Open
kapok-4o wants to merge 1 commit into
RustAudio:masterfrom
kapok-4o:fix/queue-seek-before-first-sample
Open

kapok-4o wants to merge 1 commit into
RustAudio:masterfrom
kapok-4o:fix/queue-seek-before-first-sample

Conversation

@kapok-4o

Copy link
Copy Markdown

Fixes #932

What was wrong

SourcesQueueOutput only moves a queued source into current when next() runs out of
samples. Until then current is the initial Empty (or the source that just finished), so
try_seek went to the wrong source:

  • right after append, before the first sample, it failed with NotSupported from Empty;
  • after a source had ended but before the next sample was pulled, it seeked the finished
    source instead of the one about to play.

The fix

try_seek now does what next() would do first: while current is exhausted, it moves to
the next queued source (skipping exhausted ones and signalling append_with_signal receivers
as usual), then seeks it. channels() and sample_rate() already look ahead the same way.
It does nothing while keep-alive silence padding is still completing a frame, so frame
alignment and span lengths are unchanged. When nothing is queued, current is left alone, so
seeking an empty queue (or one whose last source has finished) behaves exactly as before.

Tests

New tests in src/queue.rs:

  • seek_before_first_sample (the snippet from the issue, with and without keep-alive)
  • seek_after_source_finished_moves_to_next_source
  • seek_skips_exhausted_sources
  • seek_on_empty_queue_fails_and_keeps_playing_silence

The first three fail on master and pass with the fix.

This is a small, local change on purpose, so the engine rewrite can replace it later if the
queue gets reworked there. For reference, none of the open rewrite PRs (#904, #905, #910,
#911) change src/queue.rs; #911 only touches src/player.rs for the new amplify API.

SourcesQueueOutput only moved a queued source into current when next()
ran out of samples, so try_seek before the first sample hit the Empty
placeholder and failed, and try_seek right after a source ended seeked
the finished source. Move past exhausted sources first when something is
queued, as next() would.

Fixes RustAudio#932
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.

SourcesQueueOutput.try_seek() after SourcesQueueInput.append() fails until output is first iterated.

1 participant