+
+ if (_sdi)
+ _device_manager.release_device(_sdi);
+ if (sdi)
+ _device_manager.use_device(sdi, this);
+ _sdi = sdi;
+ update_signals(sdi);
+}
+
+void SigSession::release_device(struct sr_dev_inst *sdi)
+{
+ (void)sdi;
+
+ assert(_capture_state == Stopped);
+ _sdi = NULL;
+ update_signals(NULL);
+}
+
+void SigSession::load_file(const string &name,
+ function<void (const QString)> error_handler)
+{
+ stop_capture();
+
+ 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;
+ }
+
+ sr_dev_inst *const sdi = (sr_dev_inst*)devlist->data;
+ g_slist_free(devlist);
+
+ _decode_traces.clear();
+ update_signals(sdi);
+ read_sample_rate(sdi);
+
+ _sampling_thread = 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;
+
+ _decode_traces.clear();
+ update_signals(in->sdi);
+ read_sample_rate(in->sdi);
+
+ _sampling_thread = boost::thread(
+ &SigSession::load_input_thread_proc, this,
+ name, in, error_handler);
+ }