]> sigrok.org Git - pulseview.git/commitdiff
DecoderStack: Avoid re-feeding old data after wait_for_data()
authorMarcus Comstedt <redacted>
Sun, 26 Feb 2017 13:31:02 +0000 (14:31 +0100)
committerUwe Hermann <redacted>
Sun, 26 Feb 2017 18:27:53 +0000 (19:27 +0100)
This fixes #876 and #850.

pv/data/decoderstack.cpp
pv/data/decoderstack.hpp

index 5402df4f8539f4ebd51728277562f33342d1ffd2..c5a0e4a7a36d54957e2c96312a796782e1b7e90a 100644 (file)
@@ -301,13 +301,13 @@ optional<int64_t> 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
index 37f7ca886cecfe8a23dda75663021f01db51ee70..19a060f2bccdaa37360982fe54677ceb7b7a8608 100644 (file)
@@ -113,7 +113,7 @@ public:
 private:
        boost::optional<int64_t> 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();