From 5c9c81efcc52e92569e8f03762870d5d97da3c46 Mon Sep 17 00:00:00 2001 From: "Diogo Franco (Kovensky)" Date: Sun, 9 Mar 2014 17:52:53 -0300 Subject: ao_wasapi: Use double math for QueryPerformanceCounter correction The uint64_t math would cause overflow at long enough system uptimes (...such as 3 days), and any precision error given by the double math will be under one milisecond. --- audio/out/ao_wasapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'audio') diff --git a/audio/out/ao_wasapi.c b/audio/out/ao_wasapi.c index a3da9fe388..8f443173c8 100644 --- a/audio/out/ao_wasapi.c +++ b/audio/out/ao_wasapi.c @@ -1381,9 +1381,9 @@ static float get_device_delay(struct wasapi_state *state) { LARGE_INTEGER qpc_count; QueryPerformanceCounter(&qpc_count); - UINT64 qpc_diff = (qpc_count.QuadPart * 10000000 / state->qpc_frequency.QuadPart) - qpc_position; + double qpc_diff = (qpc_count.QuadPart * 1e7 / state->qpc_frequency.QuadPart) - qpc_position; - position += state->clock_frequency * qpc_diff / 10000000; + position += state->clock_frequency * (uint64_t)(qpc_diff / 1e7); /* convert position to the same base as sample_count */ position = position * state->format.Format.nSamplesPerSec / state->clock_frequency; -- cgit v1.2.3