From e1905c1c29df0911adfeb9acfea2aa1e077ca892 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 24 Feb 2011 16:22:42 +0000 Subject: [PATCH] allow zero-input (i.e. tone generator) processors to be added git-svn-id: svn://localhost/ardour2/branches/3.0@8950 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/plugin_insert.cc | 27 ++++++++++++++++++++++----- libs/ardour/route.cc | 18 +++++++++++------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index 052b3a3e02..1484bd7294 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -612,6 +612,20 @@ PluginInsert::can_support_io_configuration (const ChanCount& in, ChanCount& out) ChanCount inputs = _plugins[0]->get_info()->n_inputs; ChanCount outputs = _plugins[0]->get_info()->n_outputs; + bool no_inputs = true; + for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { + if (inputs.get (*t) != 0) { + no_inputs = false; + break; + } + } + + if (no_inputs) { + /* no inputs so we can take any input configuration since we throw it away */ + out = outputs; + return true; + } + // Plugin inputs match requested inputs exactly if (inputs == in) { out = outputs; @@ -624,12 +638,15 @@ PluginInsert::can_support_io_configuration (const ChanCount& in, ChanCount& out) uint32_t f = 0; bool can_replicate = true; for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { + + uint32_t nin = inputs.get (*t); + // No inputs of this type - if (inputs.get(*t) == 0 && in.get(*t) == 0) { + if (nin == 0 && in.get(*t) == 0) { continue; } - if (inputs.get(*t) != 1 || outputs.get (*t) != 1) { + if (nin != 1 || outputs.get (*t) != 1) { can_replicate = false; break; } @@ -637,16 +654,16 @@ PluginInsert::can_support_io_configuration (const ChanCount& in, ChanCount& out) // Potential factor not set yet if (f == 0) { - f = in.get(*t) / inputs.get(*t);; + f = in.get(*t) / nin; } // Factor for this type does not match another type, can not replicate - if (f != (in.get(*t) / inputs.get(*t))) { + if (f != (in.get(*t) / nin)) { can_replicate = false; break; } } - + if (can_replicate) { for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { out.set (*t, outputs.get(*t) * f); diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index dba16131f9..5550bb3f9b 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -503,13 +503,17 @@ Route::process_output_buffers (BufferSet& bufs, break; } - if (bufs.count() != (*i)->input_streams()) { - cerr << _name << " bufs = " << bufs.count() - << " input for " << (*i)->name() << " = " << (*i)->input_streams() - << endl; - } - assert (bufs.count() == (*i)->input_streams()); - +#ifndef NDEBUG + /* if it has any inputs, make sure they match */ + if ((*i)->input_streams() != ChanCount::ZERO) { + if (bufs.count() != (*i)->input_streams()) { + cerr << _name << " bufs = " << bufs.count() + << " input for " << (*i)->name() << " = " << (*i)->input_streams() + << endl; + abort (); + } + } +#endif /* should we NOT run plugins here if the route is inactive? do we catch route != active somewhere higher? */