From: Soeren Apel Date: Mon, 23 Nov 2020 22:49:11 +0000 (+0100) Subject: Fix #1629 by not reallocating DecodeSegments X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=9431e2d3d256f3602c3637847a8ec3ad3fdcd590 Fix #1629 by not reallocating DecodeSegments Doing so called the empty DecodeSegment copy constructor, creating empty DecodeSegment instances. Also fixes an off-by-one bug that prevented the final input segment from being processed. --- diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index bda8d51e..640e5814 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -1173,14 +1173,12 @@ void DecodeSignal::logic_mux_proc() logic_mux_data_->push_segment(output_segment); output_segment->set_samplerate(get_input_samplerate(segment_id)); + } else { + // Wait for more input data if we're processing the currently last segment + unique_lock logic_mux_lock(logic_mux_mutex_); + logic_mux_cond_.wait(logic_mux_lock); } } - - if (segment_id == (get_input_segment_count() - 1)) { - // Wait for more input data if we're processing the currently last segment - unique_lock logic_mux_lock(logic_mux_mutex_); - logic_mux_cond_.wait(logic_mux_lock); - } } } while (!logic_mux_interrupt_); } @@ -1305,14 +1303,13 @@ void DecodeSignal::decode_proc() // All segments have been processed if (!decode_interrupt_) decode_finished(); + + // Wait for more input data + unique_lock input_wait_lock(input_mutex_); + decode_input_cond_.wait(input_wait_lock); } } - if (current_segment_id_ == (logic_mux_data_->logic_segments().size() - 1)) { - // Wait for more input data if we're processing the currently last segment - unique_lock input_wait_lock(input_mutex_); - decode_input_cond_.wait(input_wait_lock); - } } } while (!decode_interrupt_); } diff --git a/pv/data/decodesignal.hpp b/pv/data/decodesignal.hpp index fad3db78..f4783be2 100644 --- a/pv/data/decodesignal.hpp +++ b/pv/data/decodesignal.hpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -79,7 +80,7 @@ struct DecodeSegment // Constructor is a no-op DecodeSegment() { }; // Copy constructor is a no-op - DecodeSegment(DecodeSegment&& ds) { (void)ds; }; + DecodeSegment(DecodeSegment&& ds) { (void)ds; qCritical() << "Empty DecodeSegment copy constructor called"; }; map annotation_rows; // Note: Row is the same for all segments while RowData is not pv::util::Timestamp start_time; @@ -246,7 +247,7 @@ private: vector< shared_ptr > stack_; bool stack_config_changed_; - vector segments_; + deque segments_; uint32_t current_segment_id_; mutable mutex input_mutex_, output_mutex_, decode_pause_mutex_, logic_mux_mutex_;