SDL_PutAudioStreamData(3)
π SDL_PutAudioStreamData β bestie's guide to yeeting audio into a stream π
okay so like. you're in the SDL3 FUNCTIONS section of the manual (that's the vibe of this whole page, iykyk) and you found SDL_PutAudioStreamData(3). and honestly? iconic of you. let's get into it β¨
β¨ NAME β¨
SDL_PutAudioStreamData β add data to the stream. that's it. that's the whole job. she's a simple girl and she slays at it π
π SYNOPSIS π
#include <SDL3/SDL_audio.h>
bool SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len);
look at her. three args. returns a bool. no cap, it's giving minimalism π
π¦ DESCRIPTION π¦
okay so here's the tea, bestie. the data you're putting in has to match the format / channels / samplerate that you specified in the latest call to SDL_SetAudioStreamFormat. or β if you never changed it β whatever format was specified when you created the stream. fr fr, mismatch = chaos. π
and now the part that lowkey blows people's minds: this call simply copies the unconverted data for later. that's it. she's not converting anything on the way in. she's just holding it. β¨
this is different from SDL2, where the data was converted during the Put call and then the Get call would just dequeue the previously-converted stuff. so if you're porting your brain over from SDL2, unlearn that. periodt. π
π FUNCTION PARAMETERS π
streamβ the stream the audio data is being added to. your main character stream. π«Άbufβ a pointer to the audio data to add. just a little pointer, doing her best. πlenβ the number of bytes to write to the stream. bytes!! not samples!! don't do the thing!! π
β RETURN VALUE β
returns true on success or false on failure π₯² β and if it fails, you call SDL_GetError() for more information, because she will tell you what went wrong, she's not mysterious like that.
π₯ THREAD SAFETY π₯
it is safe to call this function from any thread π§ β but if the stream has a callback set, the caller might need to manage extra locking. so like. be mindful. vibe check your locks. π
πΈ AVAILABILITY πΈ
this function is available since SDL 3.2.0. babygirl is relatively new. treat her with respect. π
π« SEE ALSO π«
SDL_ClearAudioStream(3)SDL_FlushAudioStream(3)SDL_GetAudioStreamData(3)SDL_GetAudioStreamQueued(3)
go read them. they're all connected. it's a whole friend group. π³οΈπ
mwah π that's the page!! brought to you by Simple Directmedia Layer, running on SDL 3.4.18, and yes this whole thing is SDL_PutAudioStreamData(3) β go put some audio in a stream, bestie, you've got this π§β¨
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms