+ // Create data containers for the logic data snapshots
+ {
+ lock_guard<mutex> data_lock(_data_mutex);
+
+ _logic_data.reset();
+ if (logic_probe_count != 0) {
+ _logic_data.reset(new data::Logic(
+ logic_probe_count));
+ assert(_logic_data);
+ }
+ }
+
+ // Make the Signals list
+ do {
+ lock_guard<mutex> lock(_signals_mutex);
+
+ _signals.clear();
+
+ if(!sdi)
+ break;
+
+ for (const GSList *l = sdi->probes; l; l = l->next) {
+ shared_ptr<view::Signal> signal;
+ sr_probe *const probe = (sr_probe *)l->data;
+ assert(probe);
+
+ switch(probe->type) {
+ case SR_PROBE_LOGIC:
+ signal = shared_ptr<view::Signal>(
+ new view::LogicSignal(*this, probe,
+ _logic_data));
+ break;
+
+ case SR_PROBE_ANALOG:
+ {
+ shared_ptr<data::Analog> data(
+ new data::Analog());
+ signal = shared_ptr<view::Signal>(
+ new view::AnalogSignal(*this, probe,
+ data));
+ break;
+ }
+
+ default:
+ assert(0);
+ break;
+ }
+
+ assert(signal);
+ _signals.push_back(signal);
+ }
+
+ } 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."));