+ } while(0);
+
+ signals_changed();
+}
+
+bool SigSession::is_trigger_enabled() const
+{
+ assert(_sdi);
+ for (const GSList *l = _sdi->probes; l; l = l->next) {
+ const sr_probe *const p = (const sr_probe *)l->data;
+ assert(p);
+ if (p->trigger && p->trigger[0] != '\0')
+ return true;
+ }
+
+ return false;
+}
+
+shared_ptr<view::Signal> SigSession::signal_from_probe(
+ const sr_probe *probe) const
+{
+ lock_guard<mutex> lock(_signals_mutex);
+ BOOST_FOREACH(shared_ptr<view::Signal> sig, _signals) {
+ assert(sig);
+ if (sig->probe() == probe)
+ return sig;
+ }
+ return shared_ptr<view::Signal>();
+}
+
+void SigSession::read_sample_rate(const sr_dev_inst *const sdi)
+{
+ GVariant *gvar;
+ uint64_t sample_rate = 0;
+
+ // Read out the sample rate
+ if(sdi->driver)
+ {
+ const int ret = sr_config_get(sdi->driver, sdi, NULL,
+ SR_CONF_SAMPLERATE, &gvar);
+ if (ret != SR_OK) {
+ qDebug("Failed to get samplerate\n");
+ return;
+ }
+
+ sample_rate = g_variant_get_uint64(gvar);
+ g_variant_unref(gvar);
+ }
+
+ // Set the sample rate of all data
+ const set< shared_ptr<data::SignalData> > data_set = get_data();
+ BOOST_FOREACH(shared_ptr<data::SignalData> data, data_set) {
+ assert(data);
+ data->set_samplerate(sample_rate);
+ }
+}
+
+void SigSession::load_session_thread_proc(
+ function<void (const QString)> error_handler)
+{
+ (void)error_handler;
+
+ 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_snapshots.empty());
+}
+
+void SigSession::load_input_thread_proc(const string name,
+ sr_input *in, function<void (const QString)> error_handler)
+{
+ (void)error_handler;
+
+ assert(in);
+ assert(in->format);
+
+ sr_session_datafeed_callback_add(data_feed_in_proc, NULL);
+
+ set_capture_state(Running);
+
+ in->format->loadfile(in, name.c_str());
+
+ sr_session_destroy();
+ set_capture_state(Stopped);
+
+ // Confirm that SR_DF_END was received
+ assert(!_cur_logic_snapshot);
+ assert(_cur_analog_snapshots.empty());
+
+ delete in;
+}
+
+void SigSession::sample_thread_proc(struct sr_dev_inst *sdi,
+ uint64_t record_length,
+ function<void (const QString)> error_handler)
+{
+ assert(sdi);
+ assert(error_handler);
+
+ sr_session_new();
+ sr_session_datafeed_callback_add(data_feed_in_proc, NULL);
+
+ if (sr_session_dev_add(sdi) != SR_OK) {
+ error_handler(tr("Failed to use device."));
+ sr_session_destroy();
+ return;
+ }
+
+ // Set the sample limit
+ if (sr_config_set(sdi, NULL, SR_CONF_LIMIT_SAMPLES,
+ g_variant_new_uint64(record_length)) != SR_OK) {
+ error_handler(tr("Failed to configure "
+ "time-based sample limit."));
+ sr_session_destroy();
+ return;