X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fdata%2Fdecodesignal.cpp;h=6f0e0fa7c50594632bf3305d3a01a56179f21f43;hb=02c87df7336eb81b770457b4153cf2dc649ffdab;hp=3420fa1c7efbed0c899de170fc4d191118c7ebdf;hpb=462941e2626cef9855e810abdb0458e99ee1c5f1;p=pulseview.git diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 3420fa1c..6f0e0fa7 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -33,7 +33,6 @@ #include #include -using std::forward_list; using std::lock_guard; using std::make_shared; using std::min; @@ -84,7 +83,7 @@ void DecodeSignal::stack_decoder(const srd_decoder *decoder, bool restart_decode if ((stack_.empty()) || ((stack_.size() > 0) && (name() == prev_dec_name))) set_name(QString::fromUtf8(decoder->name)); - const shared_ptr dec = make_shared(decoder); + const shared_ptr dec = make_shared(decoder, stack_.size()); stack_.push_back(dec); // Include the newly created decode channels in the channel lists @@ -141,6 +140,8 @@ bool DecodeSignal::toggle_decoder_visibility(int index) void DecodeSignal::reset_decode(bool shutting_down) { + resume_decode(); // Make sure the decode thread isn't blocked by pausing + if (stack_config_changed_ || shutting_down) stop_srd_session(); else @@ -158,8 +159,6 @@ void DecodeSignal::reset_decode(bool shutting_down) logic_mux_thread_.join(); } - resume_decode(); // Make sure the decode thread isn't blocked by pausing - current_segment_id_ = 0; segments_.clear(); @@ -643,6 +642,19 @@ const DecodeBinaryClass* DecodeSignal::get_binary_data_class(uint32_t segment_id return nullptr; } +const deque* DecodeSignal::get_all_annotations_by_segment( + uint32_t segment_id) const +{ + try { + const DecodeSegment *segment = &(segments_.at(segment_id)); + return &(segment->all_annotations); + } catch (out_of_range&) { + // Do nothing + } + + return nullptr; +} + void DecodeSignal::save_settings(QSettings &settings) const { SignalBase::save_settings(settings); @@ -738,7 +750,7 @@ void DecodeSignal::restore_settings(QSettings &settings) continue; if (QString::fromUtf8(dec->id) == id) { - shared_ptr decoder = make_shared(dec); + shared_ptr decoder = make_shared(dec, stack_.size()); stack_.push_back(decoder); decoder->set_visible(settings.value("visible", true).toBool()); @@ -786,7 +798,7 @@ void DecodeSignal::restore_settings(QSettings &settings) // Restore channel mapping unsigned int channels = settings.value("channels").toInt(); - const unordered_set< shared_ptr > signalbases = + const vector< shared_ptr > signalbases = session_.signalbases(); for (unsigned int channel_id = 0; channel_id < channels; channel_id++) { @@ -1380,7 +1392,7 @@ void DecodeSignal::connect_input_notifiers() void DecodeSignal::create_decode_segment() { // Create annotation segment - segments_.emplace_back(DecodeSegment()); + segments_.emplace_back(); // Add annotation classes for (const shared_ptr& dec : stack_) @@ -1408,6 +1420,9 @@ void DecodeSignal::annotation_callback(srd_proto_data *pdata, void *decode_signa if (ds->decode_interrupt_) return; + if (ds->segments_.empty()) + return; + lock_guard lock(ds->output_mutex_); // Get the decoder and the annotation data @@ -1436,8 +1451,15 @@ void DecodeSignal::annotation_callback(srd_proto_data *pdata, void *decode_signa if (!row) row = dec->get_row_by_id(0); - // Add the annotation - ds->segments_[ds->current_segment_id_].annotation_rows.at(row).emplace_annotation(pdata); + RowData& row_data = ds->segments_[ds->current_segment_id_].annotation_rows.at(row); + + // Add the annotation to the row + const Annotation* ann = row_data.emplace_annotation(pdata); + + // Add the annotation to the global annotation list + deque& all_annotations = + ds->segments_[ds->current_segment_id_].all_annotations; + all_annotations.emplace_back(ann); } void DecodeSignal::binary_callback(srd_proto_data *pdata, void *decode_signal)