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 3929 - Mix_Init always returns 0 - no supported music interfaces found
Summary: Mix_Init always returns 0 - no supported music interfaces found
Status: RESOLVED FIXED
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: 2.0.2
Hardware: x86 Linux
: P2 blocker
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-31 09:57 UTC by Steffen Pankratz
Modified: 2018-03-01 15:59 UTC (History)
2 users (show)

See Also:


Attachments
Patch for has_music function (618 bytes, patch)
2017-10-31 09:57 UTC, Steffen Pankratz
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steffen Pankratz 2017-10-31 09:57:50 UTC
Created attachment 3049 [details]
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.
Comment 1 Martin Stumpf 2018-02-28 10:38:42 UTC
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 :)
Comment 2 Martin Stumpf 2018-02-28 10:43:24 UTC
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.
Comment 3 Sam Lantinga 2018-02-28 18:19:03 UTC
This should be fixed in this commit, can you verify?
https://hg.libsdl.org/SDL_mixer/rev/7fa15b556953
Comment 4 Martin Stumpf 2018-03-01 11:17:33 UTC
Seems like it :)
Didn't test extensively, but the return code of Mix_Init seems correct.

Greetings and thanks,
Martin
Comment 5 Sam Lantinga 2018-03-01 15:59:58 UTC
Great, thanks!