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 7406fb02213c11d3
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
     1.1 --- a/src/audio/SDL_audio.c	Thu Jul 11 23:17:52 2013 -0400
     1.2 +++ b/src/audio/SDL_audio.c	Thu Jul 11 23:53:00 2013 -0400
     1.3 @@ -461,6 +461,7 @@
     1.4          }
     1.5      } else {
     1.6          /* Otherwise, do not use the streamer. This is the old code. */
     1.7 +        const int silence = (int) device->spec.silence;
     1.8  
     1.9          /* Loop, filling the audio buffers */
    1.10          while (device->enabled) {
    1.11 @@ -484,9 +485,13 @@
    1.12                  }
    1.13              }
    1.14  
    1.15 -            SDL_LockMutex(device->mixer_lock);
    1.16 -            (*fill) (udata, stream, stream_len);
    1.17 -            SDL_UnlockMutex(device->mixer_lock);
    1.18 +            if (device->paused) {
    1.19 +                SDL_memset(stream, silence, stream_len);
    1.20 +            } else {
    1.21 +                SDL_LockMutex(device->mixer_lock);
    1.22 +                (*fill) (udata, stream, stream_len);
    1.23 +                SDL_UnlockMutex(device->mixer_lock);
    1.24 +            }
    1.25  
    1.26              /* Convert the audio if necessary */
    1.27              if (device->convert.needed) {