SDL Wiki
(This is the legacy documentation for stable SDL2, the current stable version; SDL3 is the current development version.)


Dequeue more audio on non-callback devices.


Uint32 SDL_DequeueAudio(SDL_AudioDeviceID dev, void *data, Uint32 len);

Function Parameters

dev the device ID from which we will dequeue audio
data a pointer into where audio data should be copied
len the number of bytes (not samples!) to which (data) points

Return Value

Returns the number of bytes dequeued, which could be less than requested; call SDL_GetError() for more information.


If you are looking to queue audio for output on a non-callback playback device, you want SDL_QueueAudio() instead. SDL_DequeueAudio() will always return 0 if you use it with playback devices.

SDL offers two ways to retrieve audio from a capture device: you can either supply a callback that SDL triggers with some frequency as the device records more audio data, (push method), or you can supply no callback, and then SDL will expect you to retrieve data at regular intervals (pull method) with this function.

There are no limits on the amount of data you can queue, short of exhaustion of address space. Data from the device will keep queuing as necessary without further intervention from you. This means you will eventually run out of memory if you aren't routinely dequeueing data.

Capture devices will not queue data when paused; if you are expecting to not need captured audio for some length of time, use SDL_PauseAudioDevice() to stop the capture device from queueing more data. This can be useful during, say, level loading times. When unpaused, capture devices will start queueing data from that point, having flushed any capturable data available while paused.

This function is thread-safe, but dequeueing from the same device from two threads at once does not promise which thread will dequeue data first.

You may not dequeue audio from a device that is using an application-supplied callback; doing so returns an error. You have to use the audio callback, or dequeue audio with this function, but not both.

You should not call SDL_LockAudio() on the device before dequeueing; SDL handles locking internally for this function.


This function is available since SDL 2.0.5.


[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.