]> git.sesse.net Git - bmusb/commitdiff
Make the received timestamps in FakeCapture much more stable.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 1 Feb 2017 17:57:49 +0000 (18:57 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 1 Feb 2017 17:57:49 +0000 (18:57 +0100)
fake_capture.cpp

index 29b06b100d016d49543114c0056a6c31e4bf05dd..2ef1d7d68dc58b71a2c2cd93a76efd0f5473d536 100644 (file)
@@ -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.