diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-06-11 17:04:08 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-06-11 17:04:08 -0400 |
commit | 10643779b6f039a7458bd0c970ef40ac80ea0568 (patch) | |
tree | 2491337607008d9f7cd6f0fe110f8b8ba234e4b5 /libs/canvas | |
parent | 077e62573493d889151ecbde4ecfc088ac9f08b1 (diff) |
more refactoring of WaveView threaded code to try to get to heart of crash bug
Diffstat (limited to 'libs/canvas')
-rw-r--r-- | libs/canvas/canvas/wave_view.h | 3 | ||||
-rw-r--r-- | libs/canvas/wave_view.cc | 77 |
2 files changed, 40 insertions, 40 deletions
diff --git a/libs/canvas/canvas/wave_view.h b/libs/canvas/canvas/wave_view.h index ceb6829da2..55d82022af 100644 --- a/libs/canvas/canvas/wave_view.h +++ b/libs/canvas/canvas/wave_view.h @@ -379,8 +379,7 @@ public: mutable boost::shared_ptr<WaveViewCache::Entry> _current_image; mutable boost::shared_ptr<WaveViewThreadRequest> current_request; - void send_request (boost::shared_ptr<WaveViewThreadRequest>) const; - bool idle_send_request (boost::shared_ptr<WaveViewThreadRequest>) const; + bool idle_send_request () const; static WaveViewCache* images; diff --git a/libs/canvas/wave_view.cc b/libs/canvas/wave_view.cc index 6dc5c71726..52f6ee9f33 100644 --- a/libs/canvas/wave_view.cc +++ b/libs/canvas/wave_view.cc @@ -861,9 +861,47 @@ WaveView::queue_get_image (boost::shared_ptr<const ARDOUR::Region> region, frame req->fill_color = _fill_color; req->region_amplitude = _region_amplitude; - send_request (req); + if (current_request) { + /* this will stop rendering in progress (which might otherwise + be long lived) for any current request. + */ + current_request->cancel (); + } + + start_drawing_thread (); + + /* swap requests (protected by lock) */ + + { + Glib::Threads::Mutex::Lock lm (request_queue_lock); + current_request = req; + } + + /* this is always called from the GUI thread (there is only one), and + * the same thread runs the idle callback chain. thus we do not need + * any locks to protect idle_queued - it is only ever set or read in + * the unitary GUI thread. + */ + + if (!idle_queued) { + Glib::signal_idle().connect (sigc::mem_fun (*this, &WaveView::idle_send_request)); + idle_queued = true; + } } +bool +WaveView::idle_send_request () const +{ + Glib::Threads::Mutex::Lock lm (request_queue_lock); + + request_queue.insert (this); + request_cond.signal (); /* wake thread - must be done while holding lock */ + idle_queued = false; + + return false; /* do not call from idle again */ +} + + void WaveView::generate_image (boost::shared_ptr<WaveViewThreadRequest> req, bool in_render_thread) const { @@ -1371,43 +1409,6 @@ WaveView::cancel_my_render_request () const current_request.reset (); } -void -WaveView::send_request (boost::shared_ptr<WaveViewThreadRequest> req) const -{ - if (req->type == WaveViewThreadRequest::Draw && current_request) { - /* this will stop rendering in progress (which might otherwise - be long lived) for any current request. - */ - current_request->cancel (); - } - - start_drawing_thread (); - - /* this is always called from the GUI thread (there is only one), and - * the same thread runs the idle callback chain. thus we do not need - * any locks to protect idle_queued - it is only ever set or read in - * the unitary GUI thread. - */ - - if (!idle_queued) { - Glib::signal_idle().connect (sigc::bind (sigc::mem_fun (*this, &WaveView::idle_send_request), req)); - idle_queued = true; - } -} - -bool -WaveView::idle_send_request (boost::shared_ptr<WaveViewThreadRequest> req) const -{ - Glib::Threads::Mutex::Lock lm (request_queue_lock); - /* swap requests (protected by lock) */ - current_request = req; - request_queue.insert (this); - request_cond.signal (); /* wake thread - must be done while holding lock */ - idle_queued = false; - - return false; /* do not call from idle again */ -} - /*-------------------------------------------------*/ void |