X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fdata%2Fsegment.cpp;h=433e7536bbf9cd973c3a2a5af4fec2666d12de1c;hb=51d3950ff93b166ce2034920b8e48594298e544a;hp=86211f8218f52d02eb8ed59df0e2eecf998379a9;hpb=6f925ba9d6faf1077b73c5a5808259576081716a;p=pulseview.git diff --git a/pv/data/segment.cpp b/pv/data/segment.cpp index 86211f8..433e753 100644 --- a/pv/data/segment.cpp +++ b/pv/data/segment.cpp @@ -23,17 +23,15 @@ #include #include #include -#include using std::lock_guard; using std::min; using std::recursive_mutex; -using std::vector; namespace pv { namespace data { -const uint64_t Segment::MaxChunkSize = 10*1024*1024; /* 10MiB */ +const uint64_t Segment::MaxChunkSize = 10 * 1024 * 1024; /* 10MiB */ Segment::Segment(uint64_t samplerate, unsigned int unit_size) : sample_count_(0), @@ -119,8 +117,7 @@ void Segment::append_single_sample(void *data) // There will always be space for at least one sample in // the current chunk, so we do not need to test for space - memcpy(current_chunk_ + (used_samples_ * unit_size_), - data, unit_size_); + memcpy(current_chunk_ + (used_samples_ * unit_size_), data, unit_size_); used_samples_++; unused_samples_--; @@ -222,16 +219,12 @@ SegmentRawDataIterator* Segment::begin_raw_sample_iteration(uint64_t start) void Segment::continue_raw_sample_iteration(SegmentRawDataIterator* it, uint64_t increase) { - lock_guard lock(mutex_); - + // Fail gracefully if we are asked to deliver data we don't have if (it->sample_index > sample_count_) - { - // Fail gracefully if we are asked to deliver data we don't have return; - } else { - it->sample_index += increase; - it->chunk_offs += (increase * unit_size_); - } + + it->sample_index += increase; + it->chunk_offs += (increase * unit_size_); if (it->chunk_offs > (chunk_size_ - 1)) { it->chunk_num++; @@ -254,6 +247,5 @@ void Segment::end_raw_sample_iteration(SegmentRawDataIterator* it) } } - } // namespace data } // namespace pv