X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fdecodesignal.cpp;h=4705b104542cef6c9875d8fa7e1922b6b6cae0c8;hp=05dc3428ab5ce8e9f2bcb964175b55fceb3557d2;hb=556259d2d0a212c20db9b18311b9524b52401a56;hpb=2d20774fe218b2b72169fbbc37f161b7b2b6f410 diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 05dc342..4705b10 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -151,6 +151,9 @@ void DecodeSignal::reset_decode(bool shutting_down) logic_mux_thread_.join(); } + decode_pause_mutex_.unlock(); + decode_paused_ = false; + class_rows_.clear(); current_segment_id_ = 0; segments_.clear(); @@ -258,6 +261,25 @@ void DecodeSignal::begin_decode() decode_thread_ = std::thread(&DecodeSignal::decode_proc, this); } +void DecodeSignal::pause_decode() +{ + decode_paused_ = true; +} + +void DecodeSignal::resume_decode() +{ + // Manual unlocking is done before notifying, to avoid waking up the + // waiting thread only to block again (see notify_one for details) + decode_pause_mutex_.unlock(); + decode_pause_cond_.notify_one(); + decode_paused_ = false; +} + +bool DecodeSignal::is_paused() const +{ + return decode_paused_; +} + QString DecodeSignal::error_message() const { lock_guard lock(output_mutex_); @@ -981,6 +1003,11 @@ void DecodeSignal::decode_data( // Notify the frontend that we processed some data and // possibly have new annotations as well new_annotations(); + + if (decode_paused_) { + unique_lock pause_wait_lock(decode_pause_mutex_); + decode_pause_cond_.wait(pause_wait_lock); + } } }