2 Copyright (C) 2010 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "ardour/audio_buffer.h"
21 #include "ardour/unknown_processor.h"
26 using namespace ARDOUR;
28 UnknownProcessor::UnknownProcessor (Session& s, XMLNode const & state)
31 , have_ioconfig (false)
35 XMLProperty const * prop = state.property (X_("name"));
37 set_name (prop->value ());
38 _display_to_user = true;
42 XMLNodeList kids = state.children ();
43 for (XMLNodeIterator i = kids.begin(); i != kids.end(); ++i) {
44 if ((*i)->name() == X_("ConfiguredInput")) {
46 saved_input = new ChanCount(**i);
48 if ((*i)->name() == X_("ConfiguredOutput")) {
50 saved_output = new ChanCount(**i);
53 have_ioconfig = (have_io == 3);
56 UnknownProcessor::~UnknownProcessor () {
62 UnknownProcessor::state ()
64 return *(new XMLNode (_state));
68 UnknownProcessor::can_support_io_configuration (const ChanCount &in, ChanCount & out) {
69 if (have_ioconfig && in == *saved_input) {
72 } else if (!have_ioconfig) {
73 /* pass for old sessions.
75 * session load assumes processor config succeeds.
76 * if initial configuration fails, processors downstream
77 * remain unconfigured and at least the panner will assert/segfault.
79 * This may still result in impossible setup, however
80 * Route::configure_processors_unlocked() ignores configure_io() return value
81 * in the inner loop and configures all available processors.
83 * It can still lead to segfaults IFF the track has no inputs and this is a
84 * generator (processor_max_streams will be zero).
86 PBD::warning << _("Using plugin-stub with unknown i/o configuration for: ") << name() << endmsg;
88 /* No output channels are fine (or should be, there may be edge-cases with e.g sends).
92 * This is the safer option (no audio output, no possible damage)
93 * and the way to go in the long run.
94 * An even better solution is to disable the route if there are missing plugins
95 * and/or impossible configurations.
97 * Currently no output channels results in awkward GUI route display and also
98 * breaks semantics in mixbus (which assumes that the route has channels required
99 * for the always present mixer-strip plugin).
107 PBD::error << _("Using plugin-stub with mismatching i/o configuration for: ") << name() << endmsg;
114 UnknownProcessor::run (BufferSet& bufs, samplepos_t /*start_sample*/, samplepos_t /*end_sample*/, double /*speed*/, pframes_t nframes, bool)
116 if (!have_ioconfig) {
119 // silence excess output buffers
120 for (uint32_t i = saved_input->n_audio(); i < saved_output->n_audio(); ++i) {
121 bufs.get_audio (i).silence (nframes);