From: Joel Holdsworth Date: Tue, 3 Sep 2013 11:49:25 +0000 (+0100) Subject: Read out the sample rate when loading files X-Git-Tag: pulseview-0.2.0~322 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=deef291c50ddb212b82f5b1c0a5f597dd7d567e6;p=pulseview.git Read out the sample rate when loading files Fixes bug #123 --- diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 41e31a28..e9349bba 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -106,9 +106,12 @@ void SigSession::load_file(const string &name, return; } - update_signals((sr_dev_inst*)devlist->data); + sr_dev_inst *const sdi = (sr_dev_inst*)devlist->data; g_slist_free(devlist); + update_signals(sdi); + read_sample_rate(sdi); + _sampling_thread.reset(new boost::thread( &SigSession::load_session_thread_proc, this, error_handler)); @@ -121,6 +124,7 @@ void SigSession::load_file(const string &name, return; update_signals(in->sdi); + read_sample_rate(in->sdi); _sampling_thread.reset(new boost::thread( &SigSession::load_input_thread_proc, this, @@ -367,6 +371,31 @@ bool SigSession::is_trigger_enabled() const return false; } +void SigSession::read_sample_rate(const sr_dev_inst *const sdi) +{ + GVariant *gvar; + uint64_t sample_rate = 0; + + // Read out the sample rate + if(sdi->driver) + { + const int ret = sr_config_get(sdi->driver, + SR_CONF_SAMPLERATE, &gvar, sdi); + if (ret != SR_OK) { + qDebug("Failed to get samplerate\n"); + return; + } + + sample_rate = g_variant_get_uint64(gvar); + g_variant_unref(gvar); + } + + if(_analog_data) + _analog_data->set_samplerate(sample_rate); + if(_logic_data) + _logic_data->set_samplerate(sample_rate); +} + void SigSession::load_session_thread_proc( function error_handler) { @@ -454,27 +483,7 @@ void SigSession::sample_thread_proc(struct sr_dev_inst *sdi, void SigSession::feed_in_header(const sr_dev_inst *sdi) { - GVariant *gvar; - uint64_t sample_rate = 0; - - // Read out the sample rate - if(sdi->driver) - { - const int ret = sr_config_get(sdi->driver, - SR_CONF_SAMPLERATE, &gvar, sdi); - if (ret != SR_OK) { - qDebug("Failed to get samplerate\n"); - return; - } - - sample_rate = g_variant_get_uint64(gvar); - g_variant_unref(gvar); - } - - if(_analog_data) - _analog_data->set_samplerate(sample_rate); - if(_logic_data) - _logic_data->set_samplerate(sample_rate); + read_sample_rate(sdi); } void SigSession::feed_in_meta(const sr_dev_inst *sdi, diff --git a/pv/sigsession.h b/pv/sigsession.h index 805f6ae0..88c603e2 100644 --- a/pv/sigsession.h +++ b/pv/sigsession.h @@ -96,6 +96,8 @@ private: bool is_trigger_enabled() const; + void read_sample_rate(const sr_dev_inst *const sdi); + private: /** * Attempts to autodetect the format. Failing that