MIX_SETTRACKSTOPPEDCALLBACK(3)
π MIX_SetTrackStoppedCallback(3) π
okay bestie, so this one lives in the SDL_mixer3 manual, in the FUNCTIONS section, and it's literally the "hey, that track just stopped!!" notification system. it's giving doorbell energy. π
β¨ NAME β¨
MIX_SetTrackStoppedCallback β set a callback that fires when a MIX_Track is stopped.
πΈ SYNOPSIS πΈ
#include <SDL3_mixer/SDL_mixer.h>
bool MIX_SetTrackStoppedCallback(MIX_Track *track, MIX_TrackStoppedCallback cb, void *userdata);
π¦ DESCRIPTION π¦
so when a track finishes playing β either because it ran out of data to mix (and all the loops were completed too, no sneaky leftover loops), or because your app straight up stopped it β it fires the callback you set right here. iconic behavior honestly.
every track has its own unique callback, no sharing, no borrowing, each track gets its own lil personal one π
passing a NULL callback here? totally legal bestie. it just disables this track's callback. ghosted. π
now listen β pausing a track will not fire the callback. and it also won't fire on a playing track that's being destroyed. so don't go waiting for a ping in either of those situations, it's not coming.
it is legal to adjust the track from inside there, including changing its input and restarting it. and if you do that because it ran out of data mid-mixing, the mixer will start mixing the new track state in its current run without any gap in the audio. seamless. no little silence hiccup. lowkey gorgeous. πβ¨
π FUNCTION PARAMETERS π
trackβ the track we're assigning this callback to. the main character of this operation.cbβ the function to call when the track stops. may beNULL.userdataβ an opaque pointer handed off to the callback for its own personal use. it's the lil goodie bag, we don't look inside. π
β RETURN VALUE β
returns true on success or false on failure β and if it fails, call SDL_GetError() for more info. fr fr, always go check the error.
π AVAILABILITY π
this function has been available since SDL-mixer 3.0.0. it's been doing its thing for a minute.
π SEE ALSO π
k that's the whole page bestie, go set some callbacks and slay π«Άβ¨
SDL_mixer β SDL_mixer 3.2.4 β signing off π mwah, no cap, this manual page ate and left no crumbs π
π¦ where this page comes from
- fedora 44: SDL3_mixer-doc 3.2.4-3.fc44 Β· Zlib AND (GPL-2.0-or-later OR LGPL-2.0-or-later)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms