We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3706

Summary: [PATCH] mpg123 support
Product: SDL_mixer Reporter: Franc[e]sco <lolisamurai>
Component: miscAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: enhancement    
Priority: P2    
Version: 2.0.1   
Hardware: x86_64   
OS: Linux   
Attachments: mpg123 support patch

Description Franc[e]sco 2017-07-20 22:24:12 UTC
Created attachment 2805 [details]
mpg123 support patch

hello, I was playing with SDL2_mixer and I've noticed that smpeg2 has major issues loading specific malformed/exotic mp3 files such as mp3 files with japanese metadata, which made it hang upon loading the file.

after googling around, I found a github issue about SDL_mixer's mp3 support and they ended up plugging libmpg123 using the music player hook.

libmad seems to do okay for me, but the aforementioned issue reports "noises or crashes due to buffer issues" and both libmad and smpeg2 appear to be unmaintained for many years, so I thought I'd add a libmpg123 mp3 module.

thanks to mpg123's flexible interface I was able to achieve this quickly and with little code, and it even supports seeking. this is a lot cleaner than using the MusicPlayer hook and more flexible.

you can find some advantages of mpg123 on the aforementioned github issue (https://github.com/EasyRPG/Player/issues/818), but basically it handles broken or exotic files much better than mad and smpeg (especially smpeg), and it's a bit more maintained from what I can see.

I have attached the patch, first time working with mercurial and sending patches through mail so there might be mistakes.
Comment 1 Franc[e]sco 2017-07-23 12:21:06 UTC
update: I've found a couple mp3's that play incorrectly even on libmad (stuttering really hard) but play perfectly with my mpg123 patch
Comment 2 Sam Lantinga 2017-10-13 05:28:59 UTC
Added, thanks!
https://hg.libsdl.org/SDL_mixer/rev/420f3b37dc95