It's not stated in the documentation, so I'd like to ask if anyone knows if it's ok to halt a channel (via Mix_HaltChannel()) that's been already halted?

I'm asking 'cause I'd like to halt every channel with Mix_HaltChannel(-1)(which could possibly include already halted channels) before freeing the chunks for safety reasons, because the documentation states that it's not good to free chunks of channels that are still playing.

Thanks a lot in advance.


1 Answer 1


Yes, looking quickly through the source of SDL_Mixer it does seem like doing this is safe.

The code essentially flows as the following:

  • Is the channel the call wants to halt -1?
    • If yes, call Mix_HaltChannel on all channels.
    • If no do the following:
      • Is the wanted channel still playing?
        • If yes, stop the audio.
      • Handle fading.

So as you can see, the code actually handles the case where the channel is already halted. If you want to check it yourself, Mix_HaltChannel can be found in mixer.c, starting on line 1042.

  • \$\begingroup\$ Where can I actually find mixer.c? \$\endgroup\$ Commented Dec 12, 2016 at 20:44
  • \$\begingroup\$ In the source code for SDL_Mixer, downloadable from here. \$\endgroup\$
    – user35344
    Commented Dec 12, 2016 at 20:54
  • \$\begingroup\$ @zeldahyrule Was your question answered? If it was, please accept this answer so that others can find help more easily in the future. \$\endgroup\$
    – user35344
    Commented Dec 21, 2016 at 15:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .