-
Notifications
You must be signed in to change notification settings - Fork 22
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
How to detect when decoder has reached end of audio file? #20
Comments
I have little experience in rust. Can you debug why
return Err(Error::Eof); is not triggered? |
@lieff When |
Yes, I try to understand how it can happen. If Ok(frame) always returned
then samples should be non-zero. It can happen only if self.buffer.len() is non-zero, so buffer not fully consumed here:
Can you debug and confirm that? Also minimp3-rs/examples/example.rs seems relies on Err(Error::Eof), does it work on your side? |
@lieff I'm not using minimp3 directly, I'm using it through rodio.. |
Some(0) do not means buffer is empty, Only in combination if with current buffer we have Err(Error::InsufficientData) | Err(Error::SkippedData) and we can`t read anything further (Some(0)) means Err(Error::Eof); which looks correct in code. If minimp3-rs/examples/example.rs works with your mp3 file then it's not minimp3-rs bug after all. If you share your mp3 file - I can look at it too. |
@lieff It happened with all mp3 files I tested.. |
Not minimp3-rs bug then, can't reproduce issue with bundled mp3 test file and decoder.next_frame() successfully returns Err(Error::Eof) on eof. |
@lieff Can you please try with this file? This file exhibits this behavior. I think the bug is in this crate because the rodio code on top of this is very minimal and seems correct: Btw, I have another issue, maybe this is related to this one? |
No luck, can't reproduce:
Outputs:
|
That`s expected, minimp3-rs have filled internal buffer, so when you consume data from stream to skip frames, filled buffer coninued to decode. Also mp3 have bit-reservoir, so some frames may not decode after such seek. Overall mp3 have complex seek procedure https://github.com/lieff/minimp3/blob/master/minimp3_ex.h#L707, minimp3-rs currently do not have one. |
@lieff I don't understand: Why does the decoder start over from the start again after I drained samples from it? |
I do not know, auto-rewind streams may be? Do you have minimal reproduction example? |
RustAudio/rodio#293
next_frame
seems to always returnSome
.The text was updated successfully, but these errors were encountered: