joyrider
Active Member
I'm using mod files as my music files and for some strange reason i have to set the volume of the music everytime after the mod file starts playing (mix_playmusic). when i use ogg files i just can call the setvolume function once and it stays the exact same volume but with mods it doesn't it keeps reverting back to max volume when the music starts playing again / loops. even when calling mix_playmusic(musix,-1) it will play it once at the set volume and then revert back. Pretty weird ...
anyway i found a way around it by using the mix_hookmusicfinished and a callback function for it where i start the music again and also set the volume (so i'm using mix_playmusic(musix,0) to play it once).
anyway this seems to work like a charm however am i bit concerned
when looking up the mix_hookmusicfinished function on google i found numerous pages where they said that it's a bad idea to call sdl_mixer functions from within a callback function see here :http://jonatkins.org/SDL_mixer/SDL_mixer_63.html or here : http://jcatki.no-ip.org/SDL_mixer/SDL_mixer.html#SEC5
(just what i'm doing now to fix the issue).
does anyone have a clue why this is a bad idea ? cause it does seem to work without any problems as far as i can tell. and it's the only way i can think of to fix that volume problem when looping the music.
found a way around it could have used just a boolean flag and restarted the music somewhere else outside the callback.
however i think it still isn't normal that u have to call the volume function each time the music starts playing again and that it will only play it at the specified volume during the first loop when calling mix_playmusic(music,-1) (-1 for looping)
when using ogg's this problem doesn't even exist
anyway i found a way around it by using the mix_hookmusicfinished and a callback function for it where i start the music again and also set the volume (so i'm using mix_playmusic(musix,0) to play it once).
anyway this seems to work like a charm however am i bit concerned
when looking up the mix_hookmusicfinished function on google i found numerous pages where they said that it's a bad idea to call sdl_mixer functions from within a callback function see here :http://jonatkins.org/SDL_mixer/SDL_mixer_63.html or here : http://jcatki.no-ip.org/SDL_mixer/SDL_mixer.html#SEC5
(just what i'm doing now to fix the issue).
does anyone have a clue why this is a bad idea ? cause it does seem to work without any problems as far as i can tell. and it's the only way i can think of to fix that volume problem when looping the music.
found a way around it could have used just a boolean flag and restarted the music somewhere else outside the callback.
however i think it still isn't normal that u have to call the volume function each time the music starts playing again and that it will only play it at the specified volume during the first loop when calling mix_playmusic(music,-1) (-1 for looping)
when using ogg's this problem doesn't even exist