use same error status for mixer

This commit is contained in:
Mylloon 2023-05-03 21:05:06 +02:00
parent 77b584d89f
commit 2c205a2b97
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -1,12 +1,14 @@
#include "../includes/audio.h"
#include "SDL_mixer.h"
#include <stdio.h>
// Stocke les données à propos de la musique
static double average;
// Channel son utilisé
static int _channel;
// Code utilisé en tant qu'erreur de SDL_Mixer
static int _errStatus = 2;
double averageMusic(void) { return average; }
void callback(void *_, Uint8 *stream, int size) {
@ -20,25 +22,25 @@ void callback(void *_, Uint8 *stream, int size) {
void initMusic(Mix_Chunk *music, const char *filename) {
if (!Mix_Init(MIX_INIT_MID)) {
fprintf(stderr, "Erreur Mix_Init\n");
exit(2);
fprintf(stderr, "Erreur Mix_Init - Chargement des librairies dynamiques\n");
exit(_errStatus);
}
if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 1, 2048)) {
fprintf(stderr, "Erreur Mix_OpenAudio\n");
exit(2);
exit(_errStatus);
};
if (!(music = Mix_LoadWAV(filename))) {
fprintf(stderr, "Erreur Mix_LoadWAV for '%s'\n", filename);
exit(2);
fprintf(stderr, "Erreur Mix_LoadWAV en chargant '%s'\n", filename);
exit(_errStatus);
}
Mix_SetPostMix(callback, NULL);
if ((_channel = Mix_PlayChannel(-1, music, -1)) == -1) {
fprintf(stderr, "Erreur Mix_PlayChannel\n");
exit(2);
fprintf(stderr, "Erreur Mix_PlayChannel - Le son n'as pas pu être joué\n");
exit(_errStatus);
};
}