Bug in SDL_mixer-1.2.4

Hi all,

I think I have discovered a small bug in the SDL_mixer library, v.1.2.4
(file SDL_mixer-1.2.4/mixer.c, line 178) :

diff -ur SDL_mixer-1.2.4/mixer.c mySDL_mixer-1.2.4/mixer.c
— SDL_mixer-1.2.4/mixer.c Sun May 19 22:50:35 2002
+++ mySDL_mixer-1.2.4/mixer.c Wed Jun 12 11:54:04 2002
@@ -175,7 +175,7 @@
if( mix_channel[i].fading ==
MIX_FADING_OUT ) {
mix_channel[i].playing = 0;
mix_channel[i].expire = 0;

  •                                           Mix_Volume(i, 
    

mix_channel[i].fading); /* Restore the volume */

  •                                           Mix_Volume(i, 
    

mix_channel[i].fade_volume); /* Restore the volume */
}
mix_channel[i].fading = MIX_NO_FADING;
} else {

Mix_Volume is given as 2nd argument the ‘fading’ field of the _Mix_Channel
struct, which is of type enum Mix_Fading. But this 2nd arg is interpreted
as a volume value, so the volume of this channel will always be set to 1
(MIX_FADING_OUT) !
So if you want to play another sample later on on the same channel, without
setting the volume explicitly using Mix_Volume, it will be inaudible. And
if you use Mix_FadeInChannel instead of Mix_PlayChannel, the volume may
sometimes even become 0 (because of rounding imprecisions in the volume
fading computation, I assume), and in that case it becomes impossible to
stop the channel using Mix_FadeOut, because if the volume is 0 Mix_FadeOut
does nothing and the channel is never made available again…

I assume it is the fade_volume field that must be given instead, to restore
the volume to the value it had when the fading out started. I tried this
correction in my program, and it works right for me.

Hope this helps…

Willy

Xavier Wielemans - alterface
http://www.alterface.com
phone +32 10 47 41 05
fax +32 10 47 20 89

Mix_Volume is given as 2nd argument the ‘fading’ field of the _Mix_Channel
struct, which is of type enum Mix_Fading. But this 2nd arg is interpreted
as a volume value, so the volume of this channel will always be set to 1
(MIX_FADING_OUT) !

This patch has been applied to CVS. Thanks!

–ryan.