Fix Scons for SDL2_mixer 2.0.2
With the change from SDL_mixer 2.0.1 to 2.0.2, we cannot simply check if SDL_mixer can open an OGG/Vorbis file, we must first open an audio device. [This is probably a mistake, since the documentation implies simply initializing the codec should be enough.] To avoid future problems, upgrade the feature-test program to perform a full initialization and shut-down; everything except actually playing the sound. Closes #2137
This commit is contained in:
parent
81809a9dd7
commit
c4d78f8fc6
1 changed files with 34 additions and 9 deletions
43
scons/sdl.py
43
scons/sdl.py
|
@ -93,17 +93,42 @@ def CheckSDL(context, sdl_lib = "SDL", require_version = None, header_file = Non
|
||||||
|
|
||||||
def CheckOgg(context):
|
def CheckOgg(context):
|
||||||
test_program = '''
|
test_program = '''
|
||||||
#include <SDL_mixer.h>
|
#include <stdlib.h>
|
||||||
#include <stdlib.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
#include <SDL2/SDL.h>
|
||||||
{
|
#include <SDL2/SDL_mixer.h>
|
||||||
Mix_Music* music = Mix_LoadMUS("$TESTFILE");
|
|
||||||
if (music == NULL) {
|
int main(int argc, char ** argv)
|
||||||
exit(1);
|
{
|
||||||
}
|
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
|
||||||
exit(0);
|
fprintf(stdout, "Cannot initialize SDL Audio: %s\\n", SDL_GetError());
|
||||||
|
return (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) == -1) {
|
||||||
|
fprintf(stdout, "Cannot initialize SDL Mixer: %s\\n", Mix_GetError());
|
||||||
|
return (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Mix_Init(MIX_INIT_OGG) != MIX_INIT_OGG) {
|
||||||
|
fprintf(stdout, "Cannot initialize OGG codec: %s\\n", Mix_GetError());
|
||||||
|
Mix_CloseAudio();
|
||||||
|
return (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
Mix_Music* music = Mix_LoadMUS("$TESTFILE");
|
||||||
|
if (music == NULL) {
|
||||||
|
fprintf(stdout, "Cannot load music file: %s\\n", Mix_GetError());
|
||||||
|
Mix_CloseAudio();
|
||||||
|
return (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stdout, "Success\\n");
|
||||||
|
Mix_FreeMusic(music);
|
||||||
|
Mix_CloseAudio();
|
||||||
|
return (EXIT_SUCCESS);
|
||||||
|
}
|
||||||
\n
|
\n
|
||||||
'''
|
'''
|
||||||
nodepath = File("data/core/music/main_menu.ogg").rfile().abspath.replace("\\", "\\\\")
|
nodepath = File("data/core/music/main_menu.ogg").rfile().abspath.replace("\\", "\\\\")
|
||||||
|
|
Loading…
Add table
Reference in a new issue