From: Soeren Apel Date: Sat, 12 Dec 2015 14:01:03 +0000 (+0100) Subject: Session: Allow using sample rate from meta packet X-Git-Tag: pulseview-0.3.0~34 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8a7b603b295dacee7160eba8e577d6666472be9f;p=pulseview.git 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. --- 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: