From bf411d3730526af0bb984f6bb3dd4035d6070bc4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 22 Nov 2010 17:15:32 +0000 Subject: Simplify strip silence dialogue threading, hopefully fixing #3560 in the process. git-svn-id: svn://localhost/ardour2/branches/3.0@8068 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/strip_silence_dialog.h | 51 +++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 28 deletions(-) (limited to 'gtk2_ardour/strip_silence_dialog.h') diff --git a/gtk2_ardour/strip_silence_dialog.h b/gtk2_ardour/strip_silence_dialog.h index 3b800eb115..c9b31578b9 100644 --- a/gtk2_ardour/strip_silence_dialog.h +++ b/gtk2_ardour/strip_silence_dialog.h @@ -43,17 +43,21 @@ public: nframes_t minimum_length () const; nframes_t fade_length () const; - static void stop_thread (); private: + typedef std::list > SilenceResult; + void create_waves (); void peaks_ready (); void canvas_allocation (Gtk::Allocation &); void update_silence_rects (); void resize_silence_rects (); + void update (); void update_threshold_line (); + void update_stats (SilenceResult const &); void threshold_changed (); void update_progress_gui (float); + void restart_thread (); Gtk::SpinButton _threshold; AudioClock _minimum_length; @@ -62,32 +66,23 @@ private: Gtk::Label _shortest_silence_label; Gtk::Label _shortest_audible_label; Gtk::ProgressBar _progress_bar; - typedef std::list > SilenceResult; struct Wave { - boost::shared_ptr region; - ArdourCanvas::WaveView* view; - std::list silence_rects; - ArdourCanvas::SimpleLine* threshold_line; - double samples_per_unit; - SilenceResult silence; - - Wave (ArdourCanvas::Group *, boost::shared_ptr); - ~Wave (); + boost::shared_ptr region; + ArdourCanvas::WaveView* view; + std::list silence_rects; + ArdourCanvas::SimpleLine* threshold_line; + double samples_per_unit; + SilenceResult silence; + + Wave (ArdourCanvas::Group *, boost::shared_ptr); + ~Wave (); }; ArdourCanvas::Canvas* _canvas; std::list _waves; int _wave_width; int _wave_height; - bool restart_queued; - - static ARDOUR::InterThreadInfo itt; - static bool thread_should_exit; - static Glib::Cond *thread_run; - static Glib::Cond *thread_waiting; - static Glib::StaticMutex run_lock; - static StripSilenceDialog* current; ARDOUR::framecnt_t max_audible; ARDOUR::framecnt_t min_audible; @@ -95,14 +90,14 @@ private: ARDOUR::framecnt_t min_silence; PBD::ScopedConnection* _peaks_ready_connection; - - static bool _detection_done (void*); - static void* _detection_thread_work (void*); - - bool detection_done (); - void* detection_thread_work (); - bool start_silence_detection (); - void maybe_start_silence_detection (); - void update_stats (const SilenceResult&); + pthread_t _thread; ///< thread to compute silence in the background + static void * _detection_thread_work (void *); + void * detection_thread_work (); + Glib::Mutex _lock; ///< lock held while the thread is doing work + Glib::Cond _run_cond; ///< condition to wake the thread + bool _thread_should_finish; ///< true if the thread should terminate + PBD::Signal0 Completed; ///< emitted when a silence detection has completed + PBD::ScopedConnection _completed_connection; + ARDOUR::InterThreadInfo _interthread_info; }; -- cgit v1.2.3