Play a MIX_Audio from start to finish without any management.
Defined in <SDL3_mixer/SDL_mixer.h>
bool MIX_PlayAudio(MIX_Mixer *mixer, MIX_Audio *audio);
MIX_Mixer * | mixer | the mixer on which to play this audio. |
MIX_Audio * | audio | the audio input to play. |
(bool) Returns true if the track has begun mixing, false on error; call SDL_GetError() for details.
This is what we term a "fire-and-forget" sound. Internally, SDL_mixer will manage a temporary track to mix the specified MIX_Audio, cleaning it up when complete. No options can be provided for how to do the mixing, like MIX_PlayTrack() offers, and since the track is not available to the caller, no adjustments can be made to mixing over time.
This is not the function to build an entire game of any complexity around, but it can be convenient to play simple, one-off sounds that can't be stopped early. An example would be a voice saying "GAME OVER" during an unpausable endgame sequence.
There are no limits to the number of fire-and-forget sounds that can mix at once (short of running out of memory), and SDL_mixer keeps an internal pool of temporary tracks it creates as needed and reuses when available.
It is safe to call this function from any thread.
This function is available since SDL_mixer 3.0.0.