From 943ad545d7226d04ef054959ba9dbce7490b0602 Mon Sep 17 00:00:00 2001
From: Cameron Gutman <[EMAIL REDACTED]>
Date: Sun, 23 Feb 2025 17:22:05 -0600
Subject: [PATCH] audio: Initialize the audio callback buffer with silence
Some apps (DeSmuME) won't necessarily write to it like they're
supposed to, so we will end up playing uninitialized memory.
---
src/sdl2_compat.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index f070888..c31ac9e 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -6842,6 +6842,9 @@ static SDL_AudioDeviceID OpenAudioDeviceLocked(const char *devicename, int iscap
return 0;
}
+ /* Some apps may leave the callback buffer unmodified, so initialize it with silence */
+ SDL3_memset(stream2->callback2_buffer, obtained2->silence, stream2->bytes_per_callbacks);
+
stream2->callback2 = desired2->callback;
stream2->callback2_userdata = desired2->userdata;
if (iscapture) {