From: Soeren Apel Date: Fri, 5 Jan 2018 14:24:41 +0000 (+0100) Subject: Add segment_id to all segment classes X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=85a702806a15852f3684645dffdc38cb30274481;p=pulseview.git Add segment_id to all segment classes --- diff --git a/pv/data/analogsegment.cpp b/pv/data/analogsegment.cpp index 7a3d62d8..73a3084d 100644 --- a/pv/data/analogsegment.cpp +++ b/pv/data/analogsegment.cpp @@ -48,8 +48,8 @@ const int AnalogSegment::EnvelopeScaleFactor = 1 << EnvelopeScalePower; const float AnalogSegment::LogEnvelopeScaleFactor = logf(EnvelopeScaleFactor); const uint64_t AnalogSegment::EnvelopeDataUnit = 64 * 1024; // bytes -AnalogSegment::AnalogSegment(Analog& owner, uint64_t samplerate) : - Segment(samplerate, sizeof(float)), +AnalogSegment::AnalogSegment(Analog& owner, uint32_t segment_id, uint64_t samplerate) : + Segment(segment_id, samplerate, sizeof(float)), owner_(owner), min_value_(0), max_value_(0) diff --git a/pv/data/analogsegment.hpp b/pv/data/analogsegment.hpp index 8cb4d25b..5267e77e 100644 --- a/pv/data/analogsegment.hpp +++ b/pv/data/analogsegment.hpp @@ -79,7 +79,7 @@ private: static const uint64_t EnvelopeDataUnit; public: - AnalogSegment(Analog& owner, uint64_t samplerate); + AnalogSegment(Analog& owner, uint32_t segment_id, uint64_t samplerate); virtual ~AnalogSegment(); diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 1eff9119..eb7a0d3b 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -807,7 +807,8 @@ void DecodeSignal::logic_mux_proc() // Create initial logic mux segment shared_ptr output_segment = - make_shared(*logic_mux_data_, logic_mux_unit_size_, 0); + make_shared(*logic_mux_data_, segment_id, + logic_mux_unit_size_, 0); logic_mux_data_->push_segment(output_segment); output_segment->set_samplerate(get_input_samplerate(0)); @@ -847,7 +848,8 @@ void DecodeSignal::logic_mux_proc() segment_id++; output_segment = - make_shared(*logic_mux_data_, logic_mux_unit_size_, 0); + make_shared(*logic_mux_data_, segment_id, + logic_mux_unit_size_, 0); logic_mux_data_->push_segment(output_segment); output_segment->set_samplerate(get_input_samplerate(segment_id)); diff --git a/pv/data/logicsegment.cpp b/pv/data/logicsegment.cpp index 38f4bf24..4b32f38d 100644 --- a/pv/data/logicsegment.cpp +++ b/pv/data/logicsegment.cpp @@ -46,9 +46,9 @@ const int LogicSegment::MipMapScaleFactor = 1 << MipMapScalePower; const float LogicSegment::LogMipMapScaleFactor = logf(MipMapScaleFactor); const uint64_t LogicSegment::MipMapDataUnit = 64 * 1024; // bytes -LogicSegment::LogicSegment(pv::data::Logic& owner, unsigned int unit_size, - uint64_t samplerate) : - Segment(samplerate, unit_size), +LogicSegment::LogicSegment(pv::data::Logic& owner, uint32_t segment_id, + unsigned int unit_size, uint64_t samplerate) : + Segment(segment_id, samplerate, unit_size), owner_(owner), last_append_sample_(0) { diff --git a/pv/data/logicsegment.hpp b/pv/data/logicsegment.hpp index 3621e7f0..7becfc3e 100644 --- a/pv/data/logicsegment.hpp +++ b/pv/data/logicsegment.hpp @@ -77,7 +77,8 @@ public: typedef pair EdgePair; public: - LogicSegment(pv::data::Logic& owner, unsigned int unit_size, uint64_t samplerate); + LogicSegment(pv::data::Logic& owner, uint32_t segment_id, + unsigned int unit_size, uint64_t samplerate); virtual ~LogicSegment(); diff --git a/pv/data/segment.cpp b/pv/data/segment.cpp index 8745e874..9b18c649 100644 --- a/pv/data/segment.cpp +++ b/pv/data/segment.cpp @@ -33,7 +33,8 @@ namespace data { const uint64_t Segment::MaxChunkSize = 10 * 1024 * 1024; /* 10MiB */ -Segment::Segment(uint64_t samplerate, unsigned int unit_size) : +Segment::Segment(uint32_t segment_id, uint64_t samplerate, unsigned int unit_size) : + segment_id_(segment_id), sample_count_(0), start_time_(0), samplerate_(samplerate), @@ -90,6 +91,11 @@ unsigned int Segment::unit_size() const return unit_size_; } +uint32_t Segment::segment_id() const +{ + return segment_id_; +} + void Segment::set_complete() { is_complete_ = true; diff --git a/pv/data/segment.hpp b/pv/data/segment.hpp index 62750c11..18f1aed7 100644 --- a/pv/data/segment.hpp +++ b/pv/data/segment.hpp @@ -58,7 +58,7 @@ private: static const uint64_t MaxChunkSize; public: - Segment(uint64_t samplerate, unsigned int unit_size); + Segment(uint32_t segment_id, uint64_t samplerate, unsigned int unit_size); virtual ~Segment(); @@ -71,6 +71,8 @@ public: unsigned int unit_size() const; + uint32_t segment_id() const; + void set_complete(); bool is_complete() const; @@ -85,6 +87,7 @@ protected: void continue_raw_sample_iteration(SegmentRawDataIterator* it, uint64_t increase); void end_raw_sample_iteration(SegmentRawDataIterator* it); + uint32_t segment_id_; mutable recursive_mutex mutex_; vector data_chunks_; uint8_t* current_chunk_; diff --git a/pv/data/signalbase.cpp b/pv/data/signalbase.cpp index 018e4a27..f421e760 100644 --- a/pv/data/signalbase.cpp +++ b/pv/data/signalbase.cpp @@ -566,7 +566,7 @@ void SignalBase::conversion_thread_proc() // Create the initial logic data segment if needed if (logic_data->logic_segments().size() == 0) { shared_ptr new_segment = - make_shared(*logic_data.get(), 1, asegment->samplerate()); + make_shared(*logic_data.get(), 0, 1, asegment->samplerate()); logic_data->push_segment(new_segment); } @@ -588,8 +588,8 @@ void SignalBase::conversion_thread_proc() return; } - shared_ptr new_segment = - make_shared(*logic_data.get(), 1, asegment->samplerate()); + shared_ptr new_segment = make_shared( + *logic_data.get(), segment_id, 1, asegment->samplerate()); logic_data->push_segment(new_segment); lsegment = logic_data->logic_segments().back().get(); diff --git a/pv/session.cpp b/pv/session.cpp index 605cc05c..fb1732bb 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -1109,7 +1109,8 @@ void Session::feed_in_logic(shared_ptr logic) // Create a new data segment cur_logic_segment_ = make_shared( - *logic_data_, logic->unit_size(), cur_samplerate_); + *logic_data_, logic_data_->get_segment_count(), + logic->unit_size(), cur_samplerate_); logic_data_->push_segment(cur_logic_segment_); signal_new_segment(); @@ -1162,7 +1163,7 @@ void Session::feed_in_analog(shared_ptr analog) // Create a segment, keep it in the maps of channels segment = make_shared( - *data, cur_samplerate_); + *data, data->get_segment_count(), cur_samplerate_); cur_analog_segments_[channel] = segment; // Push the segment into the analog data.