SDL School

API reference / Audio

SDL_GetAudioStreamQueued

Function, SDL3

Gets the number of bytes that wait in a stream.

Declaration

#include <SDL3/SDL.h>

int SDL_GetAudioStreamQueued(SDL_AudioStream *stream);

Parameters

streamThe stream.

Return value

The number of bytes, or -1 on failure.

Example

Make a tone
while (SDL_GetAudioStreamQueued(stream) < KEEP_QUEUED * (int)sizeof(float)) {
    float samples[CHUNK_SAMPLES];

    make_samples(samples, CHUNK_SAMPLES);
    SDL_PutAudioStreamData(stream, samples, sizeof(samples));
}

See this code run in Make a tone. Download the full program (.zip)

Notes

In SDL2

Use SDL_GetQueuedAudioSize.

See also