From: Gerhard Sittig Date: Sat, 12 May 2018 06:31:52 +0000 (+0200) Subject: DecodeSignal: avoid specifying a zero samplerate to libsigrokdecode X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ba5b52e12e2d95c5ac9155cb697e002df5df1de6;p=pulseview.git DecodeSignal: avoid specifying a zero samplerate to libsigrokdecode When the sample rate is not known, avoid claiming the value would be zero and calling setup routines in backend libraries. Although the call is not strictly fatal, this simple check avoids potential log messages at callee's for this unexpected condition. --- diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index d60c53e4..e70947b2 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -1020,9 +1020,12 @@ void DecodeSignal::start_srd_session() terminate_srd_session(); // Metadata is cleared also, so re-set it + uint64_t samplerate = 0; if (segments_.size() > 0) + samplerate = segments_.at(current_segment_id_).samplerate; + if (samplerate) srd_session_metadata_set(srd_session_, SRD_CONF_SAMPLERATE, - g_variant_new_uint64(segments_.at(current_segment_id_).samplerate)); + g_variant_new_uint64(samplerate)); for (const shared_ptr &dec : stack_) dec->apply_all_options(); srd_session_start(srd_session_); @@ -1077,9 +1080,12 @@ void DecodeSignal::terminate_srd_session() srd_session_terminate_reset(srd_session_); // Metadata is cleared also, so re-set it + uint64_t samplerate = 0; if (segments_.size() > 0) + samplerate = segments_.at(current_segment_id_).samplerate; + if (samplerate) srd_session_metadata_set(srd_session_, SRD_CONF_SAMPLERATE, - g_variant_new_uint64(segments_.at(current_segment_id_).samplerate)); + g_variant_new_uint64(samplerate)); for (const shared_ptr &dec : stack_) dec->apply_all_options(); }