From b656720bc61c71807d30e055c335d6391dcd3ca6 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 19 Sep 2023 14:35:37 -0400 Subject: [PATCH] loopwave: Use SDL_GetAudioStreamQueued() for more accurate results. --- test/loopwave.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/loopwave.c b/test/loopwave.c index 5e59219652..1fa1b91e1a 100644 --- a/test/loopwave.c +++ b/test/loopwave.c @@ -31,14 +31,14 @@ static struct SDL_AudioSpec spec; Uint8 *sound; /* Pointer to wave data */ Uint32 soundlen; /* Length of wave data */ - Uint32 soundpos; } wave; static SDL_AudioStream *stream; static void fillerup(void) { - if (SDL_GetAudioStreamAvailable(stream) < (int) ((wave.soundlen / 2))) { + const int minimum = (wave.soundlen / SDL_AUDIO_FRAMESIZE(wave.spec)) / 2; + if (SDL_GetAudioStreamQueued(stream) < minimum) { SDL_PutAudioStreamData(stream, wave.sound, wave.soundlen); } }