From 505040522aaa28af2d4bf3f437f2e546680e3123 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 12 Jul 2016 08:17:57 +0200 Subject: [PATCH] Fix crash on exit when there are no USB cards. --- mixer.cpp | 5 ++++- mixer.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mixer.cpp b/mixer.cpp index 6276e2c..94d09e7 100644 --- 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 e893ffb..7abbaec 100644 --- 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 frame_allocator; -- 2.39.2