From 23b4a93b45c71f8aeabe40e1bbca98bf4ceceb4a Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sun, 16 Feb 2025 23:49:26 -0500
Subject: [PATCH] audio: Don't clear queued audio when pausing an audio device.
Fixes #368.
---
src/sdl2_compat.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 77c5cab..2db5af0 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -7060,7 +7060,9 @@ SDL_PauseAudioDevice(SDL_AudioDeviceID dev, int pause_on)
SDL2_AudioStream *stream2 = GetOpenAudioDevice(dev);
if (stream2) {
const SDL_AudioDeviceID device3 = SDL3_GetAudioStreamDevice(stream2->stream3);
- SDL3_ClearAudioStream(stream2->stream3);
+ if (stream2->callback2) { // don't clear the stream for queued audio, just callback audio.
+ SDL3_ClearAudioStream(stream2->stream3);
+ }
if (device3) {
if (pause_on) {
SDL3_PauseAudioDevice(device3);