From: Joel Holdsworth Date: Mon, 2 Sep 2013 13:32:36 +0000 (+0100) Subject: Enumerate probes when session is loaded X-Git-Tag: pulseview-0.2.0~323 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e8c9f8a5a3186f9c3e4f23ba4e35de7c59410bd3;p=pulseview.git Enumerate probes when session is loaded Fixes bug #126 --- diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 6d8e09d6..41e31a28 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -95,9 +95,38 @@ void SigSession::load_file(const string &name, function error_handler) { stop_capture(); - _sampling_thread.reset(new boost::thread( - &SigSession::load_thread_proc, this, name, - error_handler)); + + if (sr_session_load(name.c_str()) == SR_OK) { + GSList *devlist = NULL; + sr_session_dev_list(&devlist); + + if (!devlist || !devlist->data || + sr_session_start() != SR_OK) { + error_handler(tr("Failed to start session.")); + return; + } + + update_signals((sr_dev_inst*)devlist->data); + g_slist_free(devlist); + + _sampling_thread.reset(new boost::thread( + &SigSession::load_session_thread_proc, this, + error_handler)); + + } else { + sr_input *in = NULL; + + if (!(in = load_input_file_format(name.c_str(), + error_handler))) + return; + + update_signals(in->sdi); + + _sampling_thread.reset(new boost::thread( + &SigSession::load_input_thread_proc, this, + name, in, error_handler)); + } + } SigSession::capture_state SigSession::get_capture_state() const @@ -338,29 +367,38 @@ bool SigSession::is_trigger_enabled() const return false; } -void SigSession::load_thread_proc(const string name, +void SigSession::load_session_thread_proc( function error_handler) { - sr_input *in = NULL; + (void)error_handler; - if (sr_session_load(name.c_str()) == SR_OK) { - if (sr_session_start() != SR_OK) { - error_handler(tr("Failed to start session.")); - return; - } - } - else if(!(in = load_input_file_format(name.c_str(), error_handler))) - return; + sr_session_datafeed_callback_add(data_feed_in_proc, NULL); + + set_capture_state(Running); + + sr_session_run(); + + sr_session_destroy(); + set_capture_state(Stopped); + + // Confirm that SR_DF_END was received + assert(!_cur_logic_snapshot); + assert(!_cur_analog_snapshot); +} + +void SigSession::load_input_thread_proc(const string name, + sr_input *in, function error_handler) +{ + (void)error_handler; + + assert(in); + assert(in->format); sr_session_datafeed_callback_add(data_feed_in_proc, NULL); set_capture_state(Running); - if(in) { - assert(in->format); - in->format->loadfile(in, name.c_str()); - } else - sr_session_run(); + in->format->loadfile(in, name.c_str()); sr_session_destroy(); set_capture_state(Stopped); diff --git a/pv/sigsession.h b/pv/sigsession.h index 296f28d5..805f6ae0 100644 --- a/pv/sigsession.h +++ b/pv/sigsession.h @@ -112,7 +112,10 @@ private: boost::function error_handler, sr_input_format *format = NULL); - void load_thread_proc(const std::string name, + void load_session_thread_proc( + boost::function error_handler); + + void load_input_thread_proc(const std::string name, sr_input *in, boost::function error_handler); void sample_thread_proc(struct sr_dev_inst *sdi,