]> sigrok.org Git - pulseview.git/commitdiff
Read out the sample rate when loading files
authorJoel Holdsworth <redacted>
Tue, 3 Sep 2013 11:49:25 +0000 (12:49 +0100)
committerJoel Holdsworth <redacted>
Tue, 3 Sep 2013 14:48:13 +0000 (15:48 +0100)
Fixes bug #123

pv/sigsession.cpp
pv/sigsession.h

index 41e31a2802a0af68c2d0505e2f3e3384ca96a010..e9349bba0efb1eae40e3cfa4f93dd5ddd9fc5e92 100644 (file)
@@ -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<void (const QString)> 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,
index 805f6ae07efda2f153a2514a24a64607b2e0f54d..88c603e20127baeb171d97b3ddbb154762c5d7cf 100644 (file)
@@ -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