From e7aa4a549951a4989f2a1506f891540dc1bc72c1 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 9 Apr 2024 23:34:35 +0200 Subject: Better audio timing test: compensate for audio server latency --- src/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 167f8a5..bb54ca2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2388,6 +2388,10 @@ int main(int argc, char **argv) { double received_audio_time = clock_get_monotonic_seconds(); const int64_t timeout_ms = std::round((1000.0 / (double)audio_track.codec_context->sample_rate) * 1000.0); + // Move audio back by around 252 ms. This is just a shitty way to handle audio latency but pulseaudio latency calculation + // returns much lower value which isn't helpful. + audio_device.frame->pts = audio_track.codec_context->frame_size * 12; + while(running) { void *sound_buffer; int sound_buffer_size = -1; -- cgit v1.2.3