From 35ab234e5e1aa6bbdcc095c87dfcc316e3aeb3c4 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 13 Jan 2014 10:46:11 +0100 Subject: [PATCH] fix deadlock when removing monitoring-section --- libs/ardour/route.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 842ce5e7e1..9f18d8da00 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -1377,7 +1377,7 @@ Route::clear_processors (Placement p) } int -Route::remove_processor (boost::shared_ptr processor, ProcessorStreams* err, bool) +Route::remove_processor (boost::shared_ptr processor, ProcessorStreams* err, bool need_process_lock) { // TODO once the export point can be configured properly, do something smarter here if (processor == _capturing_processor) { @@ -1397,7 +1397,10 @@ Route::remove_processor (boost::shared_ptr processor, ProcessorStream processor_max_streams.reset(); { - Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ()); + Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock (), Glib::Threads::NOT_LOCK); + if (need_process_lock) { + lx.acquire(); + } Glib::Threads::RWLock::WriterLock lm (_processor_lock); ProcessorState pstate (this); @@ -1457,6 +1460,9 @@ Route::remove_processor (boost::shared_ptr processor, ProcessorStream } } } + if (need_process_lock) { + lx.release(); + } } reset_instrument_info (); @@ -4147,8 +4153,7 @@ Route::has_external_redirects () const boost::shared_ptr Route::the_instrument () const { - Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ()); - Glib::Threads::RWLock::WriterLock lm (_processor_lock); + Glib::Threads::RWLock::ReaderLock lm (_processor_lock); return the_instrument_unlocked (); }