[GB.SDL2.AUDIO]
* NEW: Explicitely initialize each sound format support, and print a warning for each failure. * NEW: 'gb.sdl2.audio' does not require 'gb.sdl2' anymore. git-svn-id: svn://localhost/gambas/trunk@6793 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
a5f2cb1575
commit
4edd14b3db
4 changed files with 19 additions and 2 deletions
|
@ -10,5 +10,6 @@ Component=gb.form
|
|||
Component=gb.sdl.sound
|
||||
Description="LCDLabel example.\n\nThis example shows a timer based on a LCDLabel control."
|
||||
TabSize=2
|
||||
Language=fr
|
||||
Vendor=Example
|
||||
Packager=1
|
||||
|
|
|
@ -144,6 +144,7 @@ static bool start_sound_engine()
|
|||
}
|
||||
|
||||
Mix_QuerySpec(&info.rate, &info.format, &info.channels);
|
||||
//fprintf(stderr, "Mix_QuerySpec: %d %d %d\n", info.rate, info.format, info.channels);
|
||||
|
||||
channel_count = Mix_AllocateChannels(-1);
|
||||
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
[Component]
|
||||
Key=gb.sdl2.audio
|
||||
Require=gb.sdl2
|
|
@ -40,6 +40,12 @@ bool AUDIO_initialized = FALSE;
|
|||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
static void init_mixer(int flag, const char *name)
|
||||
{
|
||||
if ((Mix_Init(flag) & flag) != flag)
|
||||
fprintf(stderr, "gb.sdl2.audio: warning: %s\n", Mix_GetError());
|
||||
}
|
||||
|
||||
bool AUDIO_init()
|
||||
{
|
||||
Uint16 format;
|
||||
|
@ -48,6 +54,12 @@ bool AUDIO_init()
|
|||
if (AUDIO_initialized)
|
||||
return FALSE;
|
||||
|
||||
init_mixer(MIX_INIT_MP3, "MP3");
|
||||
init_mixer(MIX_INIT_OGG, "OGG");
|
||||
init_mixer(MIX_INIT_MOD, "MOD");
|
||||
init_mixer(MIX_INIT_FLAC, "FLAC");
|
||||
init_mixer(MIX_INIT_FLUIDSYNTH, "FLUIDSYNTH");
|
||||
|
||||
if (Mix_OpenAudio(AUDIO_frequency, MIX_DEFAULT_FORMAT, 2, AUDIO_buffer_size))
|
||||
{
|
||||
GB.Error("Unable to initialize mixer");
|
||||
|
@ -55,6 +67,7 @@ bool AUDIO_init()
|
|||
}
|
||||
|
||||
Mix_QuerySpec(&AUDIO_frequency, &format, &channels);
|
||||
//fprintf(stderr, "AUDIO_init: %d %d %d\n", AUDIO_frequency, format, channels);
|
||||
|
||||
if (CHANNEL_init())
|
||||
return TRUE;
|
||||
|
@ -71,6 +84,9 @@ static void AUDIO_exit()
|
|||
CHANNEL_exit();
|
||||
MUSIC_exit();
|
||||
Mix_CloseAudio();
|
||||
|
||||
while (Mix_Init(0))
|
||||
Mix_Quit();
|
||||
}
|
||||
|
||||
static void init_sdl()
|
||||
|
|
Loading…
Reference in a new issue