Skip to content

Commit

Permalink
Ignore SDL2_mixer 2.0.2 Mix_init() bug
Browse files Browse the repository at this point in the history
2.0.2 is still found in some Linux package mangers
  • Loading branch information
blacktm committed Apr 12, 2019
1 parent a1afb65 commit 84d8474
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/simple2d.c
Expand Up @@ -133,9 +133,19 @@ bool S2D_Init() {
// Initialize SDL_mixer // Initialize SDL_mixer
int mix_flags = MIX_INIT_FLAC | MIX_INIT_OGG | MIX_INIT_MP3; int mix_flags = MIX_INIT_FLAC | MIX_INIT_OGG | MIX_INIT_MP3;
int mix_initted = Mix_Init(mix_flags); int mix_initted = Mix_Init(mix_flags);
if ((mix_initted&mix_flags) != mix_flags) {
S2D_Error("Mix_Init", Mix_GetError()); // Bug in SDL2_mixer 2.0.2:
// Mix_Init should return OR'ed flags if successful, but returns 0 instead.
// Fixed in: https://hg.libsdl.org/SDL_mixer/rev/7fa15b556953
const SDL_version *linked_version = Mix_Linked_Version();
if (linked_version->major == 2 && linked_version->minor == 0 && linked_version->patch == 2) {
// It's version 2.0.2, don't check for Mix_Init errors
} else {
if ((mix_initted&mix_flags) != mix_flags) {
S2D_Error("Mix_Init", Mix_GetError());
}
} }

if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096) != 0) { if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096) != 0) {
S2D_Error("Mix_OpenAudio", Mix_GetError()); S2D_Error("Mix_OpenAudio", Mix_GetError());
return false; return false;
Expand Down

0 comments on commit 84d8474

Please sign in to comment.