sdl2-compat: audio: Don't allocate SDL2_AudioStream::callback2_buffer if not necessary.

From 857d4f24740f450152dd38abc172227d4bd83c6f Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sun, 16 Feb 2025 23:46:48 -0500
Subject: [PATCH] audio: Don't allocate SDL2_AudioStream::callback2_buffer if
 not necessary.

---
 src/sdl2_compat.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 6542bf9..77c5cab 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -6701,15 +6701,15 @@ static SDL_AudioDeviceID OpenAudioDeviceLocked(const char *devicename, int iscap
         return 0;
     }
 
-    stream2->bytes_per_callbacks = obtained2->size;
-    stream2->callback2_buffer = SDL3_malloc(stream2->bytes_per_callbacks);
-    if (!stream2->callback2_buffer) {
-        SDL_FreeAudioStream(stream2);
-        SDL3_CloseAudioDevice(device3);
-        return 0;
-    }
-
     if (desired2->callback) {
+        stream2->bytes_per_callbacks = obtained2->size;
+        stream2->callback2_buffer = SDL3_malloc(stream2->bytes_per_callbacks);
+        if (!stream2->callback2_buffer) {
+            SDL_FreeAudioStream(stream2);
+            SDL3_CloseAudioDevice(device3);
+            return 0;
+        }
+
         stream2->callback2 = desired2->callback;
         stream2->callback2_userdata = desired2->userdata;
         if (iscapture) {