X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fsigsession.cpp;h=354082c7262c351a3fe09423761823e7beab302d;hp=782f9c791b472ab24bb848958e847ded490d63d5;hb=5ac961e325a9d2cbafdd8fae3a6704d7348cf19a;hpb=d5bf2c6ce9dfcffdc94c6b71c8f015e88b8bc2b8 diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 782f9c79..354082c7 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -40,6 +40,7 @@ namespace pv { SigSession* SigSession::_session = NULL; SigSession::SigSession() : + _sdi(NULL), _capture_state(Stopped) { // TODO: This should not be necessary @@ -58,6 +59,11 @@ SigSession::~SigSession() _session = NULL; } +void SigSession::set_device(struct sr_dev_inst *sdi) +{ + _sdi = sdi; +} + void SigSession::load_file(const string &name, function error_handler) { @@ -73,15 +79,20 @@ SigSession::capture_state SigSession::get_capture_state() const 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 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) @@ -95,7 +106,7 @@ void SigSession::start_capture(struct sr_dev_inst *sdi, // 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)); } @@ -221,7 +232,11 @@ void SigSession::feed_in_header(const sr_dev_inst *sdi) const int ret = sr_config_get(sdi->driver, SR_CONF_SAMPLERATE, &gvar, sdi); - assert(ret == SR_OK); + if (ret != SR_OK) { + qDebug("Failed to get samplerate\n"); + return; + } + sample_rate = g_variant_get_uint64(gvar); g_variant_unref(gvar);