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 2399

Summary: libmad MP3 sample support broken
Product: SDL_mixer Reporter: prefer.irc
Component: miscAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED DUPLICATE QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: fran
Version: unspecified   
Hardware: All   
OS: Linux   
Attachments: Implement suggested fix
Fix libmad MP3 sample support, part 2 (bug#2399 for details)
Fix libmad MP3 sample support, part 3 (bug#2399 for details)

Description prefer.irc 2014-02-15 18:32:30 UTC
Source:
    HG tip (670/e7c3e537322d)

Disclaimer:
    Unconfirmed. Found while browsing source (attempting to determine build/link/run time dependencies)

Description:
    load_mp3.c::Mix_LoadMP3_RW calls Mix_Init(MIX_INIT_MP3) and checks the result for the MIX_INIT_MP3 flag, but that flag is not set by mixer.c::Mix_Init if MP3_MUSIC (smpeg2) is disabled. To use libmad, smpeg2 has to be disabled because smpeg2 takes precedence over libmad.

Fix:
    in mixer.c::Mix_Init (flags & MIX_INIT_MP3) {...} block, use following code:

    if (flags & MIX_INIT_MP3) {
#ifdef MP3_MUSIC
        if ((initialized & MIX_INIT_MP3) || Mix_InitMP3() == 0) {
            result |= MIX_INIT_MP3;
        }
#elif MP3_MAD_MUSIC
        result |= MIX_INIT_MP3;
#else
        Mix_SetError("Mixer not built with MP3 support");
#endif
Comment 1 prefer.irc 2014-02-16 17:04:20 UTC
Created attachment 1559 [details]
Implement suggested fix
Comment 2 prefer.irc 2014-02-16 20:37:04 UTC
Created attachment 1560 [details]
Fix libmad MP3 sample support, part 2 (bug#2399 for details)

Mix_LoadMP3_RW was only declared for smpeg2 (MP3_MUSIC), however it should also be declared for libmad (MP3_MAD_MUSIC).
Comment 3 prefer.irc 2014-02-16 21:04:29 UTC
Created attachment 1561 [details]
Fix libmad MP3 sample support, part 3 (bug#2399 for details)

Configure option --enable-music-mp3-mad-gpl should include load_mp3.c in $SOURCES
Comment 4 Francisco de la Peña 2014-09-22 00:38:48 UTC
I can confirm linking issues when trying ./configure --enable-mp3-music-mad-gpl
Building fails when linking playwave:

    build/.libs/libSDL2_mixer.so: undefined reference to `Mix_LoadMP3_RW'

Your patch fixes it for me.
Comment 5 Francisco de la Peña 2015-08-02 05:15:55 UTC
Fixed in #2743

*** This bug has been marked as a duplicate of bug 2743 ***