]> sigrok.org Git - pulseview.git/blobdiff - pv/session.cpp
Session: Allow using sample rate from meta packet
[pulseview.git] / pv / session.cpp
index da9c0e9bb4af998abf3a3303eb525536245b3ba9..ef1159ee599f8abfbf0a7e6b90d6c100eeef3f44 100644 (file)
@@ -324,9 +324,14 @@ void Session::remove_decode_signal(view::DecodeTrace *signal)
 
 void Session::set_capture_state(capture_state state)
 {
 
 void Session::set_capture_state(capture_state state)
 {
-       lock_guard<mutex> lock(sampling_mutex_);
-       const bool changed = capture_state_ != state;
-       capture_state_ = state;
+       bool changed;
+
+       {
+               lock_guard<mutex> lock(sampling_mutex_);
+               changed = capture_state_ != state;
+               capture_state_ = state;
+       }
+
        if (changed)
                capture_state_changed(state);
 }
        if (changed)
                capture_state_changed(state);
 }
@@ -481,6 +486,11 @@ void Session::feed_in_meta(shared_ptr<Meta> meta)
        for (auto entry : meta->config()) {
                switch (entry.first->id()) {
                case SR_CONF_SAMPLERATE:
        for (auto entry : meta->config()) {
                switch (entry.first->id()) {
                case SR_CONF_SAMPLERATE:
+                       // We can't rely on the header to always contain the sample rate,
+                       // so in case it's supplied via a meta packet, we use it.
+                       if (!cur_samplerate_)
+                               cur_samplerate_ = g_variant_get_uint64(entry.second.gobj());
+
                        /// @todo handle samplerate changes
                        break;
                default:
                        /// @todo handle samplerate changes
                        break;
                default: