From 305b2579ebf36c91770925c3fc510294899da931 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 19 Oct 2022 01:08:39 +0300 Subject: [PATCH] engine: client: voice: fix crackling voice file input on low FPS --- engine/client/voice.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engine/client/voice.c b/engine/client/voice.c index 7d5ef8f0..98eb5266 100644 --- a/engine/client/voice.c +++ b/engine/client/voice.c @@ -159,9 +159,11 @@ static uint Voice_GetOpusCompressedData( byte *out, uint maxsize, uint *frames ) if( voice.input_file ) { uint numbytes; - double updateInterval; + double updateInterval, curtime = Sys_DoubleTime(); + + updateInterval = curtime - voice.start_time; + voice.start_time = curtime; - updateInterval = cl.mtime[0] - cl.mtime[1]; numbytes = updateInterval * voice.samplerate * voice.width * VOICE_PCM_CHANNELS; numbytes = Q_min( numbytes, voice.input_file->size - voice.input_file_pos ); numbytes = Q_min( numbytes, sizeof( voice.input_buffer ) - voice.input_buffer_pos );