SDL_GetAudioStreamData(3)
β¨ SDL_GetAudioStreamData β¨
okay bestie, gather round, because this is a page from the SDL3 FUNCTIONS manual and it's literally the one that hands you your audio π
π NAME
SDL_GetAudioStreamData β grab the converted/resampled data out of the stream π§β¨
πΈ SYNOPSIS
#include <SDL3/SDL_audio.h>
int SDL_GetAudioStreamData(SDL_AudioStream *stream, void *buf, int len);
π¦ DESCRIPTION
So here's the tea: the input/output data format, channels and samplerate? Those get set the moment you create the stream, and if you wanna change your mind later you can just call SDL_SetAudioStreamFormat. slay, flexible π
ngl the important part is when the work happens: any conversion and resampling that needs doing gets done during this very call. Meanwhile SDL_PutAudioStreamData just queues up unconverted data for later, no thoughts, head empty π«Ά. This is different than SDL2, where the conversion/resampling work happened while you were inputting new data, and requesting output just copied the already-converted data. so yeah, that's the glow-up β¨
π FUNCTION PARAMETERS
streamβ the stream you're requesting audio from, your main character π€bufβ a buffer to fill with audio data, hand it over and it gets fed πlenβ the maximum number of bytes to fill. it's a cap, not a promise, bestie π
π RETURN VALUE
Returns the number of bytes read from the stream, or -1 on failure π. If it flops, call SDL_GetError() for more info β she'll tell you what went wrong, fr fr.
π₯ THREAD SAFETY
It's 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, keep an eye on that, iykyk π
β AVAILABILITY
This function is available since SDL 3.2.0. old enough to be iconic, new enough to be cute π
π SEE ALSO
Simple Directmedia Layer said it, SDL 3.4.18 stamped it, and that's the whole vibe check β SDL_GetAudioStreamData(3), periodt ππ¦β¨
π¦ 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