]> sigrok.org Git - pulseview.git/commitdiff
Add segment_id to all segment classes
authorSoeren Apel <redacted>
Fri, 5 Jan 2018 14:24:41 +0000 (15:24 +0100)
committerUwe Hermann <redacted>
Tue, 9 Jan 2018 23:34:39 +0000 (00:34 +0100)
pv/data/analogsegment.cpp
pv/data/analogsegment.hpp
pv/data/decodesignal.cpp
pv/data/logicsegment.cpp
pv/data/logicsegment.hpp
pv/data/segment.cpp
pv/data/segment.hpp
pv/data/signalbase.cpp
pv/session.cpp

index 7a3d62d880ff912356f7daac4bf962af6d1611b5..73a3084dde3c1b8afdb2df57f8c24d7eb24003e0 100644 (file)
@@ -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)
index 8cb4d25b9d78648133a470a8eb9974951b3b4ddc..5267e77e604ed27fa6f3d3ad09ea4779e9d1f3e3 100644 (file)
@@ -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();
 
index 1eff9119f319de72fb1bfde4d1f13ec93e7228d6..eb7a0d3b78557f413ba10a57fdf477681a13c75f 100644 (file)
@@ -807,7 +807,8 @@ void DecodeSignal::logic_mux_proc()
 
        // Create initial logic mux segment
        shared_ptr<LogicSegment> output_segment =
-               make_shared<LogicSegment>(*logic_mux_data_, logic_mux_unit_size_, 0);
+               make_shared<LogicSegment>(*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<LogicSegment>(*logic_mux_data_, logic_mux_unit_size_, 0);
+                                       make_shared<LogicSegment>(*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));
index 38f4bf246c21a619e531be955af26075678c2569..4b32f38d89992a6500293d0d462489a77a9e3243 100644 (file)
@@ -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)
 {
index 3621e7f03a6944944a6f07533a55192e406b7c33..7becfc3e70c1fc47abacc7dcd124e6c09f0f11a7 100644 (file)
@@ -77,7 +77,8 @@ public:
        typedef pair<int64_t, bool> 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();
 
index 8745e8740dc582f8a53d33ae7ed8e81d36a87398..9b18c6499a1b32cf03362dc67e835f410acb9159 100644 (file)
@@ -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;
index 62750c11c9c62e0d0de0f948e8d4896417970a22..18f1aed77192978ce1a87cbb86aaf7b929672f73 100644 (file)
@@ -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<uint8_t*> data_chunks_;
        uint8_t* current_chunk_;
index 018e4a2733fca8f813efeff6f9b9c0fd1dd6a9f6..f421e7609de8f1ccb7bfce95905bec16b62cf7a6 100644 (file)
@@ -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<LogicSegment> new_segment =
-                       make_shared<LogicSegment>(*logic_data.get(), 1, asegment->samplerate());
+                       make_shared<LogicSegment>(*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<LogicSegment> new_segment =
-                               make_shared<LogicSegment>(*logic_data.get(), 1, asegment->samplerate());
+                       shared_ptr<LogicSegment> new_segment = make_shared<LogicSegment>(
+                               *logic_data.get(), segment_id, 1, asegment->samplerate());
                        logic_data->push_segment(new_segment);
 
                        lsegment = logic_data->logic_segments().back().get();
index 605cc05c65fd8ab234f5509d5885f30f276f805d..fb1732bbe79a0d37e81830856aa91339b27d3744 100644 (file)
@@ -1109,7 +1109,8 @@ void Session::feed_in_logic(shared_ptr<Logic> logic)
 
                // Create a new data segment
                cur_logic_segment_ = make_shared<data::LogicSegment>(
-                       *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> analog)
 
                        // Create a segment, keep it in the maps of channels
                        segment = make_shared<data::AnalogSegment>(
-                               *data, cur_samplerate_);
+                               *data, data->get_segment_count(), cur_samplerate_);
                        cur_analog_segments_[channel] = segment;
 
                        // Push the segment into the analog data.