From 2fee3c939af105c5a75696702f58ef267da7bf49 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Sat, 2 Nov 2013 19:11:14 +0000 Subject: Fix video recording sync drift (patch refactored but original author unknown) --- src/client/snd_dma.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/client/snd_dma.c') diff --git a/src/client/snd_dma.c b/src/client/snd_dma.c index 369c9388..081319ca 100644 --- a/src/client/snd_dma.c +++ b/src/client/snd_dma.c @@ -1258,7 +1258,13 @@ void S_GetSoundtime(void) if( CL_VideoRecording( ) ) { - s_soundtime += (int)ceil( dma.speed / cl_aviFrameRate->value ); + float fps = MIN(cl_aviFrameRate->value, 1000.0f); + float frameDuration = MAX(dma.speed / fps, 1.0f) + clc.aviSoundFrameRemainder; + + int msec = (int)frameDuration; + s_soundtime += msec; + clc.aviSoundFrameRemainder = frameDuration - msec; + return; } -- cgit