We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4770

Summary: Mix_FadeOutChannel never sets fade_volume_reset causing faded out chunks to have volume reset incorrectly
Product: SDL_mixer Reporter: birk.kevin
Component: miscAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: shadowm, sylvain.becker
Version: 2.0.4   
Hardware: x86_64   
OS: Linux   

Description birk.kevin 2019-08-21 01:20:33 UTC
The following code at line 1155 in mixer.c ensures that the conditional to set fade_volume_reset can never be true.

    mix_channel[which].fade_volume = mix_channel[which].volume;
    mix_channel[which].fading = MIX_FADING_OUT;
    mix_channel[which].fade_length = (Uint32)ms;
    mix_channel[which].ticks_fade = SDL_GetTicks();

    /* only change fade_volume_reset if we're not fading. */
    if (mix_channel[which].fading == MIX_NO_FADING) {
        mix_channel[which].fade_volume_reset = mix_channel[which].volume;
    }

The `mix_channel[which].fading = MIX_FADING_OUT;` must be moved after the `if` statement.
Comment 1 Sylvain 2019-08-21 07:32:28 UTC
Thanks ! It's here: https://hg.libsdl.org/SDL_mixer/rev/c8ae0feb801e

I also modified the Mix_FadeInChannel
because when playing on the same channel while fading, it was saving the fading volume.

Please give a try !
Comment 2 Sylvain 2019-08-22 07:05:48 UTC
*** Bug 4205 has been marked as a duplicate of this bug. ***