+void SigSession::feed_in_analog(const sr_datafeed_analog &analog)
+{
+ lock_guard<mutex> lock(_data_mutex);
+
+ const unsigned int probe_count = g_slist_length(analog.probes);
+ const size_t sample_count = analog.num_samples / probe_count;
+ const float *data = analog.data;
+ bool sweep_beginning = false;
+
+ for (GSList *p = analog.probes; p; p = p->next)
+ {
+ shared_ptr<data::AnalogSnapshot> snapshot;
+
+ sr_probe *const probe = (sr_probe*)p->data;
+ assert(probe);
+
+ // Try to get the snapshot of the probe
+ const map< const sr_probe*, shared_ptr<data::AnalogSnapshot> >::
+ iterator iter = _cur_analog_snapshots.find(probe);
+ if (iter != _cur_analog_snapshots.end())
+ snapshot = (*iter).second;
+ else
+ {
+ // If no snapshot was found, this means we havn't
+ // created one yet. i.e. this is the first packet
+ // in the sweep containing this snapshot.
+ sweep_beginning = true;
+
+ // Create a snapshot, keep it in the maps of probes
+ snapshot = shared_ptr<data::AnalogSnapshot>(
+ new data::AnalogSnapshot(_dev_inst->get_sample_limit()));
+ _cur_analog_snapshots[probe] = snapshot;
+
+ // Find the annalog data associated with the probe
+ shared_ptr<view::AnalogSignal> sig =
+ dynamic_pointer_cast<view::AnalogSignal>(
+ signal_from_probe(probe));
+ assert(sig);
+
+ shared_ptr<data::Analog> data(sig->analog_data());
+ assert(data);
+
+ // Push the snapshot into the analog data.
+ data->push_snapshot(snapshot);
+ }
+
+ assert(snapshot);
+
+ // Append the samples in the snapshot
+ snapshot->append_interleaved_samples(data++, sample_count,
+ probe_count);
+ }
+
+ if (sweep_beginning) {
+ // This could be the first packet after a trigger
+ set_capture_state(Running);
+ }
+
+ data_updated();
+}