X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fsound.c;h=1decace8a353c023aca13416de5a11297d76023a;hb=1280ea87a3b13fcadcc3d6767f89cd274e2e6a4a;hp=87d1e90ec7a957221f58f55fb52bb9377cc87576;hpb=a6e764aab14a8157ba5b59c3d271a2073f9eae80;p=supertux.git diff --git a/src/sound.c b/src/sound.c index 87d1e90ec..1decace8a 100644 --- a/src/sound.c +++ b/src/sound.c @@ -31,16 +31,31 @@ #ifndef NOSOUND +/* --- OPEN THE AUDIO DEVICE --- */ + +int open_audio (int frequency, Uint16 format, int channels, int chunksize) +{ + if (use_sound) { + return Mix_OpenAudio( frequency, format, channels, chunksize ); + } + else { + // let the user think that the audio device was correctly opened + // and keep the compiler happy :-D + return 0; + } +} + + /* --- LOAD A SOUND --- */ Mix_Chunk * load_sound(char * file) { Mix_Chunk * snd; - + if (use_sound) { snd = Mix_LoadWAV(file); - + if (snd == NULL) st_abort("Can't load", file); } @@ -72,34 +87,36 @@ Mix_Music * load_song(char * file) /* --- PLAY A SOUND --- */ - - void playsound(Mix_Chunk * snd) + + void play_sound(Mix_Chunk * snd) { // this won't call the function if the user has disabled sound if (use_sound) { Mix_PlayChannel(-1, snd, 0); } } - - + + void free_chunk(Mix_Chunk *chunk) { - if (use_sound) + if (use_sound) { + DEBUG_MSG( __PRETTY_FUNCTION__ ); Mix_FreeChunk( chunk ); + } } - + int playing_music(void) { - if (use_sound) { + if (use_sound) { return Mix_PlayingMusic(); } else { - // we are in --disable-sound or NOSOUND, we can't be playing music ! + /* we are in --disable-sound we can't be playing music */ return 0; } } - + int halt_music(void) { if (use_sound) { @@ -109,37 +126,39 @@ int halt_music(void) return 0; } } - - + + int play_music(Mix_Music *music, int loops) { if (use_sound) { + DEBUG_MSG(__PRETTY_FUNCTION__); return Mix_PlayMusic(music, loops); } else { - // return error since you're trying to play music in --disable-sound mode + /* return error since you're trying to play music in --disable-sound mode */ return -1; } } - + void free_music(Mix_Music *music) { - if (use_sound) + if (use_sound) { + DEBUG_MSG(__PRETTY_FUNCTION__); Mix_FreeMusic( music ); + } } #else +int open_audio (int frequency, int format, int channels, int chunksize) +{ + return -1; +} + void* load_sound(void* file) { return NULL; } -void playsound(void * snd) {} +void play_sound(void * snd) {} void* load_song(void* file) { return NULL; } -int Mix_PlayingMusic() { return 0; } -void Mix_HaltMusic() {} -int Mix_PlayMusic() { return -1; } -void Mix_FreeMusic() {} -void Mix_FreeChunk() {} -int Mix_OpenAudio(int a, int b, int c, int d) { return -1; } int playing_music() { return 0; } void halt_music() {}