Adding a QueueAudio function to SDL_Mixer?

Hi all,

Here’s my situation: I’ve got several Mix_Chunk objects that comprise a repetitive piece of music, each falling under the category of either Drums, Bass, or Lead. For each of those three I have what you could call redundant variations, i.e a slightly different drum pattern / lead melody, and I’d like to be able to randomly switch between variations of the music by “queuing up” a random chunk to play on some channel once that channel’s chunk is done.

This kind of thing seems feasible using the SDL_QueueAudio function introduced in 2.0.4 (or using the callback member of SDL_AudioSpec), but SDL_Mixer doesn’t seem to have any sort of equivalent. The closest thing I could find was setting a callback using Mix_ChannelFinished. However, the documentation states that the callback is not a suitable place to call any audio functions, which includes calling Mix_PlayChannel and playing a new chunk. Furthermore I’d prefer not to wait until the chunk finishes to let the audio thread know that I want something to play so as to prevent timing issues with my music.

Is there any machinery inside SDL_Mixer to do this kind of think (queue up chunks to be played on some channel before that channel has finished?) If not I suppose I could mix the audio myself and use SDL_QueueAudio, but I thought I’d ask here.