+{
+ stop_capture();
+
+ lock_guard<mutex> lock(_sampling_mutex);
+ _sample_rate = sample_rate;
+
+ _sampling_thread.reset(new boost::thread(
+ &SigSession::sample_thread_proc, this, sdi,
+ record_length));
+}
+
+void SigSession::stop_capture()
+{
+ if (get_capture_state() == Stopped)
+ return;
+
+ sr_session_stop();
+
+ // Check that sampling stopped
+ if (_sampling_thread.get())
+ _sampling_thread->join();
+ _sampling_thread.reset();
+}
+
+vector< shared_ptr<view::Signal> > SigSession::get_signals()
+{
+ lock_guard<mutex> lock(_signals_mutex);
+ return _signals;
+}
+
+boost::shared_ptr<data::Logic> SigSession::get_data()
+{
+ return _logic_data;
+}
+
+void SigSession::set_capture_state(capture_state state)
+{
+ lock_guard<mutex> lock(_sampling_mutex);
+ _capture_state = state;
+ capture_state_changed(state);
+}
+
+void SigSession::load_thread_proc(const string name)
+{
+ if (sr_session_load(name.c_str()) != SR_OK) {
+ qDebug() << "Failed to load file.";
+ return;
+ }
+
+ sr_session_datafeed_callback_add(data_feed_in_proc);
+
+ if (sr_session_start() != SR_OK) {
+ qDebug() << "Failed to start session.";
+ return;
+ }
+
+ set_capture_state(Running);
+
+ sr_session_run();
+ sr_session_stop();
+
+ set_capture_state(Stopped);
+}
+
+void SigSession::sample_thread_proc(struct sr_dev_inst *sdi,
+ uint64_t record_length)