From 3e10c0005dec68084c15e755d43b73c9650ff12b Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sat, 24 Jun 2023 14:53:44 -0400
Subject: [PATCH] audio: Capture devices should respect logical device pausing.
---
src/audio/SDL_audio.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 3d791677dbe2..27b2633cfb59 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -774,6 +774,10 @@ SDL_bool SDL_CaptureAudioThreadIterate(SDL_AudioDevice *device)
retval = SDL_FALSE;
} else if (rc > 0) { // queue the new data to each bound stream.
for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev != NULL; logdev = logdev->next) {
+ if (SDL_AtomicGet(&logdev->paused)) {
+ continue; // paused? Skip this logical device.
+ }
+
for (SDL_AudioStream *stream = logdev->bound_streams; stream != NULL; stream = stream->next_binding) {
/* this will hold a lock on `stream` while putting. We don't explicitly lock the streams
for iterating here because the binding linked list can only change while the device lock is held.