]> sigrok.org Git - pulseview.git/commitdiff
Factored out feed_in_meta_logic
authorJoel Holdsworth <redacted>
Thu, 13 Dec 2012 21:45:54 +0000 (21:45 +0000)
committerJoel Holdsworth <redacted>
Thu, 20 Dec 2012 08:02:43 +0000 (08:02 +0000)
pv/sigsession.cpp
pv/sigsession.h

index 42d8e5520a379b1de3c024daa144bb6c5649892a..3566807e633fe07f14e2b587362e29bbd6a24d44 100644 (file)
@@ -171,62 +171,61 @@ void SigSession::sample_thread_proc(struct sr_dev_inst *sdi,
        set_capture_state(Stopped);
 }
 
-void SigSession::data_feed_in(const struct sr_dev_inst *sdi,
-       const struct sr_datafeed_packet *packet)
+void SigSession::feed_in_meta_logic(const struct sr_dev_inst *sdi,
+       const sr_datafeed_meta_logic &meta_logic)
 {
        using view::LogicSignal;
 
-       assert(sdi);
-       assert(packet);
-
-       switch (packet->type) {
-       case SR_DF_HEADER:
-       {
-               lock_guard<mutex> lock(_signals_mutex);
-               _signals.clear();
-               break;
-       }
-
-       case SR_DF_META_LOGIC:
-       {
-               assert(packet->payload);
-               const sr_datafeed_meta_logic &meta_logic =
-                       *(sr_datafeed_meta_logic*)packet->payload;
-
        {
                lock_guard<mutex> lock(_data_mutex);
 
-               // Create an empty LogiData for coming data snapshots
+               // Create an empty LogicData for coming data snapshots
                _logic_data.reset(new LogicData(meta_logic));
                assert(_logic_data);
                if (!_logic_data)
-                       break;
+                       return;
        }
 
        {
                lock_guard<mutex> lock(_signals_mutex);
 
                // Add the signals
-               for (int i = 0; i < meta_logic.num_probes; i++)
-               {
+               for (int i = 0; i < meta_logic.num_probes; i++) {
                        const sr_probe *const probe =
                                (const sr_probe*)g_slist_nth_data(
                                        sdi->probes, i);
-                       if (probe->enabled)
-                       {
+                       if (probe->enabled) {
                                shared_ptr<LogicSignal> signal(
                                        new LogicSignal(probe->name,
-                                               _logic_data,
-                                               probe->index));
+                                               _logic_data, probe->index));
                                _signals.push_back(signal);
                        }
                }
 
                signals_changed();
-               break;
        }
+}
+
+void SigSession::data_feed_in(const struct sr_dev_inst *sdi,
+       const struct sr_datafeed_packet *packet)
+{
+       assert(sdi);
+       assert(packet);
+
+       switch (packet->type) {
+       case SR_DF_HEADER:
+       {
+               lock_guard<mutex> lock(_signals_mutex);
+               _signals.clear();
+               break;
        }
 
+       case SR_DF_META_LOGIC:
+               assert(packet->payload);
+               feed_in_meta_logic(sdi,
+                       *(const sr_datafeed_meta_logic*)packet->payload);
+               break;
+
        case SR_DF_LOGIC:
        {
                lock_guard<mutex> lock(_data_mutex);
index 259356eef263b655a50c83ddb2da9604ac19cfa2..15e247b5953938c72f1e3c0639f8cae8ad031644 100644 (file)
@@ -81,6 +81,9 @@ private:
        void sample_thread_proc(struct sr_dev_inst *sdi,
                uint64_t record_length, uint64_t sample_rate);
 
+       void feed_in_meta_logic(const struct sr_dev_inst *sdi,
+               const sr_datafeed_meta_logic &meta_logic);
+
        void data_feed_in(const struct sr_dev_inst *sdi,
                const struct sr_datafeed_packet *packet);