From: Joel Holdsworth Date: Mon, 26 Aug 2013 21:11:17 +0000 (+0100) Subject: Added LogicSnapshot::get_samples X-Git-Tag: pulseview-0.2.0~302 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ed990f118d154cd487261d23986b7ad0ba4e24fe;p=pulseview.git Added LogicSnapshot::get_samples --- diff --git a/pv/data/logicsnapshot.cpp b/pv/data/logicsnapshot.cpp index f77690e1..d32274b3 100644 --- a/pv/data/logicsnapshot.cpp +++ b/pv/data/logicsnapshot.cpp @@ -70,6 +70,22 @@ void LogicSnapshot::append_payload( append_payload_to_mipmap(); } +void LogicSnapshot::get_samples(uint8_t *const data, + int64_t start_sample, int64_t end_sample) const +{ + assert(data); + assert(start_sample >= 0); + assert(start_sample < (int64_t)_sample_count); + assert(end_sample >= 0); + assert(end_sample < (int64_t)_sample_count); + assert(start_sample <= end_sample); + + lock_guard lock(_mutex); + + const size_t size = (end_sample - start_sample) * _unit_size; + memcpy(data, (const uint8_t*)_data + start_sample, size); +} + void LogicSnapshot::reallocate_mipmap_level(MipMapLevel &m) { const uint64_t new_data_length = ((m.length + MipMapDataUnit - 1) / diff --git a/pv/data/logicsnapshot.h b/pv/data/logicsnapshot.h index 9868a212..ecff5edc 100644 --- a/pv/data/logicsnapshot.h +++ b/pv/data/logicsnapshot.h @@ -64,6 +64,9 @@ public: void append_payload(const sr_datafeed_logic &logic); + void get_samples(uint8_t *const data, + int64_t start_sample, int64_t end_sample) const; + private: void reallocate_mipmap_level(MipMapLevel &m);