SigSession* SigSession::_session = NULL;
SigSession::SigSession() :
+ _sdi(NULL),
_capture_state(Stopped)
{
// TODO: This should not be necessary
_session = NULL;
}
+void SigSession::set_device(struct sr_dev_inst *sdi)
+{
+ if (_sdi)
+ sr_dev_close(_sdi);
+ if (sdi)
+ sr_dev_open(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));
}
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);