From: Steinar H. Gunderson Date: Wed, 1 Feb 2017 17:57:49 +0000 (+0100) Subject: Make the received timestamps in FakeCapture much more stable. X-Git-Tag: 0.6.0~5 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=aac15101d9cc85681eee3e02c960d57e32414db6;hp=1833f747a9008f38e5597622f2e3dbce3340e2cb;p=bmusb Make the received timestamps in FakeCapture much more stable. --- 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.