]> sigrok.org Git - pulseview.git/commitdiff
DecodeSignal: Use signals for new data notification, not session
authorSoeren Apel <redacted>
Sun, 7 May 2017 15:51:14 +0000 (17:51 +0200)
committerUwe Hermann <redacted>
Wed, 5 Jul 2017 22:37:08 +0000 (00:37 +0200)
pv/data/decodesignal.cpp
pv/data/decodesignal.hpp

index 0e49398a44dc71757f6f2f531654629251adb2c6..a7bcee59c78185c9cd0d0540ac299ed4143505d4 100644 (file)
@@ -65,10 +65,6 @@ DecodeSignal::DecodeSignal(pv::Session &session) :
 {
        connect(&session_, SIGNAL(capture_state_changed(int)),
                this, SLOT(on_capture_state_changed(int)));
-       connect(&session_, SIGNAL(data_received()),
-               this, SLOT(on_data_received()));
-       connect(&session_, SIGNAL(frame_ended()),
-               this, SLOT(on_frame_ended()));
 
        set_name(tr("Empty decoder signal"));
 }
@@ -257,6 +253,9 @@ void DecodeSignal::begin_decode()
        // Decode the muxed logic data
        decode_interrupt_ = false;
        decode_thread_ = std::thread(&DecodeSignal::decode_proc, this);
+
+       // Receive notifications when new sample data is available
+       connect_input_notifiers();
 }
 
 QString DecodeSignal::error_message() const
@@ -588,7 +587,6 @@ void DecodeSignal::mux_logic_samples(const int64_t start, const int64_t end)
 void DecodeSignal::logic_mux_proc()
 {
        do {
-
                const uint64_t input_sample_count = get_working_sample_count();
                const uint64_t output_sample_count = segment_->get_sample_count();
 
@@ -736,6 +734,22 @@ void DecodeSignal::stop_srd_session()
        }
 }
 
+void DecodeSignal::connect_input_notifiers()
+{
+       // Disconnect the notification slot from the previous set of signals
+       disconnect(this, SLOT(on_data_received()));
+
+       // Connect the currently used signals to our slot
+       for (data::DecodeChannel &ch : channels_) {
+               if (!ch.assigned_signal)
+                       continue;
+
+               shared_ptr<Logic> logic_data = ch.assigned_signal->logic_data();
+               connect(logic_data.get(), SIGNAL(samples_added(QObject*, uint64_t, uint64_t)),
+                       this, SLOT(on_data_received()));
+       }
+}
+
 void DecodeSignal::annotation_callback(srd_proto_data *pdata, void *decode_signal)
 {
        assert(pdata);
@@ -793,10 +807,5 @@ void DecodeSignal::on_data_received()
        logic_mux_cond_.notify_one();
 }
 
-void DecodeSignal::on_frame_ended()
-{
-       logic_mux_cond_.notify_one();
-}
-
 } // namespace data
 } // namespace pv
index 8d0a29f475d4439dfa166f0fcb6e17bf10b30239..2d4d4e0c768a8a959e6bf25e3a0e97a7ad8603c0 100644 (file)
@@ -152,6 +152,8 @@ private:
        void start_srd_session();
        void stop_srd_session();
 
+       void connect_input_notifiers();
+
        static void annotation_callback(srd_proto_data *pdata, void *decode_signal);
 
 Q_SIGNALS:
@@ -161,7 +163,6 @@ Q_SIGNALS:
 private Q_SLOTS:
        void on_capture_state_changed(int state);
        void on_data_received();
-       void on_frame_ended();
 
 private:
        pv::Session &session_;