My fix for this reported issue... --ryan.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 06 Mar 2008 15:02:39 +0000
changeset 3830d05ac848d6a
parent 382 50501e45c57b
child 384 51d7d7729faf
My fix for this reported issue... --ryan.

Subject: Bug in SDL_mixer
Date: Thu, 6 Mar 2008 16:46:45 +1300
From: Karl Hendrikse
To: jcatki@jcatki.no-ip.org

I really don't know if I'm sending this to anywhere near the right
person, but I believe I have found a bug in SDL_mixer.

In mixer.c, in the mix_channels function, line 190 should be moved
outside the if statement. This will reset the volume of a channel at the
end of any fade, not just after a fade out.

The way the code works now assumes the volume will always be correct at
the end of a fade in, but in reality it will usually never get there
because the last time the volume gets updated, the fade is not quite
complete (ie. the volume is always up to one frame behind where it would
ideally be). This issue gets worse as the fadein time decreases (since
the jump in volume each iteration is greater).
mixer.c
     1.1 --- a/mixer.c	Wed Feb 27 07:31:03 2008 +0000
     1.2 +++ b/mixer.c	Thu Mar 06 15:02:39 2008 +0000
     1.3 @@ -186,10 +186,10 @@
     1.4  			} else if ( mix_channel[i].fading != MIX_NO_FADING ) {
     1.5  				Uint32 ticks = sdl_ticks - mix_channel[i].ticks_fade;
     1.6  				if( ticks > mix_channel[i].fade_length ) {
     1.7 +				    Mix_Volume(i, mix_channel[i].fade_volume); /* Restore the volume */
     1.8  					if( mix_channel[i].fading == MIX_FADING_OUT ) {
     1.9  						mix_channel[i].playing = 0;
    1.10  						mix_channel[i].expire = 0;
    1.11 -						Mix_Volume(i, mix_channel[i].fade_volume); /* Restore the volume */
    1.12  						_Mix_channel_done_playing(i);
    1.13  					}
    1.14  					mix_channel[i].fading = MIX_NO_FADING;