]> git.sesse.net Git - nageru/commitdiff
Start capturing only when the mixer is ready.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 23 Dec 2016 23:06:34 +0000 (00:06 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 23 Dec 2016 23:09:42 +0000 (00:09 +0100)
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

index f7ef46e160d251e6ec89ee4dee611f86fac74262..85f974b401d08c054ecf4e3ad4b3a0870f622dd1 100644 (file)
--- 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();