-
Notifications
You must be signed in to change notification settings - Fork 293
Fix Symphonia seek for a duration with a fractional element of 0 #687
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
if frac < 0.0001 { } else { }instead?Next to the beginning of the Source
saturating_subwill leave seconds unchanged, and the whole effect would be to actually seek forward almost a second.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its never called at the beginning of the source. This handles seeking beyond a source end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this is good to merge right?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it fixes the problem - yes, we can merge. Since it is already an improvement.
We can handle other cases later if necessary.
The source itself can be less than a second long. The check compares with < 1ms overlap, but tick-back is 0.1ms. what about overlaps in range 0.1...1.0 ms? I wonder if there are any symphonia functions to work with its timestamps or ways to convert those from/to Duration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh damn, I did not think of that. Thanks for clarifying. No I agree now, lets fix this properly only then merge. This will need a comment in the code explaining this case or a future refactor might throw the code out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I placed this comment in the code:
As I remember symphonia does not seek if the time is beyond the length of the track. In rodio we have defined seek to saturate at the track length. If symphonia now saturates we can remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you seek to or beyond the end, you get an
UnexpectedEofwhich is anyway what you get when the stream ends.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though that is completely valid behavior for symphonia its not what we want in rodio (seeking beyond source should saturate as that is easiest for the end user) we do this instead. We also still want to return UnexpectedEof in case of other errors.
Though reading it now is still kinda fragile when audio has no
total_duration. I'm strongly for leaving it as is for now. Since we have more then enough going on atm :)edit: and the next release is already going to be gigantic. Do feel free to open an issue and present alternative behavior.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean with saturating? I assume the behavior should be that the iterator returns
None. Is that also what you mean?I would make (and have made) the Symphonia decoder such that it handles this specific end-of-stream
UnexpectedEofthat way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see the docs: https://docs.rs/rodio/latest/rodio/source/trait.Source.html#method.try_seek
As long as the duration of the source is known seek is guaranteed to saturate at the end of the source. For example given a source that reports a total duration of 42 seconds calling try_seek() with 60 seconds as argument will seek to 42 seconds.
Yeah that's way simpler, go ahead and do that 👍 Maybe I was worried about skipping back? but that's not a feature nor can we make it one.