SDL_CreateAudioStream(3)

✨ SDL_CreateAudioStream ✨

okay so bestie, this is a page from the SDL3 FUNCTIONS manual (yes the manual name is literally part of the header, i'm folding it in here so it doesn't get lost πŸ’–) and today we're learning how to make a whole new audio stream. it's giving "birth of a vibe" honestly.


🌸 NAME 🌸

SDL_CreateAudioStream β€” Create a new audio stream.

like literally, you're manifesting a stream of audio out of thin air πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_audio.h>

SDL_AudioStream * SDL_CreateAudioStream(const SDL_AudioSpec *src_spec, const SDL_AudioSpec *dst_spec);

πŸ’… DESCRIPTION πŸ’…

so here's the tea, and you need to hear it: src_spec or dst_spec may be NULL, no big deal, no drama. BUT β€” and this is the important part β€” any attempts to put or get data from an audio stream will fail until it has valid specs assigned to both ends of the stream. both ends, bestie. both. 🫢

and no, you're not stuck forever! specs can be assigned later through SDL_SetAudioStreamFormat(), or by binding the stream to an audio device. and lowkey here's the detail that matters: binding will set the format of only the input or output, depending on what kind of device the stream was bound to. not both. just one. iykyk πŸ‘‘


🌈 FUNCTION PARAMETERS 🌈

  • src_spec β€” the format details of the input audio. May be NULL.
  • dst_spec β€” the format details of the output audio. May be NULL.

see? told you. both of them can just be NULL and the function will still hand you a stream. it's chill like that. πŸ’œ


⭐ RETURN VALUE ⭐

Returns a new audio stream on success ✨ or NULL on failure 😭; call SDL_GetError() for more information.

no cap: if you get NULL back, go read SDL_GetError() immediately. don't sit there guessing, the answer is right there.

🧚 THREAD SAFETY 🧚

It is safe to call this function from any thread.

periodt. go wild, call it from wherever. πŸ”₯


πŸ¦‹ AVAILABILITY πŸ¦‹

This function is available since SDL 3.2.0.

(if you're on something older, sorry bestie, this one's not for you πŸ™ˆ)


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie πŸŽ€ Simple Directmedia Layer, SDL 3.4.18, and this little beauty is dated SDL_CreateAudioStream(3) β€” mwah, go make some noise πŸ’–πŸŒΈβœ¨

πŸ“¦ where this page comes from