use same error status for mixer
This commit is contained in:
parent
77b584d89f
commit
2c205a2b97
1 changed files with 11 additions and 9 deletions
20
src/audio.c
20
src/audio.c
|
@ -1,12 +1,14 @@
|
||||||
#include "../includes/audio.h"
|
#include "../includes/audio.h"
|
||||||
#include "SDL_mixer.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
// Stocke les données à propos de la musique
|
// Stocke les données à propos de la musique
|
||||||
static double average;
|
static double average;
|
||||||
|
|
||||||
|
// Channel son utilisé
|
||||||
static int _channel;
|
static int _channel;
|
||||||
|
|
||||||
|
// Code utilisé en tant qu'erreur de SDL_Mixer
|
||||||
|
static int _errStatus = 2;
|
||||||
|
|
||||||
double averageMusic(void) { return average; }
|
double averageMusic(void) { return average; }
|
||||||
|
|
||||||
void callback(void *_, Uint8 *stream, int size) {
|
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) {
|
void initMusic(Mix_Chunk *music, const char *filename) {
|
||||||
if (!Mix_Init(MIX_INIT_MID)) {
|
if (!Mix_Init(MIX_INIT_MID)) {
|
||||||
fprintf(stderr, "Erreur Mix_Init\n");
|
fprintf(stderr, "Erreur Mix_Init - Chargement des librairies dynamiques\n");
|
||||||
exit(2);
|
exit(_errStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 1, 2048)) {
|
if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 1, 2048)) {
|
||||||
fprintf(stderr, "Erreur Mix_OpenAudio\n");
|
fprintf(stderr, "Erreur Mix_OpenAudio\n");
|
||||||
exit(2);
|
exit(_errStatus);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!(music = Mix_LoadWAV(filename))) {
|
if (!(music = Mix_LoadWAV(filename))) {
|
||||||
fprintf(stderr, "Erreur Mix_LoadWAV for '%s'\n", filename);
|
fprintf(stderr, "Erreur Mix_LoadWAV en chargant '%s'\n", filename);
|
||||||
exit(2);
|
exit(_errStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mix_SetPostMix(callback, NULL);
|
Mix_SetPostMix(callback, NULL);
|
||||||
|
|
||||||
if ((_channel = Mix_PlayChannel(-1, music, -1)) == -1) {
|
if ((_channel = Mix_PlayChannel(-1, music, -1)) == -1) {
|
||||||
fprintf(stderr, "Erreur Mix_PlayChannel\n");
|
fprintf(stderr, "Erreur Mix_PlayChannel - Le son n'as pas pu être joué\n");
|
||||||
exit(2);
|
exit(_errStatus);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue