MIX_CreateAudioDecoder_IO(3)

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

πŸ’– MIX_CreateAudioDecoder_IO β€” the SDL_mixer3 glow-up πŸ’–

okay bestie, we're in the SDL_mixer3 FUNCTIONS section and today's main character is MIX_CreateAudioDecoder_IO(3). it literally makes you a MIX_AudioDecoder out of an SDL_IOStream. no cap. ✨


🌸 NAME 🌸

MIX_CreateAudioDecoder_IO β€” create a MIX_AudioDecoder from an SDL_IOStream. that's the whole vibe. πŸ¦‹


✨ SYNOPSIS ✨

#include <SDL3_mixer/SDL_mixer.h>

MIX_AudioDecoder * MIX_CreateAudioDecoder_IO(SDL_IOStream *io, bool closeio, SDL_PropertiesID props);

look at that signature. iconic. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

so here's the tea: most apps do NOT need this. SDL_mixer's usual interfaces will decode audio as needed, they got you. πŸ™Œ

BUT. if you wanna decode an audio file into a memory buffer without playing it? that's the moment. this interface is giving exactly that energy. it's for when you just want the decoded data and you're not trying to make any noise. 🀫

this function lets you specify properties too, which is intended to supply file-specific settings β€” like where to find SoundFonts for a MIDI file, etc. most of the properties available to MIX_LoadAudioWithProperties() apply here, too. and in most cases, the caller should pass a zero to specify no extra properties. zero. nothing. quiet luxury. 🀌

okay now pay attention because this one matters: if closeio is true, then io will be closed when this decoder is done with it. and if this function fails and closeio is true, then io will be closed before this function returns. so it's closed either way, bestie. plan accordingly. πŸ’€

when you're done with the audio decoder, it can be destroyed with MIX_DestroyAudioDecoder(). clean up after yourself, it's the rule. 🧹

one more thing: this function requires SDL_mixer to have been initialized with a successful call to MIX_Init(). but β€” plot twist β€” it does NOT need an actual MIX_Mixer to have been created. decoder stays unbothered. un-mixed. unstoppable. πŸ‘‘


🌈 FUNCTION PARAMETERS 🌈

  • io β€” the i/o stream from which to load data. your source of truth, your supply. πŸ“
  • closeio β€” if true, close the i/o stream when done with it. (yes, that close. the one from above. bye bye stream πŸ‘‹)
  • props β€” decoder-specific properties. may be zero. zero is a perfectly valid slay. ✨

⭐ RETURN VALUE ⭐

returns an audio decoder, ready to decode. it arrives prepped, primped, and prepared. periodt. πŸ’…


🧚 THREAD SAFETY 🧚

it is safe to call this function from any thread. any. thread. no exclusivity drama, no jealousy, no locks in your feelings. 🫢


πŸ’œ AVAILABILITY πŸ’œ

this function is available since SDL_mixer 3.0.0. it's been here, it's been thriving. πŸ‘‘


πŸ”₯ SEE ALSO πŸ”₯

go read those too, iykyk. πŸ“š


and that's the whole page, bestie β€” brought to you by SDL_mixer 3.2.4, the version that ate and left no crumbs. mwah. πŸŽ€πŸ’–βœ¨πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from