From: Joel Holdsworth Date: Wed, 12 Dec 2012 21:49:15 +0000 (+0000) Subject: Moved file load into a thread X-Git-Tag: pulseview-0.1.0~197 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8a67bd9e5199279ac976412a66b5f6cbfdfc17ea;p=pulseview.git Moved file load into a thread --- diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index e19291d4..c8444c7d 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -55,15 +55,11 @@ SigSession::~SigSession() _session = NULL; } -void SigSession::load_file(const std::string &name) +void SigSession::load_file(const string &name) { - if (sr_session_load(name.c_str()) == SR_OK) { - /* sigrok session file */ - sr_session_datafeed_callback_add(data_feed_in_proc); - sr_session_start(); - sr_session_run(); - sr_session_stop(); - } + stop_capture(); + _sampling_thread.reset(new boost::thread( + &SigSession::load_thread_proc, this, name)); } SigSession::capture_state SigSession::get_capture_state() const @@ -114,6 +110,28 @@ void SigSession::set_capture_state(capture_state state) capture_state_changed(state); } +void SigSession::load_thread_proc(const string name) +{ + if (sr_session_load(name.c_str()) != SR_OK) { + qDebug() << "Failed to load file."; + return; + } + + sr_session_datafeed_callback_add(data_feed_in_proc); + + if (sr_session_start() != SR_OK) { + qDebug() << "Failed to start session."; + return; + } + + set_capture_state(Running); + + sr_session_run(); + sr_session_stop(); + + set_capture_state(Stopped); +} + void SigSession::sample_thread_proc(struct sr_dev_inst *sdi, uint64_t record_length, uint64_t sample_rate) { diff --git a/pv/sigsession.h b/pv/sigsession.h index b4f07db4..68b14e11 100644 --- a/pv/sigsession.h +++ b/pv/sigsession.h @@ -76,6 +76,8 @@ private: void set_capture_state(capture_state state); private: + void load_thread_proc(const std::string name); + void sample_thread_proc(struct sr_dev_inst *sdi, uint64_t record_length, uint64_t sample_rate);