Add stream data
This commit is contained in:
parent
e945126117
commit
6a22f68259
2 changed files with 29 additions and 1 deletions
|
@ -8,7 +8,13 @@
|
||||||
// Charge et lance la musique
|
// Charge et lance la musique
|
||||||
void initialisationMusique(Mix_Music *, const char *);
|
void initialisationMusique(Mix_Music *, const char *);
|
||||||
|
|
||||||
// Libère la musique de la mémoire
|
// Renvoie le stream de la musique
|
||||||
|
Uint8 *musiqueStream(void);
|
||||||
|
|
||||||
|
// Renvoie la taille du stream de la musique
|
||||||
|
int musiqueStreamTaille(void);
|
||||||
|
|
||||||
|
// Libère la musique en mémoire
|
||||||
void liberationMusique(Mix_Music *);
|
void liberationMusique(Mix_Music *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
22
src/audio.c
22
src/audio.c
|
@ -2,12 +2,34 @@
|
||||||
|
|
||||||
#include "../includes/audio.h"
|
#include "../includes/audio.h"
|
||||||
|
|
||||||
|
// Stocke les données à propos de la musique
|
||||||
|
struct infos {
|
||||||
|
Uint8 *stream;
|
||||||
|
int taille;
|
||||||
|
} musique_infos;
|
||||||
|
|
||||||
|
Uint8 *musiqueStream(void) {
|
||||||
|
return musique_infos.stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
int musiqueStreamTaille(void) {
|
||||||
|
return musique_infos.taille;
|
||||||
|
}
|
||||||
|
|
||||||
|
void callback(void *_, Uint8 *stream, int taille) {
|
||||||
|
(void)_;
|
||||||
|
|
||||||
|
musique_infos.stream = stream;
|
||||||
|
musique_infos.taille = taille;
|
||||||
|
}
|
||||||
|
|
||||||
void initialisationMusique(Mix_Music *musique, const char *filename) {
|
void initialisationMusique(Mix_Music *musique, const char *filename) {
|
||||||
Mix_Init(MIX_INIT_MID);
|
Mix_Init(MIX_INIT_MID);
|
||||||
Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 1024);
|
Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 1024);
|
||||||
musique = Mix_LoadMUS(filename);
|
musique = Mix_LoadMUS(filename);
|
||||||
|
|
||||||
Mix_VolumeMusic(MIX_MAX_VOLUME / 10);
|
Mix_VolumeMusic(MIX_MAX_VOLUME / 10);
|
||||||
|
Mix_SetPostMix(callback, NULL);
|
||||||
|
|
||||||
Mix_PlayMusic(musique, 1);
|
Mix_PlayMusic(musique, 1);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue