SDL Mixer, error where a channel ends before it finishes fading out

In SDL Mixer if you play a sound on a channel, then set it to fade out
after a period of time say 1000 ms.
If the channel finishes before the fade out time period is reached then
it will run the call back function, but it will still have the
MIX_FADING_OUT flag set.
This means that it will continue to fade the channel out (setting the
volume), even though the channel has stopped playing, when the channel
has finished fading out it will then call the call back function again
for that channel.

This can cause all kinds of errors as the call back function is called
twice, and is easily solved by setting the fading flag to MIX_NO_FADING
if the channel finishes before the fade out time is reached.

Simple fix was chaging :
if (!mix_channel[i].playing && !mix_channel[i].looping) {
_Mix_channel_done_playing(i);
}
to:
if (!mix_channel[i].playing && !mix_channel[i].looping) {
_Mix_channel_done_playing(i);
mix_channel[i].fading = MIX_NO_FADING;
}
in mixer.c

OMG this took way too long for me to locate, and has been causing me a
headache for weeks.

Mark Castell
Happy Fun