From aac15101d9cc85681eee3e02c960d57e32414db6 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Wed, 1 Feb 2017 18:57:49 +0100 Subject: [PATCH] Make the received timestamps in FakeCapture much more stable. --- fake_capture.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fake_capture.cpp b/fake_capture.cpp index 29b06b1..2ef1d7d 100644 --- a/fake_capture.cpp +++ b/fake_capture.cpp @@ -238,6 +238,7 @@ void FakeCapture::producer_thread_func() next_frame = now; } } + steady_clock::time_point timestamp = steady_clock::now(); // Figure out when the next frame is to be, then compute the current one. add_time(1.0 / fps, &next_frame); @@ -262,7 +263,7 @@ void FakeCapture::producer_thread_func() memset4(video_frame.data, ycbcr, width * height / 2); } video_frame.len = width * height * 2; - video_frame.received_timestamp = steady_clock::now(); + video_frame.received_timestamp = timestamp; } AudioFormat audio_format; @@ -274,7 +275,7 @@ void FakeCapture::producer_thread_func() const unsigned num_stereo_samples = audio_sample_frequency / fps; assert(audio_frame.size >= audio_format.num_channels * sizeof(int32_t) * num_stereo_samples); audio_frame.len = audio_format.num_channels * sizeof(int32_t) * num_stereo_samples; - audio_frame.received_timestamp = steady_clock::now(); + audio_frame.received_timestamp = timestamp; if (audio_sin == 0.0f) { // Silence. -- 2.39.2