Commit b2f5123b655c6744fb3044a6bacf21cd5be086b1

Ryan C. Gordon 2017-10-11T11:43:35

audio: calculate resampling time directly, don't increment (thanks, Eric!). Fixes buffer overruns as floating point errors accumulate. Partially fixes Bugzilla #3848.

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c
index 4808e67..9027799 100644
--- a/src/audio/SDL_audiocvt.c
+++ b/src/audio/SDL_audiocvt.c
@@ -527,7 +527,7 @@ SDL_ResampleAudio(const int chans, const int inrate, const int outrate,
             *(dst++) = outsample;
         }
 
-        outtime += outtimeincr;
+        outtime = i * outtimeincr;
     }
 
     return outframes * chans * sizeof (float);