Explicitly write silence to the audio device while it is paused.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 11 Jul 2013 23:53:00 -0400
changeset 7406 fb02213c11d3
parent 7405 5a9172b56b18
child 7407 db8a19d767d7
Explicitly write silence to the audio device while it is paused. This is what SDL 1.2 did; we'll do this properly (add a method for the target driver to pause) when I rewrite all this code after the official 2.0 release. Fixes Bugzilla #1857.
src/audio/SDL_audio.c
--- a/src/audio/SDL_audio.c	Thu Jul 11 23:17:52 2013 -0400
+++ b/src/audio/SDL_audio.c	Thu Jul 11 23:53:00 2013 -0400
@@ -461,6 +461,7 @@
         }
     } else {
         /* Otherwise, do not use the streamer. This is the old code. */
+        const int silence = (int) device->spec.silence;
 
         /* Loop, filling the audio buffers */
         while (device->enabled) {
@@ -484,9 +485,13 @@
                 }
             }
 
-            SDL_LockMutex(device->mixer_lock);
-            (*fill) (udata, stream, stream_len);
-            SDL_UnlockMutex(device->mixer_lock);
+            if (device->paused) {
+                SDL_memset(stream, silence, stream_len);
+            } else {
+                SDL_LockMutex(device->mixer_lock);
+                (*fill) (udata, stream, stream_len);
+                SDL_UnlockMutex(device->mixer_lock);
+            }
 
             /* Convert the audio if necessary */
             if (device->convert.needed) {