audio: a little more robustness in the capture device's thread.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 02 Aug 2016 15:04:33 -0400
changeset 10223 59c16a96a5a1
parent 10222 942b45f2fae3
child 10224 8769b18e16a1
audio: a little more robustness in the capture device's thread.
src/audio/SDL_audio.c
--- a/src/audio/SDL_audio.c	Tue Aug 02 13:50:58 2016 -0400
+++ b/src/audio/SDL_audio.c	Tue Aug 02 15:04:33 2016 -0400
@@ -729,7 +729,6 @@
 
         while (still_need > 0) {
             const int rc = current_audio.impl.CaptureFromDevice(device, ptr, still_need);
-            SDL_assert(rc != 0);  /* device should have blocked, failed, or returned data. */
             SDL_assert(rc <= still_need);  /* device should not overflow buffer. :) */
             if (rc > 0) {
                 still_need -= rc;
@@ -751,7 +750,9 @@
 
         /* !!! FIXME: this should be LockDevice. */
         SDL_LockMutex(device->mixer_lock);
-        if (!SDL_AtomicGet(&device->paused)) {
+        if (SDL_AtomicGet(&device->paused)) {
+            current_audio.impl.FlushCapture(device);  /* one snuck in! */
+        } else {
             (*callback)(udata, stream, stream_len);
         }
         SDL_UnlockMutex(device->mixer_lock);