From e89978195f3910693958b8faebbd88b4643f8d57 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 23 Apr 2020 06:18:54 -0700 Subject: Clean up some scaling math --- alc/alc.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'alc/alc.cpp') 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(freq) / device->Frequency}; + device->UpdateSize = static_cast(device->UpdateSize*scale + 0.5); + device->BufferSize = static_cast(device->BufferSize*scale + 0.5); device->Frequency = freq; device->Flags.set(); -- cgit v1.2.3