]> git.sesse.net Git - nageru/commitdiff
Fix crash on exit when there are no USB cards.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 12 Jul 2016 06:17:57 +0000 (08:17 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 12 Jul 2016 06:17:57 +0000 (08:17 +0200)
mixer.cpp
mixer.h

index 6276e2cb20c15b92aaaa4c70dfd00afdf0360322..94d09e7eb272441dcf1dd2dfe6dde790f0baca22 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -205,6 +205,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
        }
 
        if (num_usb_devices > 0) {
+               has_bmusb_thread = true;
                BMUSBCapture::start_bm_thread();
        }
 
@@ -283,7 +284,9 @@ Mixer::~Mixer()
 {
        resource_pool->release_glsl_program(cbcr_program_num);
        glDeleteBuffers(1, &cbcr_vbo);
-       BMUSBCapture::stop_bm_thread();
+       if (has_bmusb_thread) {
+               BMUSBCapture::stop_bm_thread();
+       }
 
        for (unsigned card_index = 0; card_index < num_cards; ++card_index) {
                {
diff --git a/mixer.h b/mixer.h
index e893ffb8427728b235d21f93c7a9169991c14aef..7abbaec1a5e5e1273f89925d6adbedbe66f048dc 100644 (file)
--- a/mixer.h
+++ b/mixer.h
@@ -424,6 +424,7 @@ private:
        int64_t pts_int = 0;  // In TIMEBASE units.
 
        std::mutex bmusb_mutex;
+       bool has_bmusb_thread = false;
        struct CaptureCard {
                CaptureInterface *capture;
                std::unique_ptr<PBOFrameAllocator> frame_allocator;