SDL: Adjust rounding when calculating resampled output frames

From 580a4963917cf5057e3b4cb3d9a04b985f27dc9d Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 30 Aug 2024 06:42:39 -0700
Subject: [PATCH] Adjust rounding when calculating resampled output frames

Fixes https://github.com/libsdl-org/sdl2-compat/issues/95
---
 src/audio/SDL_audioresample.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/audio/SDL_audioresample.c b/src/audio/SDL_audioresample.c
index f1660f7b1c6d0..79aa8851e6194 100644
--- a/src/audio/SDL_audioresample.c
+++ b/src/audio/SDL_audioresample.c
@@ -662,7 +662,7 @@ Sint64 SDL_GetResamplerOutputFrames(Sint64 input_frames, Sint64 resample_rate, S
     }
 
     // output_frames = div_ceil(input_offset, resample_rate)
-    Sint64 output_frames = (input_offset > 0) ? (((input_offset - 1) / resample_rate) + 1) : 0;
+    Sint64 output_frames = (input_offset > 0) ? ((input_offset + resample_rate * 3 / 4) / resample_rate) : 0;
 
     *inout_resample_offset = (output_frames * resample_rate) - input_offset;