SDL/src/audio
Sam Lantinga 723d014336 Fixed bug 4171 - SDL_GetQueuedAudioSize is broken with WASAPI
Cameron Gutman

I was trying to use SDL_GetQueuedAudioSize() to ensure my audio latency didn't get too high while streaming data in from the network. If I get more than N frames of audio queued, I know that the network is giving me more data than I can play and I need to drop some to keep latency low.

This doesn't work well on WASAPI out of the box, due to the addition of GetPendingBytes() to the amount of queued data. As a terrible hack, I loop 100 times calling SDL_Delay(10) and SDL_GetQueuedAudioSize() before I ever call SDL_QueueAudio() to get a "baseline" amount that I then subtract from SDL_GetQueuedAudioSize() later. However, because this value isn't actually a constant, this hack can cause SDL_GetQueuedAudioSize() - baselineSize to be < 0. This means I have no accurate way of determining how much data is actually queued in SDL's audio buffer queue.

The SDL_GetQueuedAudioSize() documentation says: "This is the number of bytes that have been queued for playback with SDL_QueueAudio(), but have not yet been sent to the hardware." Yet, SDL_GetQueuedAudioSize() returns > 0 value when SDL_QueueAudio() has never been called.

Based on that documentation, I believe the current behavior contradicts the documented behavior of this function and should be changed in line with Boris's patch.

I understand that exposing the IAudioClient::GetCurrentPadding() value is useful, but a solution there needs to take into account what of that data is silence inserted by SDL and what is actual data queued by the user with SDL_QueueAudio(). Until that happens, I think the best approach is to remove the GetPendingBytes() call until SDL is able to keep track of queued data to make sense of it. This would make SDL_GetQueuedAudioSize() possible to use accurately with WASAPI.
2019-06-04 17:32:15 -07:00
..
alsa Fixed bug 4525 - Fix crash in ALSA_HotplugThread caused by bad return value check 2019-03-16 18:48:21 -07:00
android Updated copyright for 2019 2019-01-04 22:01:14 -08:00
arts Updated copyright for 2019 2019-01-04 22:01:14 -08:00
coreaudio [SDL] iOS fix bug with audio interrupted by a phone call not restoring. 2019-05-14 14:20:54 -07:00
directsound Updated copyright for 2019 2019-01-04 22:01:14 -08:00
disk Updated copyright for 2019 2019-01-04 22:01:14 -08:00
dsp Updated copyright for 2019 2019-01-04 22:01:14 -08:00
dummy Updated copyright for 2019 2019-01-04 22:01:14 -08:00
emscripten Emscripten: No need for Runtime. for dynCalls 2019-01-29 12:21:22 +00:00
esd Updated copyright for 2019 2019-01-04 22:01:14 -08:00
fusionsound Updated copyright for 2019 2019-01-04 22:01:14 -08:00
haiku Updated copyright for 2019 2019-01-04 22:01:14 -08:00
jack Updated copyright for 2019 2019-01-04 22:01:14 -08:00
nacl Updated copyright for 2019 2019-01-04 22:01:14 -08:00
nas Updated copyright for 2019 2019-01-04 22:01:14 -08:00
netbsd Updated copyright for 2019 2019-01-04 22:01:14 -08:00
openslES Fixed static and buzzing when trying to use floating point audio on the OpenSL ES audio driver. 2019-05-23 13:47:27 -07:00
paudio Updated copyright for 2019 2019-01-04 22:01:14 -08:00
psp Updated copyright for 2019 2019-01-04 22:01:14 -08:00
pulseaudio Updated copyright for 2019 2019-01-04 22:01:14 -08:00
qsa Updated copyright for 2019 2019-01-04 22:01:14 -08:00
sndio Updated copyright for 2019 2019-01-04 22:01:14 -08:00
sun Updated copyright for 2019 2019-01-04 22:01:14 -08:00
wasapi Fixed bug 4171 - SDL_GetQueuedAudioSize is broken with WASAPI 2019-06-04 17:32:15 -07:00
winmm Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_audio.c Fixed bug 4171 - SDL_GetQueuedAudioSize is broken with WASAPI 2019-06-04 17:32:15 -07:00
SDL_audio_c.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_audiocvt.c Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_audiodev.c Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_audiodev_c.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_audiotypecvt.c Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_mixer.c Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_sysaudio.h Fixed bug 4171 - SDL_GetQueuedAudioSize is broken with WASAPI 2019-06-04 17:32:15 -07:00
SDL_wave.c Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_wave.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00