Mix_HookMusic() and SDL_MixAudio()

This is probably a silly question, but is it safe to call SDL_MixAudio() from a callback function set using Mix_HookMusic()?

The SDL_mixer code itself would seem to indicate that it’s safe, but the documentation says it’s a ‘bad idea’ to call SDL audio functions from a callback. The documentation for Mix_HookMusic() itself is a little more specific, stating only that you shouldn’t call SDL_LockAudio() from a callback.

I’m currently calling SDL_MixAudio() from the callback and haven’t had any problems, but I’d be more comfortable knowing for certain that it’s a safe thing to do.

Thanks,
Jesse

Yes, it’s fine. SDL_MixAudio() doesn’t have any side effects or
external inputs.On Sat, Sep 19, 2009 at 11:10 AM, Jesse A. wrote:

This is probably a silly question, but is it safe to call SDL_MixAudio()
from a callback function set using Mix_HookMusic()?

The SDL_mixer code itself would seem to indicate that it’s safe, but the
documentation says it’s a ‘bad idea’ to call SDL audio functions from a
callback. The documentation for Mix_HookMusic() itself is a little more
specific, stating only that you shouldn’t call SDL_LockAudio() from a
callback.

I’m currently calling SDL_MixAudio() from the callback and haven’t had any
problems, but I’d be more comfortable knowing for certain that it’s a safe
thing to do.

Thanks,
Jesse


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

Yes, it’s fine. SDL_MixAudio() doesn’t have any side effects or external inputs.

Thanks for your reply :slight_smile: I figured that was probably the case, but it’s nice to have it confirmed.