MIX_SETTRACKSTOPPEDCALLBACK(3)

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

πŸ’– 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 be NULL.
  • 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