From: Soeren Apel Date: Mon, 14 Aug 2017 15:52:43 +0000 (+0200) Subject: Session: Rework frame handling X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=837bb15a1c1b668640da474522f174da462d6d61;p=pulseview.git Session: Rework frame handling --- diff --git a/pv/session.cpp b/pv/session.cpp index 4dcc2e8b..ad4c17e2 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -990,10 +990,26 @@ void Session::feed_in_trigger() void Session::feed_in_frame_begin() { + frame_began_ = true; + if (cur_logic_segment_ || !cur_analog_segments_.empty()) frame_began(); } +void Session::feed_in_frame_end() +{ + { + lock_guard lock(data_mutex_); + cur_logic_segment_.reset(); + cur_analog_segments_.clear(); + } + + if (frame_began_) { + frame_began_ = false; + frame_ended(); + } +} + void Session::feed_in_logic(shared_ptr logic) { lock_guard lock(data_mutex_); @@ -1090,8 +1106,6 @@ void Session::feed_in_analog(shared_ptr analog) void Session::data_feed_in(shared_ptr device, shared_ptr packet) { - static bool frame_began = false; - (void)device; assert(device); @@ -1111,11 +1125,6 @@ void Session::data_feed_in(shared_ptr device, feed_in_trigger(); break; - case SR_DF_FRAME_BEGIN: - feed_in_frame_begin(); - frame_began = true; - break; - case SR_DF_LOGIC: try { feed_in_logic(dynamic_pointer_cast(packet->payload())); @@ -1134,20 +1143,25 @@ void Session::data_feed_in(shared_ptr device, } break; + case SR_DF_FRAME_BEGIN: + feed_in_frame_begin(); + break; + case SR_DF_FRAME_END: + feed_in_frame_end(); + break; + case SR_DF_END: - { + // Strictly speaking, this is performed when a frame end marker was + // received, so there's no point doing this again. However, not all + // devices use frames, and for those devices, we need to do it here. { lock_guard lock(data_mutex_); cur_logic_segment_.reset(); cur_analog_segments_.clear(); } - if (frame_began) { - frame_began = false; - frame_ended(); - } break; - } + default: break; } diff --git a/pv/session.hpp b/pv/session.hpp index fa96ce64..9d42a4d9 100644 --- a/pv/session.hpp +++ b/pv/session.hpp @@ -201,6 +201,7 @@ private: void feed_in_trigger(); void feed_in_frame_begin(); + void feed_in_frame_end(); void feed_in_logic(shared_ptr logic); @@ -236,6 +237,7 @@ private: bool out_of_memory_; bool data_saved_; + bool frame_began_; Q_SIGNALS: void capture_state_changed(int state);