From: Jon Burgess Date: Sat, 13 Oct 2018 21:26:25 +0000 (+0100) Subject: Expose length of valid data in segment chunk X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=50e56db003055e96c5a12e675889e4afad07b65c;p=pulseview.git Expose length of valid data in segment chunk --- diff --git a/pv/data/segment.cpp b/pv/data/segment.cpp index 6ea17ff6..ef555292 100644 --- a/pv/data/segment.cpp +++ b/pv/data/segment.cpp @@ -289,5 +289,13 @@ uint8_t* Segment::get_iterator_value(SegmentDataIterator* it) return (it->chunk + it->chunk_offs); } +uint64_t Segment::get_iterator_valid_length(SegmentDataIterator* it) +{ + assert(it->sample_index <= (sample_count_ - 1)); + + return ((chunk_size_ - it->chunk_offs) / unit_size_); +} + + } // namespace data } // namespace pv diff --git a/pv/data/segment.hpp b/pv/data/segment.hpp index 4c6c36af..f5a00c95 100644 --- a/pv/data/segment.hpp +++ b/pv/data/segment.hpp @@ -90,6 +90,7 @@ protected: void continue_sample_iteration(SegmentDataIterator* it, uint64_t increase); void end_sample_iteration(SegmentDataIterator* it); uint8_t* get_iterator_value(SegmentDataIterator* it); + uint64_t get_iterator_valid_length(SegmentDataIterator* it); uint32_t segment_id_; mutable recursive_mutex mutex_;