SDL: audio: simple-copy path should check if device is paused.

From 4db2b968af2fbb586e19d2aea71898c4a87780bc Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Wed, 27 Sep 2023 16:24:33 -0400
Subject: [PATCH] audio: simple-copy path should check if device is paused.

Otherwise, we get into situations where all bound streams need to change
their output formats when a device pauses...and it makes the fast case
slow: when pausing a single input, it needs to silence and then convert a
silent buffer, instead of just zeroing out the device buffer and being done.
---
 src/audio/SDL_audio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 8eb9cb0a4cf4..4155db7c36a4 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -181,7 +181,6 @@ static SDL_bool AudioDeviceCanUseSimpleCopy(SDL_AudioDevice *device)
         device->logical_devices &&  // there's a logical device
         !device->logical_devices->next &&  // there's only _ONE_ logical device
         !device->logical_devices->postmix && // there isn't a postmix callback
-        !SDL_AtomicGet(&device->logical_devices->paused) &&  // it isn't paused
         device->logical_devices->bound_streams &&  // there's a bound stream
         !device->logical_devices->bound_streams->next_binding  // there's only _ONE_ bound stream.
     ) ? SDL_TRUE : SDL_FALSE;
@@ -835,7 +834,7 @@ SDL_bool SDL_OutputAudioThreadIterate(SDL_AudioDevice *device)
             // We should have updated this elsewhere if the format changed!
             SDL_assert(AUDIO_SPECS_EQUAL(stream->dst_spec, device->spec));
 
-            const int br = SDL_GetAudioStreamData(stream, device_buffer, buffer_size);
+            const int br = SDL_AtomicGet(&logdev->paused) ? 0 : SDL_GetAudioStreamData(stream, device_buffer, buffer_size);
             if (br < 0) {  // Probably OOM. Kill the audio device; the whole thing is likely dying soon anyhow.
                 retval = SDL_FALSE;
                 SDL_memset(device_buffer, device->silence_value, buffer_size);  // just supply silence to the device before we die.