Skip to content

Conversation

@roderickvd
Copy link
Member

This fixes a few related issues with how the queue handles empty/exhausted sources and their metadata. Issue reported on Discord here: https://discord.com/channels/590254806208217089/1394057870466744411/1455547213328683110.

Issue summary

Appending a source with different channels/sample_rate to an empty queue would use wrong metadata during the UniformSourceIterator setup, causing resampling with incorrect parameters.

Changes

  • Queue now properly reports metadata from the next queued source instead of hardcoded silence values, preventing resampling issues when appending sources
  • Queue uses the current source's metadata when generating keep-alive silence chunks
  • Empty now properly reports exhaustion via current_span_len() = Some(0).

Opportunistic refactoring

  • Empty now properly implements size_hint and ExactSizeIterator
  • Zero now properly implements size_hint, try_seek and total_duration implementations, plus Copy derive

* Empty: make unit struct, derive Default, and implement Iterator::size_hint
and ExactSizeIterator.

* Zero: derive Copy; implement size_hint, total_duration and try_seek;
and fix current_span_len to return total span length.
@roderickvd roderickvd added the bug label Dec 30, 2025
@glima31
Copy link

glima31 commented Dec 30, 2025

I confirm that this fixes both the core issue descrbed in my initial discord message regarding this matter and also the one described here.

When playing back the encoded data to the target hardware device, i no longer have decoding problems during the first moments of playback.

@roderickvd
Copy link
Member Author

Perfect, considering it solved. Thank you for your prompt feedback. Merging now.

@roderickvd roderickvd merged commit a1a1219 into master Dec 30, 2025
9 checks passed
@roderickvd roderickvd deleted the fix/empty-source-exhaustion branch December 30, 2025 20:03
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.

3 participants