{
switch(_session.get_capture_state()) {
case SigSession::Stopped:
- _session.start_capture(
- _sampling_bar->get_selected_device(),
- _sampling_bar->get_record_length(),
+ _session.set_device(_sampling_bar->get_selected_device());
+ _session.start_capture(_sampling_bar->get_record_length(),
boost::bind(&MainWindow::session_error, this,
QString("Capture failed"), _1));
break;
SigSession* SigSession::_session = NULL;
SigSession::SigSession() :
+ _sdi(NULL),
_capture_state(Stopped)
{
// TODO: This should not be necessary
_session = NULL;
}
+struct sr_dev_inst* SigSession::get_device() const
+{
+ return _sdi;
+}
+
+void SigSession::set_device(struct sr_dev_inst *sdi)
+{
+ _sdi = sdi;
+}
+
void SigSession::load_file(const string &name,
function<void (const QString)> error_handler)
{
return _capture_state;
}
-void SigSession::start_capture(struct sr_dev_inst *sdi,
- uint64_t record_length,
+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) {
+ for (l = _sdi->probes; l; l = l->next) {
sr_probe *const probe = (sr_probe*)l->data;
assert(probe);
if (probe->enabled)
// Begin the session
_sampling_thread.reset(new boost::thread(
- &SigSession::sample_thread_proc, this, sdi,
+ &SigSession::sample_thread_proc, this, _sdi,
record_length, error_handler));
}
~SigSession();
+ /**
+ * Gets device instance that will be used in the next capture session.
+ */
+ struct sr_dev_inst* get_device() const;
+
+ /**
+ * Sets device instance that will be used in the next capture session.
+ */
+ void set_device(struct sr_dev_inst *sdi);
+
void load_file(const std::string &name,
boost::function<void (const QString)> error_handler);
capture_state get_capture_state() const;
- void start_capture(struct sr_dev_inst* sdi,
- uint64_t record_length,
+ void start_capture(uint64_t record_length,
boost::function<void (const QString)> error_handler);
void stop_capture();
const struct sr_datafeed_packet *packet, void *cb_data);
private:
+
+ /**
+ * The device instance that will be used in the next capture session.
+ */
+ struct sr_dev_inst *_sdi;
+
mutable boost::mutex _sampling_mutex;
capture_state _capture_state;