X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;ds=sidebyside;f=pv%2Fsession.cpp;h=73dd339b60fea95259d6fddc7aace7ec9f3ad0e1;hb=2b05d3110a0a50ce93c8c887a2dc00c1375e92fa;hp=6b7645bc7c7ef92e876e74076e062f7f532171c0;hpb=cc9a7898ee7afc32e03dbcc991ed7ba722ed8f1b;p=pulseview.git diff --git a/pv/session.cpp b/pv/session.cpp index 6b7645b..73dd339 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -195,10 +195,14 @@ Session::capture_state Session::get_capture_state() const void Session::start_capture(function error_handler) { + if (!device_) { + error_handler(tr("No active device set, can't start acquisition.")); + return; + } + stop_capture(); // Check that at least one channel is enabled - assert(device_); const shared_ptr sr_dev = device_->device(); if (sr_dev) { const auto channels = sr_dev->channels(); @@ -219,8 +223,7 @@ void Session::start_capture(function error_handler) // Begin the session sampling_thread_ = std::thread( - &Session::sample_thread_proc, this, device_, - error_handler); + &Session::sample_thread_proc, this, error_handler); } void Session::stop_capture() @@ -454,13 +457,12 @@ shared_ptr Session::signal_from_channel( return shared_ptr(); } -void Session::sample_thread_proc(shared_ptr device, - function error_handler) +void Session::sample_thread_proc(function error_handler) { - assert(device); assert(error_handler); - (void)device; + if (!device_) + return; cur_samplerate_ = device_->read_config(ConfigKey::SAMPLERATE);