]> sigrok.org Git - pulseview.git/commitdiff
DecodeSignal: only pass non-zero sample rate to decoders
authorGerhard Sittig <redacted>
Sun, 28 Jan 2018 20:02:54 +0000 (21:02 +0100)
committerUwe Hermann <redacted>
Sun, 28 Jan 2018 20:58:16 +0000 (21:58 +0100)
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.

pv/data/decodesignal.cpp

index 2a3ad14b56743b5d7adb5b152aa76cfd03320807..1ff9d76d0a6c7309b821c406e93aaa7cc0108b33 100644 (file)
@@ -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);