+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;
+ }
+
+ if (sr_session_start() != SR_OK) {
+ error_handler(tr("Failed to start session."));
+ return;
+ }
+
+ set_capture_state(is_trigger_enabled() ? AwaitingTrigger : Running);
+
+ sr_session_run();
+ sr_session_destroy();
+
+ 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);
+}
+