[SDL] SDL_mixer
Ryan C. Gordon
icculus at clutteredmind.org
Sat Feb 23 16:34:01 PST 2002
> In the channel_complete_callback(int chan) I call then
> Mix_FreeChunk(...) But this function is a callback function and
> supposely in another thread. So it is possible that first
> Mix_CloseAudio() and SDL_QuitSubSystem(...) are called before. If then
> Mix_FreeChunk(..) does not work, the program creates big memory leaks,
> which I certainly do not want to have.
When you call Mix_CloseAudio(), it halts all the playing channels and
calls their "done" callbacks before returning. It is safe to call
Mix_FreeChunk() in these callbacks. You do not need to explicitly call
Mix_HaltChannel() before Mix_CloseAudio(), since it will be done for you.
(As an aside, by the luck of the current code's design, you CAN call
Mix_FreeChunk after even SDL_Quit(), and it will work, but you should NOT
rely on this behaviour.)
--ryan.
More information about the SDL
mailing list