+ }
+
+ signals_changed();
+}
+
+void Session::feed_in_frame_begin()
+{
+ if (cur_logic_snapshot_ || !cur_analog_snapshots_.empty())
+ frame_began();
+}
+
+void Session::feed_in_logic(shared_ptr<Logic> logic)
+{
+ lock_guard<mutex> lock(data_mutex_);
+
+ if (!logic_data_)
+ {
+ qDebug() << "Unexpected logic packet";
+ return;
+ }
+
+ if (!cur_logic_snapshot_)
+ {
+ // This could be the first packet after a trigger
+ set_capture_state(Running);
+
+ // Get sample limit.
+ const auto keys = device_->config_keys(
+ ConfigKey::DEVICE_OPTIONS);
+ const auto iter = keys.find(ConfigKey::LIMIT_SAMPLES);
+ const uint64_t sample_limit = (iter != keys.end() &&
+ (*iter).second.find(sigrok::GET) !=
+ (*iter).second.end()) ?
+ VariantBase::cast_dynamic<Variant<guint64>>(
+ device_->config_get(ConfigKey::LIMIT_SAMPLES)).get() : 0;
+
+ // Create a new data snapshot
+ cur_logic_snapshot_ = shared_ptr<data::LogicSnapshot>(
+ new data::LogicSnapshot(logic, 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
+ {
+ // Append to the existing data snapshot
+ cur_logic_snapshot_->append_payload(logic);
+ }
+
+ data_received();
+}
+
+void Session::feed_in_analog(shared_ptr<Analog> analog)
+{
+ lock_guard<mutex> lock(data_mutex_);
+
+ const vector<shared_ptr<Channel>> channels = analog->channels();
+ const unsigned int channel_count = channels.size();
+ const size_t sample_count = analog->num_samples() / channel_count;
+ const float *data = analog->data_pointer();
+ bool sweep_beginning = false;
+
+ for (auto channel : channels)
+ {
+ shared_ptr<data::AnalogSnapshot> snapshot;
+
+ // Try to get the snapshot of the channel
+ const map< shared_ptr<Channel>, shared_ptr<data::AnalogSnapshot> >::
+ iterator iter = cur_analog_snapshots_.find(channel);
+ if (iter != cur_analog_snapshots_.end())
+ snapshot = (*iter).second;