X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fdecodesignal.cpp;h=9b40540c7032b058f988f8cb8d903d6763b3d97f;hp=9da7de6766c418e759ea1f02d88ba8ab8614c551;hb=c526a8fd78952bedc767f64009e0511b2f940f75;hpb=f98070844c2d468fdbb6beb5b65e4ccbbcd3f10b diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 9da7de6..9b40540 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -17,6 +17,7 @@ * along with this program; if not, see . */ +#include #include #include @@ -32,6 +33,7 @@ #include #include +using std::forward_list; using std::lock_guard; using std::make_pair; using std::make_shared; @@ -149,6 +151,8 @@ void DecodeSignal::reset_decode(bool shutting_down) logic_mux_thread_.join(); } + resume_decode(); // Make sure the decode thread isn't blocked by pausing + class_rows_.clear(); current_segment_id_ = 0; segments_.clear(); @@ -256,6 +260,25 @@ void DecodeSignal::begin_decode() decode_thread_ = std::thread(&DecodeSignal::decode_proc, this); } +void DecodeSignal::pause_decode() +{ + decode_paused_ = true; +} + +void DecodeSignal::resume_decode() +{ + // Manual unlocking is done before notifying, to avoid waking up the + // waiting thread only to block again (see notify_one for details) + decode_pause_mutex_.unlock(); + decode_pause_cond_.notify_one(); + decode_paused_ = false; +} + +bool DecodeSignal::is_paused() const +{ + return decode_paused_; +} + QString DecodeSignal::error_message() const { lock_guard lock(output_mutex_); @@ -280,14 +303,16 @@ void DecodeSignal::auto_assign_signals(const shared_ptr dec) if (ch.assigned_signal) continue; - const QString ch_name = ch.name.toLower(); + QString ch_name = ch.name.toLower(); + ch_name = ch_name.replace(QRegExp("[-_.]"), " "); shared_ptr match; for (shared_ptr s : session_.signalbases()) { if (!s->enabled()) continue; - const QString s_name = s->name().toLower(); + QString s_name = s->name().toLower(); + s_name = s_name.replace(QRegExp("[-_.]"), " "); if (s->logic_data() && ((ch_name.contains(s_name)) || (s_name.contains(ch_name)))) { @@ -471,6 +496,33 @@ void DecodeSignal::get_annotation_subset( } } +void DecodeSignal::get_annotation_subset( + vector &dest, + uint32_t segment_id, uint64_t start_sample, uint64_t end_sample) const +{ + // Note: We put all vectors and lists on the heap, not the stack + + const vector rows = visible_rows(); + + // Use forward_lists for faster merging + forward_list *all_ann_list = new forward_list(); + + for (const Row& row : rows) { + vector *ann_vector = new vector(); + get_annotation_subset(*ann_vector, row, segment_id, start_sample, end_sample); + + forward_list *ann_list = + new forward_list(ann_vector->begin(), ann_vector->end()); + delete ann_vector; + + all_ann_list->merge(*ann_list); + delete ann_list; + } + + move(all_ann_list->begin(), all_ann_list->end(), back_inserter(dest)); + delete all_ann_list; +} + void DecodeSignal::save_settings(QSettings &settings) const { SignalBase::save_settings(settings); @@ -952,6 +1004,11 @@ void DecodeSignal::decode_data( // Notify the frontend that we processed some data and // possibly have new annotations as well new_annotations(); + + if (decode_paused_) { + unique_lock pause_wait_lock(decode_pause_mutex_); + decode_pause_cond_.wait(pause_wait_lock); + } } } @@ -1225,7 +1282,7 @@ void DecodeSignal::annotation_callback(srd_proto_data *pdata, void *decode_signa } // Add the annotation - (*row_iter).second.emplace_annotation(pdata); + (*row_iter).second.emplace_annotation(pdata, &((*row_iter).first)); } void DecodeSignal::on_capture_state_changed(int state)