From: Joel Holdsworth Date: Thu, 13 Dec 2012 21:45:54 +0000 (+0000) Subject: Factored out feed_in_meta_logic X-Git-Tag: pulseview-0.1.0~195 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b0e1d01d40977f5699745ecb53b89bc77ced8a5c;p=pulseview.git Factored out feed_in_meta_logic --- diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 42d8e552..3566807e 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -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 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 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 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 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 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 lock(_data_mutex); diff --git a/pv/sigsession.h b/pv/sigsession.h index 259356ee..15e247b5 100644 --- a/pv/sigsession.h +++ b/pv/sigsession.h @@ -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);