MIX_StopAllTracks(3)

πŸ“¦
version 3.2.4 Β· 2 versions
, in fedora 44

πŸ’– MIX_StopAllTracks(3) β€” from the SDL_mixer3 FUNCTIONS girlies πŸ’–

okay bestie, sit down, we're talking about MIX_StopAllTracks from SDL_mixer ✨ this one's a classic.


✨ NAME ✨

MIX_StopAllTracks β€” halt every single track that's currently playing, and if you want, let them fade out over time like the dramatic main characters they are πŸŽ€


✨ SYNOPSIS ✨

#include <SDL3_mixer/SDL_mixer.h>

bool MIX_StopAllTracks(MIX_Mixer *mixer, Sint64 fade_out_ms);

✨ DESCRIPTION ✨

so here's the tea πŸ“ if fade_out_ms is greater than 0, the tracks do not stop mixing right away. instead they fade to silence over that many milliseconds, and then they stop. it's giving graceful exit, no cap πŸ’…

and lowkey important: this is different from MIX_StopTrack(), which wants sample frames. this function takes milliseconds because different tracks might have different sample rates β€” so milliseconds is the only unit that's fair to everyone. periodt 🫢

if a track ends normally while the fade-out is still in progress, the audio just stops there. the fade is not shortened to fit β€” even if the fade would last longer than the audio that's left, it doesn't get adjusted. it just... is what it is 🌸

once a track has finished any fadeout and come to a stop, it will call its MIX_TrackStoppedCallback, if any. and yes, it is legal to assign the track a new input and/or restart it during this callback β€” go off, you're allowed πŸ¦‹

also, this function does not block new play requests from being made. it is completely legal to use this function to start fading all the currently-playing tracks, and then start other tracks playing normally while those fade-outs are still in progress. iconic behavior honestly ✨


✨ FUNCTION PARAMETERS ✨

  • mixer β€” the mixer on which to stop all tracks. the one running the whole situation πŸ’œ
  • fade_out_ms β€” the number of milliseconds to spend fading out to silence before halting. use 0 to stop immediately, no fade, just gone πŸ’€

✨ RETURN VALUE ✨

returns true on success, false on error πŸ₯² if it fails, call SDL_GetError() for the details β€” it will tell you what went wrong, fr fr.


✨ THREAD SAFETY ✨

it is safe to call this function from any thread. yes gurl, any thread. go wild πŸ”₯


✨ AVAILABILITY ✨

this function is available since SDL_mixer 3.0.0 πŸ‘‘


✨ SEE ALSO ✨


and that's the whole page bestie, you ate that πŸŽ€ this was the SDL_mixer manual, SDL_mixer 3.2.4 era, no cap πŸ’– bye ily, go stop some tracks 🌈⭐

πŸ“¦ where this page comes from