Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea/proposal: Total_duration enum (unknown/max/guarenteed) #702

Open
dvdsk opened this issue Feb 16, 2025 · 0 comments
Open

Idea/proposal: Total_duration enum (unknown/max/guarenteed) #702

dvdsk opened this issue Feb 16, 2025 · 0 comments

Comments

@dvdsk
Copy link
Collaborator

dvdsk commented Feb 16, 2025

Idea by @The0x539 #626 (comment). Currently infinite sources will return None for total_duration, when paired with a TakeDuration you still get None. Another place we can do better is skippable. Right now a skippable will pass on the total_duration of what it wraps. Because the source can be skipped at any point there is no guarentee it will actually play for that length.

To address these issues we can put extra information in the total_duration result:

enum SourceDuration {
  Max(Duration),
  Guarenteed(Duration),
  Infinite,
  Unknown,
}

We could provide methods to turn this into an option returning Duration::MAX for Infinite. We could call that method known. We could also provide a map, is_known and maybe an unwrap_or.

A far simpler alternative to this proposal would be making infinite sources return Duration::MAX.

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

No branches or pull requests

1 participant