Give the _sends member of InternalReturn its own mutex,

rather than using the process lock to protect it.  Prevents
a deadlock when removing an aux send causes it to remove
itself from its return (#4712).


git-svn-id: svn://localhost/ardour2/branches/3.0@11760 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2012-03-25 20:30:26 +00:00
parent e7d2509ad9
commit ca1de50004
3 changed files with 11 additions and 12 deletions

View file

@ -47,6 +47,8 @@ class InternalReturn : public Return
private: private:
/** sends that we are receiving data from */ /** sends that we are receiving data from */
std::list<InternalSend*> _sends; std::list<InternalSend*> _sends;
/** mutex to protect _sends */
Glib::Mutex _sends_mutex;
}; };
} // namespace ARDOUR } // namespace ARDOUR

View file

@ -43,13 +43,15 @@ InternalReturn::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*e
return; return;
} }
/* _sends is only modified with the process lock held, so this is ok, I think */ Glib::Mutex::Lock lm (_sends_mutex, Glib::TRY_LOCK);
if (lm.locked ()) {
for (list<InternalSend*>::iterator i = _sends.begin(); i != _sends.end(); ++i) { for (list<InternalSend*>::iterator i = _sends.begin(); i != _sends.end(); ++i) {
if ((*i)->active ()) { if ((*i)->active ()) {
bufs.merge_from ((*i)->get_buffers(), nframes); bufs.merge_from ((*i)->get_buffers(), nframes);
} }
} }
}
_active = _pending_active; _active = _pending_active;
} }
@ -57,18 +59,14 @@ InternalReturn::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*e
void void
InternalReturn::add_send (InternalSend* send) InternalReturn::add_send (InternalSend* send)
{ {
/* caller must hold process lock */ Glib::Mutex::Lock lm (_sends_mutex);
assert (!AudioEngine::instance()->process_lock().trylock());
_sends.push_back (send); _sends.push_back (send);
} }
void void
InternalReturn::remove_send (InternalSend* send) InternalReturn::remove_send (InternalSend* send)
{ {
/* caller must hold process lock */ Glib::Mutex::Lock lm (_sends_mutex);
assert (!AudioEngine::instance()->process_lock().trylock());
_sends.remove (send); _sends.remove (send);
} }

View file

@ -2606,7 +2606,6 @@ Route::add_send_to_internal_return (InternalSend* send)
void void
Route::remove_send_from_internal_return (InternalSend* send) Route::remove_send_from_internal_return (InternalSend* send)
{ {
Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
Glib::RWLock::ReaderLock rm (_processor_lock); Glib::RWLock::ReaderLock rm (_processor_lock);
for (ProcessorList::const_iterator x = _processors.begin(); x != _processors.end(); ++x) { for (ProcessorList::const_iterator x = _processors.begin(); x != _processors.end(); ++x) {