+ [](decode::DecodeChannel ch) { return ch.assigned_signal.get(); });
+}
+
+void DecodeSignal::update_output_signals()
+{
+ for (const shared_ptr<decode::Decoder>& dec : stack_) {
+ assert(dec);
+
+ if (dec->has_logic_output()) {
+ const vector<decode::DecoderLogicOutputChannel> logic_channels =
+ dec->logic_output_channels();
+
+ // All signals of a decoder share the same LogicSegment, so it's
+ // sufficient to check for only the first channel
+ const decode::DecoderLogicOutputChannel& first_ch = logic_channels[0];
+
+ bool ch_exists = false;
+ for (const shared_ptr<SignalBase>& signal : output_signals_)
+ if (signal->internal_name() == first_ch.id)
+ ch_exists = true;
+
+ if (!ch_exists) {
+ shared_ptr<Logic> logic_data = make_shared<Logic>(logic_channels.size());
+ logic_data->set_samplerate(get_samplerate());
+ output_logic_[dec->get_srd_decoder()] = logic_data;
+
+ shared_ptr<LogicSegment> logic_segment = make_shared<data::LogicSegment>(
+ *logic_data, 0, (logic_data->num_channels() + 7) / 8, get_samplerate());
+ logic_data->push_segment(logic_segment);
+
+ uint index = 0;
+ for (const decode::DecoderLogicOutputChannel& logic_ch : logic_channels) {
+ shared_ptr<data::SignalBase> signal =
+ make_shared<data::SignalBase>(nullptr, LogicChannel);
+ signal->set_internal_name(logic_ch.id);
+ signal->set_name(logic_ch.id);
+ signal->set_index(index);
+ signal->set_data(logic_data);
+ output_signals_.push_back(signal);
+ session_.add_generated_signal(signal);
+ index++;
+ }
+ } else {
+ shared_ptr<Logic> logic_data = output_logic_[dec->get_srd_decoder()];
+ logic_data->set_samplerate(get_samplerate());
+ for (shared_ptr<LogicSegment>& segment : logic_data->logic_segments())
+ segment->set_samplerate(get_samplerate());
+ }
+ }
+ }
+
+ // TODO Delete signals that no longer have a corresponding decoder (also from session)
+ // TODO Assert that all sample rates are the same as the session's
+ // TODO Set colors to the same as the decoder's background color