[PATCH] winepulse.drv: Avoid unnecessary use of ceil function
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> --- dlls/winepulse.drv/mmdevdrv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 8d57f1a45a..0823af6341 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -28,7 +28,6 @@ #include <stdarg.h> #include <unistd.h> -#include <math.h> #include <stdio.h> #include <errno.h> @@ -1400,7 +1399,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface, period_bytes = pa_frame_size(&This->ss) * MulDiv(period, This->ss.rate, 10000000); if (duration < 20000000) - This->bufsize_frames = ceil((duration / 10000000.) * fmt->nSamplesPerSec); + This->bufsize_frames = (duration * fmt->nSamplesPerSec + 9999999) / 10000000; else This->bufsize_frames = 2 * fmt->nSamplesPerSec; This->bufsize_bytes = This->bufsize_frames * pa_frame_size(&This->ss); -- 2.19.2
I guess I'm not opposed to this, but my feeling is "if it's not broken, don't fix it". Maybe there's something I don't know. Can you explain what advantage this has? Thanks, Andrew On Sun, Dec 02, 2018 at 04:09:34PM -0700, Alex Henrie wrote:
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> --- dlls/winepulse.drv/mmdevdrv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 8d57f1a45a..0823af6341 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -28,7 +28,6 @@
#include <stdarg.h> #include <unistd.h> -#include <math.h> #include <stdio.h> #include <errno.h>
@@ -1400,7 +1399,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface, period_bytes = pa_frame_size(&This->ss) * MulDiv(period, This->ss.rate, 10000000);
if (duration < 20000000) - This->bufsize_frames = ceil((duration / 10000000.) * fmt->nSamplesPerSec); + This->bufsize_frames = (duration * fmt->nSamplesPerSec + 9999999) / 10000000; else This->bufsize_frames = 2 * fmt->nSamplesPerSec; This->bufsize_bytes = This->bufsize_frames * pa_frame_size(&This->ss); -- 2.19.2
On Wed, Dec 5, 2018 at 6:34 AM Andrew Eikum <aeikum(a)codeweavers.com> wrote:
I guess I'm not opposed to this, but my feeling is "if it's not broken, don't fix it". Maybe there's something I don't know. Can you explain what advantage this has?
To me it seems cleaner to just use integer operations instead of casting to floating-point and back again. -Alex
participants (2)
-
Alex Henrie -
Andrew Eikum