Merge "frameCountFromDurationUs: Avoid integer overflow" into main

This commit is contained in:
Andy Hung 2023-11-15 03:31:58 +00:00 committed by Gerrit Code Review
commit 4cf75592a3

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) {