Skip to content

fix: don't re-invoke exhausted source during keep-alive silence - #913

Draft
roderickvd wants to merge 2 commits into
masterfrom
fix/queue-keep-alive-reinvokes-exhausted-source
Draft

fix: don't re-invoke exhausted source during keep-alive silence#913
roderickvd wants to merge 2 commits into
masterfrom
fix/queue-keep-alive-reinvokes-exhausted-source

Conversation

@roderickvd

Copy link
Copy Markdown
Member

SourcesQueueOutput::next() kept calling current.next() on the just-exhausted source every time the keep-alive silence ran out, instead of moving past it. Sources like EmptyCallback fired repeatedly for as long as the queue stayed empty, instead of once.

This PR tracks exhaustion explicitly and stops calling next() on current once observed, while still checking the queue every frame so a newly appended source starts with no added latency.

SourcesQueueOutput::next() kept calling current.next() on the
just-exhausted source every time the keep-alive silence budget ran
out, instead of moving past it. Sources with side effects in next()
(like EmptyCallback) fired repeatedly for as long as the queue
stayed empty, instead of exactly once.

Track exhaustion explicitly and stop calling next() on current once
observed, while still checking the queue every frame so a newly
appended source starts with no added latency.
@roderickvd
roderickvd requested a review from yara-blue July 31, 2026 16:17
@roderickvd roderickvd added the bug label Jul 31, 2026
@roderickvd
roderickvd marked this pull request as draft July 31, 2026 18:17
@roderickvd

Copy link
Copy Markdown
Member Author

Converting to draft because we're not done yet (see Discord: 100% busy-looping when no source has been added yet).

@yara-blue I haven't dived into the engine rewrite PRs yet; if we are to back port this (do we need to at all?) then in which "phase PR" should I be looking?

@yara-blue

Copy link
Copy Markdown
Member

@yara-blue I haven't dived into the engine rewrite PRs yet; if we are to back port this (do we need to at all?) then in which "phase PR" should I be looking?

That should be Phase four. I'll make a note in the tracking issue to check for this since with the new traits I rewrote the queue mechanic (to prevent allocating on the audio thread).

- Introduce a format-aware Empty and allow queue keep-alive with an optional
  source (Option<Box<dyn Source + Send>>) instead of a bool.

- Add Mixer helpers (channels, sample_rate, silence) and
  Player::new_with_keep_alive/connect_new to use a silence keep-alive.

- Cache peeked metadata in SourcesQueueOutput to correctly report
  channel/sample_rate while the queue is briefly empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants