From bb79c64ab827982ee3e0b6c67f65220df23c98e5 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 24 Dec 2016 00:06:34 +0100 Subject: [PATCH] Start capturing only when the mixer is ready. Seemingly creating a context etc. can take 70+ ms, and letting the capture cards insert stuff freely for that time confuses ResamplingQueue (plus probably our video queue length policy). Delay it until we are actually ready to process output frames. --- mixer.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mixer.cpp b/mixer.cpp index f7ef46e..85f974b 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -186,9 +186,8 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards) BMUSBCapture::set_card_connected_callback(bind(&Mixer::bm_hotplug_add, this, _1)); BMUSBCapture::start_bm_thread(); - for (card_index = 0; card_index < num_cards; ++card_index) { + for (unsigned card_index = 0; card_index < num_cards; ++card_index) { cards[card_index].queue_length_policy.reset(card_index); - cards[card_index].capture->start_bm_capture(); } // Set up stuff for NV12 conversion. @@ -592,6 +591,12 @@ void Mixer::thread_func() exit(1); } + // Start the actual capture. (We don't want to do it before we're actually ready + // to process output frames.) + for (unsigned card_index = 0; card_index < num_cards; ++card_index) { + cards[card_index].capture->start_bm_capture(); + } + steady_clock::time_point start, now; start = steady_clock::now(); -- 2.39.2