From a2d4b5512a87a5d60e09fd69b6eec34332c714de Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Sat, 8 Feb 2014 16:42:18 +0000 Subject: [PATCH] Do not attempt to decode when required probes have not been specified This fixes 204 --- pv/data/decode/decoder.cpp | 12 ++++++++++++ pv/data/decode/decoder.h | 2 ++ pv/data/decoderstack.cpp | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/pv/data/decode/decoder.cpp b/pv/data/decode/decoder.cpp index 0404227..3767e48 100644 --- a/pv/data/decode/decoder.cpp +++ b/pv/data/decode/decoder.cpp @@ -84,6 +84,18 @@ void Decoder::set_option(const char *id, GVariant *value) _options[id] = value; } +bool Decoder::have_required_probes() const +{ + for (GSList *p = _decoder->probes; p; p = p->next) { + const srd_probe *const probe = (const srd_probe*)p->data; + assert(probe); + if (_probes.find(probe) == _probes.end()) + return false; + } + + return true; +} + srd_decoder_inst* Decoder::create_decoder_inst( srd_session *const session) const { diff --git a/pv/data/decode/decoder.h b/pv/data/decode/decoder.h index f96ba2b..0879558 100644 --- a/pv/data/decode/decoder.h +++ b/pv/data/decode/decoder.h @@ -62,6 +62,8 @@ public: void set_option(const char *id, GVariant *value); + bool have_required_probes() const; + srd_decoder_inst* create_decoder_inst( srd_session *const session) const; diff --git a/pv/data/decoderstack.cpp b/pv/data/decoderstack.cpp index 073dcd5..74ad7d3 100644 --- a/pv/data/decoderstack.cpp +++ b/pv/data/decoderstack.cpp @@ -246,11 +246,17 @@ void DecoderStack::decode_proc(shared_ptr data) assert(data); + // Check we have a snapshot of data const deque< shared_ptr > &snapshots = data->get_snapshots(); if (snapshots.empty()) return; + // Check that all decoders have the required probes + BOOST_FOREACH(const shared_ptr &dec, _stack) + if (!dec->have_required_probes()) + return; + const shared_ptr &snapshot = snapshots.front(); const int64_t sample_count = snapshot->get_sample_count(); -- 2.30.2