SDL_GetQueuedAudioSize() shouldn't grab lock when not set up for queueing.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 30 Jul 2014 11:11:48 -0400
changeset 9032 36c472422d64
parent 9031 e963a13a720c
child 9033 335b60fba5c2
SDL_GetQueuedAudioSize() shouldn't grab lock when not set up for queueing.
src/audio/SDL_audio.c
--- a/src/audio/SDL_audio.c	Wed Jul 30 11:08:31 2014 -0400
+++ b/src/audio/SDL_audio.c	Wed Jul 30 11:11:48 2014 -0400
@@ -472,11 +472,11 @@
 Uint32
 SDL_GetQueuedAudioSize(SDL_AudioDeviceID devid)
 {
-    /* this happens to work for non-queueing devices, since we memset()
-       the device to zero at init time, and these devices should return 0. */
     Uint32 retval = 0;
     SDL_AudioDevice *device = get_audio_device(devid);
-    if (device) {
+
+    /* Nothing to do unless we're set up for queueing. */
+    if (device && (device->spec.callback == SDL_BufferQueueDrainCallback)) {
         current_audio.impl.LockDevice(device);
         retval = device->queued_bytes + current_audio.impl.GetPendingBytes(device);
         current_audio.impl.UnlockDevice(device);