+ signals_changed();
+}
+
+shared_ptr<view::Signal> SigSession::signal_from_probe(
+ const sr_channel *probe) const
+{
+ lock_guard<mutex> lock(_signals_mutex);
+ for (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();
+ for (shared_ptr<data::SignalData> data : data_set) {
+ assert(data);
+ data->set_samplerate(sample_rate);
+ }
+}
+
+void SigSession::sample_thread_proc(shared_ptr<device::DevInst> dev_inst,
+ function<void (const QString)> error_handler)
+{
+ assert(dev_inst);
+ assert(dev_inst->dev_inst());
+ assert(error_handler);
+
+ read_sample_rate(dev_inst->dev_inst());
+
+ try {
+ dev_inst->start();
+ } catch(const QString e) {
+ error_handler(e);
+ return;
+ }
+
+ set_capture_state(dev_inst->is_trigger_enabled() ?
+ AwaitingTrigger : Running);
+
+ dev_inst->run();
+ set_capture_state(Stopped);
+
+ // Confirm that SR_DF_END was received
+ if (_cur_logic_snapshot)
+ {
+ qDebug("SR_DF_END was not received.");
+ assert(0);
+ }
+}
+
+void SigSession::feed_in_header(const sr_dev_inst *sdi)
+{
+ read_sample_rate(sdi);
+}
+
+void SigSession::feed_in_meta(const sr_dev_inst *sdi,
+ const sr_datafeed_meta &meta)
+{
+ (void)sdi;
+
+ for (const GSList *l = meta.config; l; l = l->next) {
+ const sr_config *const src = (const sr_config*)l->data;
+ switch (src->key) {
+ case SR_CONF_SAMPLERATE:
+ /// @todo handle samplerate changes
+ /// samplerate = (uint64_t *)src->value;
+ break;
+ default:
+ // Unknown metadata is not an error.
+ break;