Skip to content

Mix_Init always returns 0 - no supported music interfaces found #237

@SDLBugzilla

Description

@SDLBugzilla

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: 2.0.2
Reported for operating system, platform: Linux, x86

Comments on the original bug report:

On 2017-10-31 09:57:50 +0000, Steffen Pankratz wrote:

Created attachment 3049
Patch for has_music function

Previously working code broke after the upgrade to version 2.0.2.

The call 'Mix_Init(MIX_INIT_OGG)' always returned 0.
I made sure that SDL_mixer was built with support for Ogg Vorbis.

After I little bit of debugging, it looks to me like the implementation in the 'has_music' function might be wrong.

'Mix_Init' calls 'load_music' which sets 'loaded' to 'SDL_TRUE' for all supported music interfaces.

'Mix_Init' then calls 'has_music' for the requested music interface.
'has_music' checks that the requested music interface was 'opened'.

Which is not that case at that time, so I think 'opened' should be replace by 'loaded'.

For me the attached patch fixed the problem.

On 2018-02-28 10:38:42 +0000, Martin Stumpf wrote:

Hey!

I had the exact same problem, and the exact same idea.
Replacing 'opened' with 'loaded' in 'has_music' won't work though, as the 'opened' check is intentional later, in 'open_music', to see if the ogg music did actually open. What needs to be changed is the way the error flag in Mix_Init gets generated ...

@devs this should be a simple fix and I'd do it myself if I had the commit rights. Hope it gets fixed soon :)

On 2018-02-28 10:43:24 +0000, Martin Stumpf wrote:

This problem, however, only concerns the return flag of Mix_Init, it does not break any functionality. Just ignoring the return flag (which is still not good, however) is an acceptable workaround until this gets fixed.

On 2018-02-28 18:19:03 +0000, Sam Lantinga wrote:

This should be fixed in this commit, can you verify?
https://hg.libsdl.org/SDL_mixer/rev/7fa15b556953

On 2018-03-01 11:17:33 +0000, Martin Stumpf wrote:

Seems like it :)
Didn't test extensively, but the return code of Mix_Init seems correct.

Greetings and thanks,
Martin

On 2018-03-01 15:59:58 +0000, Sam Lantinga wrote:

Great, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions