]> git.sesse.net Git - nageru/blobdiff - mixer.cpp
Start capturing only when the mixer is ready.
[nageru] / 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();