From 0714da37a4f4edf37a2d3845e2aed50d1df437d4 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 8 Aug 2023 21:40:23 -0400
Subject: [PATCH] audio: Fix audio stream callback calculations when future
buffer has space.
We were subtracting backwards. :/
---
src/audio/SDL_audiocvt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c
index 0098504e22d3..f1517ae6c188 100644
--- a/src/audio/SDL_audiocvt.c
+++ b/src/audio/SDL_audiocvt.c
@@ -1038,7 +1038,7 @@ int SDL_GetAudioStreamData(SDL_AudioStream *stream, void *voidbuf, int len)
// calculate difference in dataset size after resampling. Use a Uint64 so the multiplication doesn't overflow.
approx_request = (int) (size_t) ((((Uint64) approx_request) * stream->src_spec.freq) / stream->dst_spec.freq);
if (!stream->flushed) { // do we need to fill the future buffer to accomodate this, too?
- approx_request += stream->future_buffer_filled_frames - stream->resampler_padding_frames;
+ approx_request += stream->resampler_padding_frames - stream->future_buffer_filled_frames;
}
}