SDL/src
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
..
atomic Updated copyright for 2019 2019-01-04 22:01:14 -08:00
audio Fixed bug 4171 - SDL_GetQueuedAudioSize is broken with WASAPI 2019-06-04 17:32:15 -07:00
core Added a function to get the current Android SDK version at runtime 2019-05-23 14:19:00 -07:00
cpuinfo Fixed Windows RT build 2019-03-19 16:52:09 -07:00
dynapi Added support for building SDL as a dynamic library on iOS 2019-03-19 07:53:33 -07:00
events Return an error if both mouse relative mode and mouse warping are unavailable, instead of asserting. 2019-05-23 11:32:36 -07:00
file Updated copyright for 2019 2019-01-04 22:01:14 -08:00
filesystem Updated copyright for 2019 2019-01-04 22:01:14 -08:00
haptic Updated copyright for 2019 2019-01-04 22:01:14 -08:00
hidapi HIDAPI: fix bug that caused non-HID class parts of composite devices to have windows HID functions called on them. 2019-03-12 14:44:12 -07:00
joystick Fixed bug 4474 - Add support for an ASUS Gamepad variation 2019-05-19 12:06:58 -07:00
libm Updated copyright for 2019 2019-01-04 22:01:14 -08:00
loadso Updated copyright for 2019 2019-01-04 22:01:14 -08:00
main Added support for building SDL as a dynamic library on iOS 2019-03-19 07:53:33 -07:00
power Updated copyright for 2019 2019-01-04 22:01:14 -08:00
render Fixed bug 4469 - make SDL_CreateTextureFromSurface pick a more appropriate format 2019-05-19 12:04:06 -07:00
sensor Updated copyright for 2019 2019-01-04 22:01:14 -08:00
stdlib Updated copyright for 2019 2019-01-04 22:01:14 -08:00
test test: unify all the command line usage logging. 2019-05-28 17:39:13 -04:00
thread Hopefully fixed the mingw32 build 2019-03-19 17:20:54 -07:00
timer Updated copyright for 2019 2019-01-04 22:01:14 -08:00
video iOS: return SDL_GetWindowSize from SDL_GL_GetDrawableSize if there's no GLES view in the window (matches the behaviour of SDL_GL_GetDrawableSize on other platforms). Addresses bug #4629. 2019-05-26 18:53:36 -03:00
SDL.c events: Make debug logging of the event queue a hint instead of an #ifdef. 2019-03-15 14:08:30 -04:00
SDL_assert.c Use _Exit() when available 2019-04-23 07:59:31 -07:00
SDL_assert_c.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_dataqueue.c Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_dataqueue.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_error.c Fix DirectInput error codes being lost 2019-03-16 18:11:09 -07:00
SDL_error_c.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_hints.c Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_internal.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_log.c Updated copyright for 2019 2019-01-04 22:01:14 -08:00