From c45295463c6968958e944d64df03fedb2bb964f2 Mon Sep 17 00:00:00 2001 From: qndel Date: Mon, 1 Mar 2021 02:08:04 +0100 Subject: [PATCH] fix text scroll speed (#1057) --- SourceX/soundsample.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SourceX/soundsample.cpp b/SourceX/soundsample.cpp index d9e5d4828..3c3edffd8 100644 --- a/SourceX/soundsample.cpp +++ b/SourceX/soundsample.cpp @@ -104,7 +104,9 @@ int SoundSample::GetLength() bytePerSample = 1; } - return chunk->alen * 1000 / (frequency * channels * bytePerSample); + Uint64 ms = 1000; // milliseconds, 64bit to avoid overflow when multiplied by alen + Uint32 bps = frequency * channels * bytePerSample; // bytes per second + return (Uint32)(chunk->alen * ms / bps); }; } // namespace dvl