]> sigrok.org Git - pulseview.git/commitdiff
Moved file load into a thread
authorJoel Holdsworth <redacted>
Wed, 12 Dec 2012 21:49:15 +0000 (21:49 +0000)
committerJoel Holdsworth <redacted>
Wed, 12 Dec 2012 21:49:43 +0000 (21:49 +0000)
pv/sigsession.cpp
pv/sigsession.h

index e19291d40004d9bdaa5c7611eeaa1aa71e1f1e20..c8444c7dee8d4ea2e1b00e69e80f33862c1430d2 100644 (file)
@@ -55,15 +55,11 @@ SigSession::~SigSession()
        _session = NULL;
 }
 
        _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
 }
 
 SigSession::capture_state SigSession::get_capture_state() const
@@ -114,6 +110,28 @@ void SigSession::set_capture_state(capture_state state)
        capture_state_changed(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)
 {
 void SigSession::sample_thread_proc(struct sr_dev_inst *sdi,
        uint64_t record_length, uint64_t sample_rate)
 {
index b4f07db4394397579e8d429bf9d9ca3d763e88b5..68b14e11036f491d0acb6b19dad7717271566b4a 100644 (file)
@@ -76,6 +76,8 @@ private:
        void set_capture_state(capture_state state);
 
 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);
 
        void sample_thread_proc(struct sr_dev_inst *sdi,
                uint64_t record_length, uint64_t sample_rate);