| Summary: | FadeInChannel/FadeOutChannel can corrupt volume level. | ||
|---|---|---|---|
| Product: | SDL_mixer | Reporter: | Joe Keen <joekeen+sdlbugzilla> |
| Component: | misc | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 1.2.8 | ||
| Hardware: | x86 | ||
| OS: | All | ||
Ryan, can you take a look at this? Thanks! Fixed in svn revision #5047. Please note that the channel's volume is changing during the fade, so if you call Mix_Volume(channel, -1) while the fade is progressing, you'll get changing values, but now the final volume is reset correctly at the end of the fade. Also note that if you change the Mix_Volume() during the fade, it'll ignore this (next run of the audio callback changes it, end of the fade resets it). This is how it worked before this patch, too. --ryan. |
When Mix_FadeInChannel is called Mix_Channel.fade_volume is set to the current volume and Mix_Channel.volume is set to 0. If Mix_FadeOutChannel is called prior to Mix_FadeInChannel finishing it sets Mix_Channel.fade_volume to the current volume rather than the desired volume for that channel. When Mix_FadeOutChannel is finished it uses that fade_volume attribute to reset the volume on the channel. The following program reproduces the problem. #include <stdio.h> #include <unistd.h> #include <SDL/SDL_mixer.h> bool done = false; void channelFinished(int channel) { done = true; } int main() { Mix_OpenAudio(48000, MIX_DEFAULT_FORMAT, 2, 512); Mix_ChannelFinished(channelFinished); Mix_AllocateChannels(50); Mix_Volume(-1,MIX_MAX_VOLUME); Mix_Chunk *chunk = Mix_LoadWAV("/tmp/foo.wav"); printf("volume start: %i\n",Mix_Volume(1,-1)); Mix_FadeInChannel(1,chunk,-1,5000); sleep(1); Mix_FadeOutChannel(1,500); while(!done) { usleep(10); } printf("volume end: %i\n",Mix_Volume(1,-1)); }