diff options
author | Robin Gareus <robin@gareus.org> | 2014-02-03 15:09:17 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2014-02-03 15:09:17 +0100 |
commit | 9c0b62e2f3786ccaa2ceda3425d15bf8afc669d0 (patch) | |
tree | 848f5437a4c2ab1c3d8d36e7c822b079638fc8e6 | |
parent | 12576a9f296d2f2fe6e7e57f9d7a1922aa38a21d (diff) |
fix processor_lock
Only WriterLock requires to hold process_lock() as well
otherwise Route::process_output_buffers() may deadlock
-rw-r--r-- | libs/ardour/route.cc | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 9e649362ee..71af69fdee 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -419,6 +419,9 @@ Route::process_output_buffers (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, int declick, bool gain_automation_ok) { + /* Caller must hold process lock */ + assert (!AudioEngine::instance()->process_lock().trylock()); + Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK); assert(lm.locked()); @@ -1382,7 +1385,16 @@ Route::remove_processor (boost::shared_ptr<Processor> processor, ProcessorStream { // TODO once the export point can be configured properly, do something smarter here if (processor == _capturing_processor) { + Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock (), Glib::Threads::NOT_LOCK); + if (need_process_lock) { + lx.acquire(); + } + _capturing_processor.reset(); + + if (need_process_lock) { + lx.release(); + } } /* these can never be removed */ @@ -1402,7 +1414,12 @@ Route::remove_processor (boost::shared_ptr<Processor> processor, ProcessorStream if (need_process_lock) { lx.acquire(); } - Glib::Threads::RWLock::WriterLock lm (_processor_lock); + + /* Caller must hold process lock */ + assert (!AudioEngine::instance()->process_lock().trylock()); + + Glib::Threads::RWLock::WriterLock lm (_processor_lock); // XXX deadlock after export + ProcessorState pstate (this); ProcessorList::iterator i; @@ -3062,6 +3079,7 @@ Route::set_meter_point (MeterPoint p, bool force) bool meter_was_visible_to_user = _meter->display_to_user (); { + Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ()); Glib::Threads::RWLock::WriterLock lm (_processor_lock); maybe_note_meter_position (); @@ -3147,12 +3165,16 @@ Route::listen_position_changed () boost::shared_ptr<CapturingProcessor> Route::add_export_point() { + Glib::Threads::RWLock::ReaderLock lm (_processor_lock); if (!_capturing_processor) { + lm.release(); + Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ()); + Glib::Threads::RWLock::WriterLock lw (_processor_lock); _capturing_processor.reset (new CapturingProcessor (_session)); _capturing_processor->activate (); - configure_processors (0); + configure_processors_unlocked (0); } @@ -4132,7 +4154,7 @@ Route::non_realtime_locate (framepos_t pos) { //Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ()); - Glib::Threads::RWLock::WriterLock lm (_processor_lock); + Glib::Threads::RWLock::ReaderLock lm (_processor_lock); for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) { (*i)->transport_located (pos); |