SDL_GetAudioStreamAvailable(3)

✨ SDL_GetAudioStreamAvailable ✨

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual πŸ’… this one's called SDL_GetAudioStreamAvailable and it's literally just "how many bytes do I have ready tho"


🌸 NAME 🌸

SDL_GetAudioStreamAvailable β€” get the number of converted/resampled bytes available πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_audio.h>

int SDL_GetAudioStreamAvailable(SDL_AudioStream *stream);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea: the stream might be buffering data behind the scenes until it has enough to resample correctly 😭 so the number you get back might be lower than what you expect, or honestly it could even be zero. not a bug, it's just the vibe. if you need the data now, add more data or flush the stream, periodt ✨

and listen β€” if the stream has SO much data that it would overflow an int, the return value gets clamped to a maximum value. but no cap, no queued data is lost 🫢 so if there are gigabytes of data queued, your app might need to read some of it with SDL_GetAudioStreamData before this function's return value stops being clamped. it's giving "the number is lying to you but only because C is like that" πŸ’€


πŸ‘‘ FUNCTION PARAMETERS πŸ‘‘

  • stream β€” the audio stream to query 🎧

⭐ RETURN VALUE ⭐

Returns the number of converted/resampled bytes available, or -1 on failure 😭 call SDL_GetError() for more info bestie, she'll tell you what went wrong πŸ’…


🌈 THREAD SAFETY 🌈

It is safe to call this function from any thread 🧚 no notes, iconic behaviour, slay πŸ‘‘


πŸ’œ AVAILABILITY πŸ’œ

This function is available since SDL 3.2.0 ⭐


πŸ”₯ SEE ALSO πŸ”₯


Simple Directmedia Layer β€” version SDL 3.4.18 πŸŽ€ mwah, that's the whole page, go forth and check your stream bytes bestie, you got this πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from