From 4edd14b3db37d25e9901200233d64df5be5170e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Fri, 2 Jan 2015 10:47:37 +0000 Subject: [PATCH] [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 --- app/examples/Control/LCDLabel/.project | 1 + gb.sdl.sound/src/sound.c | 1 + gb.sdl2/src/audio/gb.sdl2.audio.component | 1 - gb.sdl2/src/audio/main.c | 18 +++++++++++++++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/examples/Control/LCDLabel/.project b/app/examples/Control/LCDLabel/.project index 2a7f60822..28b621c79 100644 --- a/app/examples/Control/LCDLabel/.project +++ b/app/examples/Control/LCDLabel/.project @@ -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 diff --git a/gb.sdl.sound/src/sound.c b/gb.sdl.sound/src/sound.c index 0d489478a..8f03f84ef 100644 --- a/gb.sdl.sound/src/sound.c +++ b/gb.sdl.sound/src/sound.c @@ -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); diff --git a/gb.sdl2/src/audio/gb.sdl2.audio.component b/gb.sdl2/src/audio/gb.sdl2.audio.component index c4046bf44..4c09377b4 100644 --- a/gb.sdl2/src/audio/gb.sdl2.audio.component +++ b/gb.sdl2/src/audio/gb.sdl2.audio.component @@ -1,3 +1,2 @@ [Component] Key=gb.sdl2.audio -Require=gb.sdl2 \ No newline at end of file diff --git a/gb.sdl2/src/audio/main.c b/gb.sdl2/src/audio/main.c index 821fcdb18..37662c7dd 100644 --- a/gb.sdl2/src/audio/main.c +++ b/gb.sdl2/src/audio/main.c @@ -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,13 +54,20 @@ bool AUDIO_init() if (AUDIO_initialized) return FALSE; - if(Mix_OpenAudio(AUDIO_frequency, MIX_DEFAULT_FORMAT, 2, AUDIO_buffer_size)) + 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"); return TRUE; } 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()