From 8a7b603b295dacee7160eba8e577d6666472be9f Mon Sep 17 00:00:00 2001 From: Soeren Apel Date: Sat, 12 Dec 2015 15:01:03 +0100 Subject: [PATCH] Session: Allow using sample rate from meta packet Currently, PV only looks at the device config to determine the sample rate. This breaks as input filters submit meta packets containing the sample rate and provide no device config. Example: load any file in PV using the raw binary input filter and set the sample rate to anything but 0. PV will still show 'sa' as the time unit, indicating that it dismisses the sample rate information sent in the meta packet. This patch makes this work by using the sample rate if it wasn't already set from the device config. --- pv/session.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pv/session.cpp b/pv/session.cpp index 2a794f0f..ef1159ee 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -486,6 +486,11 @@ void Session::feed_in_meta(shared_ptr 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 break; default: -- 2.30.2