]> sigrok.org Git - pulseview.git/commitdiff
Added LogicSnapshot::get_samples
authorJoel Holdsworth <redacted>
Mon, 26 Aug 2013 21:11:17 +0000 (22:11 +0100)
committerJoel Holdsworth <redacted>
Sun, 29 Sep 2013 01:52:29 +0000 (10:52 +0900)
pv/data/logicsnapshot.cpp
pv/data/logicsnapshot.h

index f77690e137d6ced0a17b3f54ba0edf18f3ee1b9d..d32274b3322cb4b02808343dad61f92afee57774 100644 (file)
@@ -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<recursive_mutex> 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) /
index 9868a212561fb17364cdd98f525c882432675371..ecff5edc089c61846c400c400cb7c1192303a8fa 100644 (file)
@@ -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);