diff options
author | Diogo Franco (Kovensky) <diogomfranco@gmail.com> | 2014-03-09 17:52:53 -0300 |
---|---|---|
committer | Diogo Franco (Kovensky) <diogomfranco@gmail.com> | 2014-03-09 17:56:29 -0300 |
commit | 5c9c81efcc52e92569e8f03762870d5d97da3c46 (patch) | |
tree | 53482f361f0eea519515b98600e1963d72b82722 /audio | |
parent | a84e25eb5976678914ec7408a83cf12c8707b56e (diff) | |
download | mpv-5c9c81efcc52e92569e8f03762870d5d97da3c46.tar.bz2 mpv-5c9c81efcc52e92569e8f03762870d5d97da3c46.tar.xz |
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.
Diffstat (limited to 'audio')
-rw-r--r-- | audio/out/ao_wasapi.c | 4 |
1 files changed, 2 insertions, 2 deletions
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; |