From 16e5bd5ce7911326167b987d776b58177f09f4bd Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 17 Nov 2009 01:42:55 +0000 Subject: [PATCH] Non-ideal but functional fix for problems when adding processors which increase the required number of scratch buffers. git-svn-id: svn://localhost/ardour2/branches/3.0@6105 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/route.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index e129a22d2c..24556308d9 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -1376,7 +1376,6 @@ Route::configure_processors_unlocked (ProcessorStreams* err) _in_configure_processors = true; - // Check each processor in order to see if we can configure as requested ChanCount in = _input->n_ports (); ChanCount out; @@ -1398,6 +1397,15 @@ Route::configure_processors_unlocked (ProcessorStreams* err) } } + /* Take the process lock so that if we add a processor which increases the required + number of scratch buffers, we create those scratch buffers before the process + thread has a chance to ask for them. + XXX: in an ideal world we'd perhaps use some RCU magic to avoid having to take + the lock here. + */ + + Glib::Mutex::Lock pl (_session.engine().process_lock ()); + // We can, so configure everything list< pair >::iterator c = configuration.begin(); for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p, ++c) { @@ -1407,6 +1415,12 @@ Route::configure_processors_unlocked (ProcessorStreams* err) out = c->second; } + /* make sure we have sufficient scratch buffers to cope with the new processor + configuration */ + _session.ensure_buffers (n_process_buffers ()); + + _session.ensure_buffers (n_process_buffers ()); + _in_configure_processors = false; return 0; } @@ -2741,7 +2755,8 @@ Route::set_block_size (nframes_t nframes) for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) { (*i)->set_block_size (nframes); } - _session.ensure_buffers(processor_max_streams); + + _session.ensure_buffers (n_process_buffers ()); } void