From: Gerhard Sittig Date: Sun, 28 Jan 2018 20:02:54 +0000 (+0100) Subject: DecodeSignal: only pass non-zero sample rate to decoders X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=4349dc21e726fe6e9e1fba59f9f06a9bdc718078;p=pulseview.git DecodeSignal: only pass non-zero sample rate to decoders As reported in bug #1118 not all input sources provide a samplerate, and decoder instances may not cope with a rate spec of 0. Only pass non-zero sample rates to the decoder stack. This improves robustness in addition to the specific fix for #1118 in the decoders' implementations. --- diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 2a3ad14b..1ff9d76d 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -978,6 +978,8 @@ void DecodeSignal::decode_proc() void DecodeSignal::start_srd_session() { + uint64_t samplerate; + if (srd_session_) stop_srd_session(); @@ -1004,8 +1006,10 @@ void DecodeSignal::start_srd_session() } // Start the session - srd_session_metadata_set(srd_session_, SRD_CONF_SAMPLERATE, - g_variant_new_uint64(segments_.at(current_segment_id_).samplerate)); + samplerate = segments_.at(current_segment_id_).samplerate; + if (samplerate) + srd_session_metadata_set(srd_session_, SRD_CONF_SAMPLERATE, + g_variant_new_uint64(samplerate)); srd_pd_output_callback_add(srd_session_, SRD_OUTPUT_ANN, DecodeSignal::annotation_callback, this);