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