diff --git a/src/audio.c b/src/audio.c index 98866bc..9b6e33c 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1,4 +1,5 @@ #include "../includes/audio.h" +#include // Stocke les données à propos de la musique static double average; @@ -16,13 +17,22 @@ void callback(void *_, Uint8 *stream, int size) { void initMusic(Mix_Music *music, const char *filename) { Mix_Init(MIX_INIT_MID); - Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 1024); - music = Mix_LoadMUS(filename); + if (Mix_OpenAudio(44100, AUDIO_S16LSB, 1, 1024)) { + fprintf(stderr, "Erreur Mix_OpenAudio\n"); + exit(2); + }; + if (!(music = Mix_LoadMUS(filename))) { + fprintf(stderr, "Erreur Mix_LoadMUS\n"); + exit(2); + } Mix_VolumeMusic(MIX_MAX_VOLUME / 10); Mix_SetPostMix(callback, NULL); - Mix_PlayMusic(music, 1); + if (Mix_PlayMusic(music, 1)) { + fprintf(stderr, "Erreur Mix_PlayMusic\n"); + exit(2); + }; } void freeMusic(Mix_Music *music) {