From a4ec0b1531f0bf79ada28202114d933e821261e7 Mon Sep 17 00:00:00 2001 From: staphen Date: Mon, 18 Nov 2024 15:39:27 -0500 Subject: [PATCH] Fix order of events in case audio buffer size changes --- 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)) {