From b751f4f2e219979c665a706ef09ca8b5d56cf36c Mon Sep 17 00:00:00 2001 From: Sampo Savolainen Date: Thu, 26 Jan 2006 19:00:38 +0000 Subject: [PATCH] Ensure that there are enough peak vectors when a plugin redirect has more inputs or outputs than the route has inputs or outputs. git-svn-id: svn://localhost/trunk/ardour2@298 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/route.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 269ed98a77..5d3cd942e7 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -776,6 +776,8 @@ Route::add_redirect (Redirect *redirect, void *src, uint32_t* err_streams) PluginInsert* pi; PortInsert* porti; + uint32_t potential_max_streams = 0; + if ((pi = dynamic_cast(redirect)) != 0) { pi->set_count (1); @@ -784,6 +786,8 @@ Route::add_redirect (Redirect *redirect, void *src, uint32_t* err_streams) _have_internal_generator = true; } + potential_max_streams = max(pi->input_streams(), pi->output_streams()); + } else if ((porti = dynamic_cast(redirect)) != 0) { /* force new port inserts to start out with an i/o configuration @@ -801,6 +805,14 @@ Route::add_redirect (Redirect *redirect, void *src, uint32_t* err_streams) porti->ensure_io (n_outputs (), n_inputs(), false, this); } + // Ensure peak vector sizes before the plugin is activated + while (_peak_power.size() < potential_max_streams) { + _peak_power.push_back(0); + } + while (_stored_peak_power.size() < potential_max_streams) { + _stored_peak_power.push_back(0); + } + _redirects.push_back (redirect); if (_reset_plugin_counts (err_streams)) { @@ -837,12 +849,26 @@ Route::add_redirects (const RedirectList& others, void *src, uint32_t* err_strea RedirectList::iterator existing_end = _redirects.end(); --existing_end; + uint32_t potential_max_streams = 0; + for (RedirectList::const_iterator i = others.begin(); i != others.end(); ++i) { PluginInsert* pi; if ((pi = dynamic_cast(*i)) != 0) { pi->set_count (1); + + uint32_t m = max(pi->input_streams(), pi->output_streams()); + if (m > potential_max_streams) + potential_max_streams = m; + } + + // Ensure peak vector sizes before the plugin is activated + while (_peak_power.size() < potential_max_streams) { + _peak_power.push_back(0); + } + while (_stored_peak_power.size() < potential_max_streams) { + _stored_peak_power.push_back(0); } _redirects.push_back (*i);