-
Notifications
You must be signed in to change notification settings - Fork 232
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
Don't drop source when finished #578
Comments
First of all, thanks for the report! 👍
If I understand correctly to reproduce you:
You would expect the seek call to work on the last played item and allow you to (re)start playback correct? That seems reasonable to me, the issue is the current behavior of the queue it throws away sources that are done. This would need some kind of "seek support" for the queue.
Thats pretty bad. I think this could be due to the blocking recv here: Line 225 in 11221a8
If the source has been removed by the queue that
I like the idea of automatically pausing the queue if there is no more source past the current. I remember a PR or Issue where someone proposed expanding the queue to support referencing items in it. I gotta find that again and see if that could be useful. |
Hi, thanks for your reply! Your description sums it up nicely and confirms what I thought was the root of the issue. I think a pause-on-finish feature would be great and could even be the default. The only downside I see is that some data might be kept in memory for longer, but that seems manageable.
As in accessing items in the queue through a |
That does not seem worked out but we do have this PR for accessing items in a new queue type: #506 |
#579 should fix the hanging. I had a look at the queue that underpins most of That would also be a good point to address some current pitfalls with the API (for example Sink::new, return two objects you need to keep alive). Right now I am working on other stuff and not really using rodio. I hope that will change in a few months at which point I'll take a look at such a re-design. Of course I'll do my best to fix more pressing issues as they pop up. For now, pending that redesign, I would recommend using |
Thank you! Am I correct in assuming that using On a related note, do |
Depending on the format there is some cost yes, its really unfortunate. If you're
Yes they stream data from disk if you are opening a file. The decoders wrap anything implementing Read+Seek. You could use std::io::Cursor to create a Read+Seek interface around a Vec, then read the file to that Vec. I do not know your precise application, if it is a rhythm game or something with many sounds that need to be precisely timed you should take a look at kira. Its an audio lib purely focused on gaming and might fit your needs better, though a bit more complex to set up and less extensible. |
Thanks for the tip! However, I believe I think it should be relatively straightforward to implement an |
Atm rodio has a avg 2.5ms (max 5) delay between a seek and it starting. Planning to get rid of it in the future but you should know.
It does hold the samples, decoded, in memory initially. It drop the part of a source already played/consumed from memory as soon as it can. Thats pretty memory efficient however makes it impossible to support seeking without undoing that.
Yeah I think so too, you should be able to make it generic around anything implementing Just wrap it around a sampleconverter before you stick it into the Sink. The sample converter will make sure you have the same sample rate for the entire source. That should make implementing seeking easier. Combine that with your Still I would have a look at just loading the file to memory. Then the decoder has fast random access and latency should be pretty low. |
I noticed that as well! I think some pretty solid API choices where made here :)
I'm after sub-millisecond delays (which is tricky to begin with) and I don't want to include more sources of potential perofmance bottlenecks than necessary - altough I think that we're probbaly talking about latencies an order of magnitude lower than that. |
I think this can be closed, as the original issue is currently intended behavior, and the part that was actually a bug seems fixed. |
I've been exploring the new seeking feature and noticed a couple of issues. When a source is played, it gets removed from the queue and
try_seek()
stops working. On macOS, it even stalls the thread without returning an error, which might need its own bug report.One idea I had to work around this is to implement a
NeverStop
source that never returnsNone
onnext()
. However, I'm wondering if there's a better way to handle this, like automatically pausing when a source finishes.My current workaround for reference>
The text was updated successfully, but these errors were encountered: