From: Marcus Comstedt Date: Sun, 26 Feb 2017 13:31:02 +0000 (+0100) Subject: DecoderStack: Avoid re-feeding old data after wait_for_data() X-Git-Tag: pulseview-0.4.0~182 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e8bb7c69bce723ed2b116598012cf85deb191ba8;p=pulseview.git DecoderStack: Avoid re-feeding old data after wait_for_data() This fixes #876 and #850. --- diff --git a/pv/data/decoderstack.cpp b/pv/data/decoderstack.cpp index 5402df4f..c5a0e4a7 100644 --- a/pv/data/decoderstack.cpp +++ b/pv/data/decoderstack.cpp @@ -301,13 +301,13 @@ optional DecoderStack::wait_for_data() const } void DecoderStack::decode_data( - const int64_t sample_count, const unsigned int unit_size, + const int64_t abs_start_samplenum, const int64_t sample_count, const unsigned int unit_size, srd_session *const session) { const unsigned int chunk_sample_count = DecodeChunkLength / segment_->unit_size(); - for (int64_t i = 0; !interrupt_ && i < sample_count; + for (int64_t i = abs_start_samplenum; !interrupt_ && i < sample_count; i += chunk_sample_count) { const int64_t chunk_end = min( @@ -380,8 +380,10 @@ void DecoderStack::decode_proc() srd_session_start(session); + int64_t abs_start_samplenum = 0; do { - decode_data(*sample_count, unit_size, session); + decode_data(abs_start_samplenum, *sample_count, unit_size, session); + abs_start_samplenum = *sample_count; } while (error_message_.isEmpty() && (sample_count = wait_for_data())); // Destroy the session diff --git a/pv/data/decoderstack.hpp b/pv/data/decoderstack.hpp index 37f7ca88..19a060f2 100644 --- a/pv/data/decoderstack.hpp +++ b/pv/data/decoderstack.hpp @@ -113,7 +113,7 @@ public: private: boost::optional wait_for_data() const; - void decode_data(const int64_t sample_count, + void decode_data(const int64_t abs_start_samplenum, const int64_t sample_count, const unsigned int unit_size, srd_session *const session); void decode_proc();