From: Joel Holdsworth Date: Sun, 16 Feb 2014 11:46:21 +0000 (+0000) Subject: Begin a new decode session when a new frame begins X-Git-Tag: pulseview-0.2.0~41 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=82f50b10f8fd45a772f9ba40c4ef1f888ed6b8b1;p=pulseview.git Begin a new decode session when a new frame begins --- diff --git a/pv/data/decoderstack.cpp b/pv/data/decoderstack.cpp index 2c68ef80..e73cfc33 100644 --- a/pv/data/decoderstack.cpp +++ b/pv/data/decoderstack.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include using boost::lock_guard; @@ -63,6 +64,8 @@ DecoderStack::DecoderStack(pv::SigSession &session, _session(session), _samples_decoded(0) { + connect(&_session, SIGNAL(frame_began()), this, SLOT(on_new_frame())); + _stack.push_back(shared_ptr( new decode::Decoder(dec))); } @@ -373,5 +376,10 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder) d->new_decode_data(); } +void DecoderStack::on_new_frame() +{ + begin_decode(); +} + } // namespace data } // namespace pv diff --git a/pv/data/decoderstack.h b/pv/data/decoderstack.h index 6391e6a8..ad2a17b6 100644 --- a/pv/data/decoderstack.h +++ b/pv/data/decoderstack.h @@ -105,6 +105,9 @@ private: static void annotation_callback(srd_proto_data *pdata, void *decoder); +private slots: + void on_new_frame(); + signals: void new_decode_data(); diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 92118b48..1a5ac8ca 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -493,6 +493,12 @@ void SigSession::feed_in_meta(const sr_dev_inst *sdi, signals_changed(); } +void SigSession::feed_in_frame_begin() +{ + if (_cur_logic_snapshot || !_cur_analog_snapshots.empty()) + frame_began(); +} + void SigSession::feed_in_logic(const sr_datafeed_logic &logic) { lock_guard lock(_data_mutex); @@ -512,6 +518,12 @@ void SigSession::feed_in_logic(const sr_datafeed_logic &logic) _cur_logic_snapshot = shared_ptr( new data::LogicSnapshot(logic, _dev_inst->get_sample_limit())); _logic_data->push_snapshot(_cur_logic_snapshot); + + // @todo Putting this here means that only listeners querying + // for logic will be notified. Currently the only user of + // frame_began is DecoderStack, but in future we need to signal + // this after both analog and logic sweeps have begun. + frame_began(); } else { @@ -600,6 +612,10 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi, *(const sr_datafeed_meta*)packet->payload); break; + case SR_DF_FRAME_BEGIN: + feed_in_frame_begin(); + break; + case SR_DF_LOGIC: assert(packet->payload); feed_in_logic(*(const sr_datafeed_logic*)packet->payload); diff --git a/pv/sigsession.h b/pv/sigsession.h index 7e61d8df..6a8da068 100644 --- a/pv/sigsession.h +++ b/pv/sigsession.h @@ -145,6 +145,8 @@ private: void feed_in_meta(const sr_dev_inst *sdi, const sr_datafeed_meta &meta); + void feed_in_frame_begin(); + void feed_in_logic(const sr_datafeed_logic &logic); void feed_in_analog(const sr_datafeed_analog &analog); @@ -184,6 +186,8 @@ signals: void signals_changed(); + void frame_began(); + void data_updated(); private: