]> sigrok.org Git - pulseview.git/blobdiff - pv/session.cpp
Session: Allow an SR_DF_META packet to override the samplerate
[pulseview.git] / pv / session.cpp
index 80dad66ee929ef36974da0573cb982f3843b4e06..4aba385b687d22ac8764da163b3f552792580682 100644 (file)
@@ -511,6 +511,10 @@ void Session::load_file(QString file_name,
        const QString errorMessage(
                QString("Failed to load file %1").arg(file_name));
 
+       // In the absence of a caller's format spec, try to auto detect.
+       // Assume "sigrok session file" upon lookup miss.
+       if (!format)
+               format = device_manager_.context()->input_format_match(file_name.toStdString());
        try {
                if (format)
                        set_device(shared_ptr<devices::Device>(
@@ -1044,15 +1048,10 @@ void Session::feed_in_meta(shared_ptr<Meta> meta)
        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
+                       cur_samplerate_ = g_variant_get_uint64(entry.second.gobj());
                        break;
                default:
-                       // Unknown metadata is not an error.
+                       qDebug() << "Received meta data key" << entry.first->id() << ", ignoring.";
                        break;
                }
        }