Fixed fadeout, completed testAudioHandler. AudioHandler is now done.

merge-requests/1/merge
thmaillarb 4 years ago
parent 8cf39bb99e
commit a4dda9993a

@ -20,7 +20,7 @@ int fadeOut(void* args) {
Mix_Music* music = (Mix_Music*)args;
int ret;
if(Mix_FadeOutMusic(500) == 0) { // Starting the fadeout
if(Mix_FadeOutMusic(500) == 1) { // Starting the fadeout
while (Mix_PlayingMusic()) {
; // Waiting until it's done
}
@ -138,7 +138,7 @@ void playMusic(EnumAudios music, AudioHandler audioHandler) {
// If another music is playing, fading the previous one out
if (Mix_PlayingMusic()) {
// Creating the thread, passing the music as parameter
SDL_Thread* thread = SDL_CreateThread(&fadeOut, "Fade out", (void*)audioHandler.musics[music]);
SDL_Thread* thread = SDL_CreateThread(&fadeOut, "Fade out", audioHandler.musics[music]);
if (thread == NULL) {
fprintf(stderr,"WARNING: couldn't create thread to fade out music\n");
}

@ -29,11 +29,51 @@ void testAudioHandler(void) {
SDL_Delay(5000);
printf("Playing SFX");
printf("Playing SFX\n");
playSFX(SFX_testClick, ah);
SDL_Delay(1000);
SDL_Delay(2000);
printf("Trying to play a music as SFX (playSFX(MUSIC_base_tardi))\n");
playSFX(MUSIC_base_tardi, ah);
printf("Trying to play -1 as SFX\n");
playSFX(-1, ah);
printf("Trying to play 9999 as SFX\n");
playSFX(9999, ah);
printf("Trying to play a SFX as music (playMusic(SFX_testClick))\n");
playMusic(SFX_testClick, ah);
printf("Trying to play -1 as music\n");
playMusic(-1, ah);
printf("Trying to play 9999 as music\n");
playMusic(9999, ah);
printf("Playing louder (vol = 128) the SFX, testing with SFX_testClick\n");
changeSFXVol(128);
playSFX(SFX_testClick, ah);
SDL_Delay(2000);
printf("Playing quieter (vol = 10) the SFX, testing with SFX_testClick\n");
changeSFXVol(10);
playSFX(SFX_testClick, ah);
SDL_Delay(2000);
printf("Waiting another 30 seconds to test loop...\n");
SDL_Delay(30000);
printf("Freeing AudioHandler\n");
freeAudioHandler(&ah);

Loading…
Cancel
Save