# SDL3: When do I need to call SDL\_FlushAudioStream()?

**URL:** <https://discourse.libsdl.org/t/sdl3-when-do-i-need-to-call-sdl-flushaudiostream/57268>\
**Category:** Game Development\
**Created:** [January 24, 2025, 7:04am UTC](https://discourse.libsdl.org/t/sdl3-when-do-i-need-to-call-sdl-flushaudiostream/57268 "2025-01-24T07:04:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreas\_g](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/6bbea6/32.png) [@andreas\_g](https://discourse.libsdl.org/u/andreas_g)\
**Post date:** [January 24, 2025, 7:04am UTC](https://discourse.libsdl.org/t/sdl3-when-do-i-need-to-call-sdl-flushaudiostream/57268/1 "2025-01-24T07:04:51Z")

</div>

Hello all,

I am developing an application that uses sound output. It does not continously play audio, but only in certain situations. I am initialising audio like this (simplified without error handling):

```auto
SDL_AudioStream* Audio_Output_Stream = NULL;
SDL_AudioSpec request = {SDL_AUDIO_S16BE, 2, 44100};
SDL_InitSubSystem(SDL_INIT_AUDIO);
Audio_Output_Stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &request, NULL, NULL);

```

When audio data is available, I play it with these function calls:

```auto
SDL_ClearAudioStream(Audio_Output_Stream);
SDL_PutAudioStreamData(Audio_Output_Stream, data, len);

```

`SDL_ClearAudioStream(Audio_Output_Stream)` is called once when audio output starts. `SDL_PutAudio_StreamData(Audio_Output_Stream)` is called periodically with chunks of up to 2048 bytes.

Now my question is: Do I need to call `SDL_FlushAudioStream(Audio_Output_Stream)` after last chunk of data was passed to the stream?

It seems that some data is stuck in the queue otherwise. If I call `SDL_GetAudioStreamQueued(Audio_Output_Stream)` before starting to play (before `SDL_ClearAudioStream(Audio_Output_Stream)`) it reports 28 or 32 bytes of data being queued, even if there was a long period of time between last call of `SDL_PutAudioStreamData(Audio_Output_Stream, data, len)`.

This is with SDL3. Is there an equivalent to `SDL_FlushAudioStream()` in SDL2?
