properly calculate requrired thread buffers
authorRobin Gareus <robin@gareus.org>
Thu, 14 Apr 2016 12:13:26 +0000 (14:13 +0200)
committerRobin Gareus <robin@gareus.org>
Thu, 14 Apr 2016 12:13:26 +0000 (14:13 +0200)
libs/ardour/ardour/plugin_insert.h
libs/ardour/plugin_insert.cc
libs/ardour/route.cc
libs/ardour/thread_buffers.cc

index 2abf31c480054598a81e3bb48d4621dd63dc8153..aa1164187d4dfed7c7fbc264099b93adcd011f79 100644 (file)
@@ -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;
index 0e2fffb7ad85fa29df9f4e47f7309f9f40f8c8e0..81c15efbf157d8310080154420602c75cfc7bbf6 100644 (file)
@@ -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))
                 ) {
index 429ee3155f02ce64deb75f4f86b1378b255ac9f5..a53fdee416cf2dde77ab5e2cd814e0392adb8809 100644 (file)
@@ -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;
 
index 36ffbb70da5aeb267b9c8c811aded4ac5e31fd79..9b08f5c51304bdcfdca6ee28cee9be68b890c6d4 100644 (file)
@@ -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);