SDL: Fix order of events in case audio buffer size changes (0251b)

From 0251b14be33f511fe681e97d7af0e25907277aaa Mon Sep 17 00:00:00 2001
From: staphen <[EMAIL REDACTED]>
Date: Mon, 18 Nov 2024 15:39:27 -0500
Subject: [PATCH] Fix order of events in case audio buffer size changes

(cherry picked from commit a4ec0b1531f0bf79ada28202114d933e821261e7)
---
 src/audio/SDL_audio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 6733b38a6f4b6..dfe52b11e9a53 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -700,8 +700,6 @@ static int SDLCALL SDL_RunAudio(void *userdata)
 
     /* Loop, filling the audio buffers */
     while (!SDL_AtomicGet(&device->shutdown)) {
-        data_len = device->callbackspec.size;
-
         /* Fill the current buffer with sound */
         if (!device->stream && SDL_AtomicGet(&device->enabled)) {
             data = current_audio.impl.GetDeviceBuf(device);
@@ -728,6 +726,8 @@ static int SDLCALL SDL_RunAudio(void *userdata)
             data = device->work_buffer;
         }
 
+        data_len = device->callbackspec.size;
+
         /* !!! FIXME: this should be LockDevice. */
         SDL_LockMutex(device->mixer_lock);
         if (SDL_AtomicGet(&device->paused)) {