frameCountFromDurationUs: Avoid integer overflow

Change-Id: Ifbeab2724172f0adc113d6f8852a6f8ae7870817
This commit is contained in:
Michael Chan 2023-11-13 14:54:44 +11:00
parent bafcb977b5
commit 76f06f2c6a

View file

@ -175,7 +175,7 @@ constexpr U makeBitPositionFlagMask(std::initializer_list<E> flags) {
}
constexpr int32_t frameCountFromDurationUs(long durationUs, int32_t sampleRateHz) {
return (durationUs * sampleRateHz) / 1000000LL;
return (static_cast<long long>(durationUs) * sampleRateHz) / 1000000LL;
}
constexpr int32_t frameCountFromDurationMs(int32_t durationMs, int32_t sampleRateHz) {