| Summary: | Mix_Chunk loop/callback error with samples of certain lengths | ||
|---|---|---|---|
| Product: | SDL_mixer | Reporter: | Jesse Anders <jesseanders> |
| Component: | misc | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | jesseanders |
| Version: | unspecified | ||
| Hardware: | PowerPC | ||
| OS: | Mac OS X 10.4 (Intel) | ||
| Attachments: | Audio sample | ||
Created attachment 197 [details]
Audio sample
Here is the audio sample as an attachment.
This is fixed in subversion revision 3277, thanks! This was a great test case, BTW. |
In the mix_channels() function, it appears that looping and playback termination behaves incorrectly when the length of the sample is an even multiple of the value of the 'len' argument. When the 'loop' argument to Mix_PlayChannel() is > 0, the sound plays back one fewer times than requested, and the callback is not called when the sound finishes playing. Here is a short program that demonstrates this behavior: /******************************************************************************/ #include "SDL.h" #include "SDL_mixer.h" #include <iostream> void Callback(int) { std::cout << "Callback() was called." << std::endl; } int main(int argc, char *argv[]) { SDL_Init(SDL_INIT_AUDIO); Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024); Mix_ChannelFinished(Callback); std::cout << "\nPlaying sample with loop = 1: Should play twice, but\n" << "will only play once and callback will not be called.\n\n" << "(Press any key followed by enter to quit)" << std::endl; Mix_Chunk* sound = Mix_LoadWAV("sdl_mixer_bug.wav"); Mix_PlayChannel(-1, sound, 1); std::cin.get(); Mix_FreeChunk(sound); Mix_CloseAudio(); SDL_Quit(); return 0; } /******************************************************************************/ Here is the URL of the audio file used: http://cmldev.net/wp-content/uploads/2007/03/sdl_mixer_bug.wav The length of this particular sample is 98304, which is an even multiple of 4096, the value I get for the mix_channels() 'len' argument when the buffer size is set to 1024. I'm using SDL_mixer 1.2.7 in OS X 10.4.8.