- // Check sampling isn't already active
- if(_sampling_thread.get())
- _sampling_thread->join();
+ if (_sdi)
+ _device_manager.release_device(_sdi);
+ if (sdi)
+ _device_manager.use_device(sdi, this);
+ _sdi = sdi;
+}
+
+void SigSession::release_device(struct sr_dev_inst *sdi)
+{
+ (void)sdi;
+
+ assert(_capture_state == Stopped);
+ _sdi = NULL;
+}
+
+void SigSession::load_file(const string &name,
+ function<void (const QString)> error_handler)
+{
+ stop_capture();
+ _sampling_thread.reset(new boost::thread(
+ &SigSession::load_thread_proc, this, name,
+ error_handler));
+}
+
+SigSession::capture_state SigSession::get_capture_state() const
+{
+ lock_guard<mutex> lock(_sampling_mutex);
+ return _capture_state;
+}
+
+void SigSession::start_capture(uint64_t record_length,
+ function<void (const QString)> error_handler)
+{
+ stop_capture();
+
+ // Check that a device instance has been selected.
+ if (!_sdi) {
+ qDebug() << "No device selected";
+ return;
+ }
+
+ // Check that at least one probe is enabled
+ const GSList *l;
+ for (l = _sdi->probes; l; l = l->next) {
+ sr_probe *const probe = (sr_probe*)l->data;
+ assert(probe);
+ if (probe->enabled)
+ break;
+ }