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

Seeking to 0 makes it impossible to read until end of file #101

Open
Biohazard90 opened this issue Sep 6, 2022 · 3 comments
Open

Seeking to 0 makes it impossible to read until end of file #101

Biohazard90 opened this issue Sep 6, 2022 · 3 comments

Comments

@Biohazard90
Copy link

Biohazard90 commented Sep 6, 2022

I'm using SFML https://github.com/SFML/SFML which in turn uses minimp3. Certain mp3 files fail to continue looping after the first loop.

It looks like minimp3 stops returning the expected data until EOF after using mp3dec_ex_seek(dec, 0). This only happens on specific files. Due to never reaching the expected end, SFML inconveniently just stops playing audio altogether.

Looking through the debugger, the "offset" member of the decoder object is incorrect after seeking to 0 vs when playing a new file from scratch. I've made a blind guess and moved position += dec->start_delay; after the if (0 == position) block and that seemed to have fixed it. But I practically have no understanding of what's going on and no time to dive more into it, so I'm not comfortable with making a pull request since I might be totally off the mark here.

position += dec->start_delay;

I've attached an audio file from my users that experience this issue for repro:

Feeling - Tung Wasabi (mp3cut.net).mp3.zip

@Biohazard90
Copy link
Author

There is another issue where certain files never reach the end of the expected sample count even before looping. The expected sample count (detected_samples) does not appear to match the available data in this case (cur_sample never reaches detected_samples) - minimp3 attempts to continue reading data although EOF is reached, this again causes SFML to malfunction and stop playing instead of looping.

I'm attaching a file exhibiting this behavior again. In this case I will likely change SFMLs behavior now to be more robust against this unexpected EOF issue and just loop the file instead of erroring out, but it seems the underlying issue is in minimp3 too.

SIERRA - UNBROKEN (mp3cut.net).mp3.zip

@eXpl0it3r
Copy link

Any update on this, @lieff?

@eXpl0it3r
Copy link

Looks like this was fixed in dr_mp3 implementation that uses minimp3's decoding. If anyone is looking for an alternative, I can recommend switching to dr_mp3.

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

2 participants