diff options
author | Robin Gareus <robin@gareus.org> | 2016-04-14 14:13:26 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-04-14 14:13:26 +0200 |
commit | 79621762193a7a56cbb5a966cc8603c1d1c5e17c (patch) | |
tree | f0036ae7b5243af60cf19a1f991e4d94b6554c9b | |
parent | 5af4ce47eb2f556ba403bc8896c7123dbc0d58a0 (diff) |
properly calculate requrired thread buffers
-rw-r--r-- | libs/ardour/ardour/plugin_insert.h | 3 | ||||
-rw-r--r-- | libs/ardour/plugin_insert.cc | 6 | ||||
-rw-r--r-- | libs/ardour/route.cc | 11 | ||||
-rw-r--r-- | libs/ardour/thread_buffers.cc | 2 |
4 files changed, 16 insertions, 6 deletions
diff --git a/libs/ardour/ardour/plugin_insert.h b/libs/ardour/ardour/plugin_insert.h index 2abf31c480..aa1164187d 100644 --- a/libs/ardour/ardour/plugin_insert.h +++ b/libs/ardour/ardour/plugin_insert.h @@ -134,6 +134,8 @@ class LIBARDOUR_API PluginInsert : public Processor } } + ChanCount required_buffers () const { return _required_buffers; } + // allow to override output_streams(), implies "Custom Mode" // only the owning route may call these (with process lock held) @@ -305,6 +307,7 @@ class LIBARDOUR_API PluginInsert : public Processor ChanCount _configured_out; ChanCount _custom_out; ChanCount _cached_sidechain_pins; + ChanCount _required_buffers; bool _configured; bool _no_inplace; diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index 0e2fffb7ad..81c15efbf1 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -1455,6 +1455,12 @@ PluginInsert::configure_io (ChanCount in, ChanCount out) _no_inplace = check_inplace (); _mapping_changed = false; + /* only the "noinplace_buffers" thread buffers need to be this large, + * this can be optimized. other buffers are fine with + * ChanCount::max (natural_input_streams (), natural_output_streams()) + */ + _required_buffers = natural_input_streams () + natural_output_streams() * get_count(); + if (old_in != in || old_out != out || old_internal != _configured_internal || (old_match.method != _match.method && (old_match.method == Split || _match.method == Split)) ) { diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 429ee3155f..a53fdee416 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -2199,17 +2199,18 @@ Route::configure_processors_unlocked (ProcessorStreams* err) processor_max_streams = ChanCount::max(processor_max_streams, c->first); processor_max_streams = ChanCount::max(processor_max_streams, c->second); + boost::shared_ptr<IOProcessor> iop; boost::shared_ptr<PluginInsert> pi; if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*p)) != 0) { /* plugins connected via Split or Hide Match may have more channels. * route/scratch buffers are needed for all of them * The configuration may only be a subset (both input and output) */ - processor_max_streams = ChanCount::max(processor_max_streams, pi->input_streams()); - processor_max_streams = ChanCount::max(processor_max_streams, pi->internal_streams()); - processor_max_streams = ChanCount::max(processor_max_streams, pi->output_streams()); - processor_max_streams = ChanCount::max(processor_max_streams, pi->natural_input_streams() * pi->get_count()); - processor_max_streams = ChanCount::max(processor_max_streams, pi->natural_output_streams() * pi->get_count()); + processor_max_streams = ChanCount::max(processor_max_streams, pi->required_buffers()); + } + else if ((iop = boost::dynamic_pointer_cast<IOProcessor>(*p)) != 0) { + processor_max_streams = ChanCount::max(processor_max_streams, iop->natural_input_streams()); + processor_max_streams = ChanCount::max(processor_max_streams, iop->natural_output_streams()); } out = c->second; diff --git a/libs/ardour/thread_buffers.cc b/libs/ardour/thread_buffers.cc index 36ffbb70da..9b08f5c513 100644 --- a/libs/ardour/thread_buffers.cc +++ b/libs/ardour/thread_buffers.cc @@ -72,7 +72,7 @@ ThreadBuffers::ensure_buffers (ChanCount howmany, size_t custom) } scratch_buffers->ensure_buffers (*t, count, size); - noinplace_buffers->ensure_buffers (*t, count + count, size); // in + out + noinplace_buffers->ensure_buffers (*t, count, size); mix_buffers->ensure_buffers (*t, count, size); silent_buffers->ensure_buffers (*t, count, size); route_buffers->ensure_buffers (*t, count, size); |