aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-04-23 06:18:54 -0700
committerChris Robinson <[email protected]>2020-04-23 06:18:54 -0700
commite89978195f3910693958b8faebbd88b4643f8d57 (patch)
treee33ac555ae798ccac9ae1ebfc864e9af5f69b787
parentaff410fa6df45d37c7d9fe4e0b33fc125c3f550b (diff)
Clean up some scaling math
-rw-r--r--alc/alc.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index ef534182..df1e9c07 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -1922,10 +1922,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
{
freq = maxu(freq, MIN_OUTPUT_RATE);
- device->UpdateSize = (device->UpdateSize*freq + device->Frequency/2) /
- device->Frequency;
- device->BufferSize = (device->BufferSize*freq + device->Frequency/2) /
- device->Frequency;
+ const double scale{static_cast<double>(freq) / device->Frequency};
+ device->UpdateSize = static_cast<ALuint>(device->UpdateSize*scale + 0.5);
+ device->BufferSize = static_cast<ALuint>(device->BufferSize*scale + 0.5);
device->Frequency = freq;
device->Flags.set<FrequencyRequest>();