]> sigrok.org Git - pulseview.git/commitdiff
Begin a new decode session when a new frame begins
authorJoel Holdsworth <redacted>
Sun, 16 Feb 2014 11:46:21 +0000 (11:46 +0000)
committerJoel Holdsworth <redacted>
Sun, 2 Mar 2014 17:39:58 +0000 (17:39 +0000)
pv/data/decoderstack.cpp
pv/data/decoderstack.h
pv/sigsession.cpp
pv/sigsession.h

index 2c68ef80d2a58e1b06531d4dbafd7d1f32ef14e2..e73cfc3371bcda03c8b1a955eca71285a3dd0833 100644 (file)
@@ -33,6 +33,7 @@
 #include <pv/data/logicsnapshot.h>
 #include <pv/data/decode/decoder.h>
 #include <pv/data/decode/annotation.h>
+#include <pv/sigsession.h>
 #include <pv/view/logicsignal.h>
 
 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<decode::Decoder>(
                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
index 6391e6a88ceb0b2d4c57e41f85591401446bf531..ad2a17b6b593c79b0ddbeff9c70823fb5d508d3c 100644 (file)
@@ -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();
 
index 92118b4816711f32d06b314c56e211b327ff7e25..1a5ac8cad96405655af7cfd0ca0211d6695b3e2d 100644 (file)
@@ -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<mutex> lock(_data_mutex);
@@ -512,6 +518,12 @@ void SigSession::feed_in_logic(const sr_datafeed_logic &logic)
                _cur_logic_snapshot = shared_ptr<data::LogicSnapshot>(
                        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);
index 7e61d8dfab705f89c1277278b21a0c522cd53c45..6a8da068cde4fbd1d795cf2ebd6a39f4e214d04e 100644 (file)
@@ -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: