feat: infinite sources return Duration::MAX for total_duration#863
Closed
Sim-hu wants to merge 1 commit intoRustAudio:masterfrom
Closed
feat: infinite sources return Duration::MAX for total_duration#863Sim-hu wants to merge 1 commit intoRustAudio:masterfrom
Sim-hu wants to merge 1 commit intoRustAudio:masterfrom
Conversation
Previously, `total_duration()` returned `None` for both infinite and unknown-duration sources, making them indistinguishable. Infinite sources (generators, repeat, looped decoders, microphone) now return `Some(Duration::MAX)`, so wrapping them with `TakeDuration` correctly reports the requested duration instead of `None`. Fixes RustAudio#702
a5855e4 to
19bac75
Compare
Member
|
closed as spam per https://rust.audio/community/ai/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Some(Duration::MAX)instead ofNonefromtotal_duration()TakeDurationnow returnsSome(requested_duration)when wrapping unknown-duration sources, instead ofNoneSource::total_duration()doc to clarify thatNonemeans unknown andDuration::MAXmeans infiniteThis is the simpler alternative discussed in #702 — using
Duration::MAXto represent infinity rather than introducing a new enum.Test plan
infinite_sources_return_duration_maxtesttake_duration_on_infinite_sourcetest — verifiesSineWave.take_duration(5s)reportsSome(5s)repeat_returns_duration_maxtestcargo test --no-default-features --features "wav,mp3,flac,vorbis" --lib --tests)cargo clippycleancargo fmt --checkcleanFixes #702