2 * Copyright (C) 2010-2011 Carl Hetherington <carl@carlh.net>
3 * Copyright (C) 2013-2017 Robin Gareus <robin@gareus.org>
4 * Copyright (C) 2016-2017 Paul Davis <paul@linuxaudiosystems.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "ardour/audio_buffer.h"
22 #include "ardour/unknown_processor.h"
27 using namespace ARDOUR;
29 UnknownProcessor::UnknownProcessor (Session& s, XMLNode const & state)
32 , have_ioconfig (false)
36 XMLProperty const * prop = state.property (X_("name"));
38 set_name (prop->value ());
39 _display_to_user = true;
43 XMLNodeList kids = state.children ();
44 for (XMLNodeIterator i = kids.begin(); i != kids.end(); ++i) {
45 if ((*i)->name() == X_("ConfiguredInput")) {
47 saved_input = new ChanCount(**i);
49 if ((*i)->name() == X_("ConfiguredOutput")) {
51 saved_output = new ChanCount(**i);
54 have_ioconfig = (have_io == 3);
57 UnknownProcessor::~UnknownProcessor () {
63 UnknownProcessor::state ()
65 return *(new XMLNode (_state));
69 UnknownProcessor::can_support_io_configuration (const ChanCount &in, ChanCount & out) {
70 if (have_ioconfig && in == *saved_input) {
73 } else if (!have_ioconfig) {
74 /* pass for old sessions.
76 * session load assumes processor config succeeds.
77 * if initial configuration fails, processors downstream
78 * remain unconfigured and at least the panner will assert/segfault.
80 * This may still result in impossible setup, however
81 * Route::configure_processors_unlocked() ignores configure_io() return value
82 * in the inner loop and configures all available processors.
84 * It can still lead to segfaults IFF the track has no inputs and this is a
85 * generator (processor_max_streams will be zero).
87 PBD::warning << _("Using plugin-stub with unknown i/o configuration for: ") << name() << endmsg;
89 /* No output channels are fine (or should be, there may be edge-cases with e.g sends).
93 * This is the safer option (no audio output, no possible damage)
94 * and the way to go in the long run.
95 * An even better solution is to disable the route if there are missing plugins
96 * and/or impossible configurations.
98 * Currently no output channels results in awkward GUI route display and also
99 * breaks semantics in mixbus (which assumes that the route has channels required
100 * for the always present mixer-strip plugin).
108 PBD::error << _("Using plugin-stub with mismatching i/o configuration for: ") << name() << endmsg;
115 UnknownProcessor::run (BufferSet& bufs, samplepos_t /*start_sample*/, samplepos_t /*end_sample*/, double /*speed*/, pframes_t nframes, bool)
117 if (!have_ioconfig) {
120 // silence excess output buffers
121 for (uint32_t i = saved_input->n_audio(); i < saved_output->n_audio(); ++i) {
122 bufs.get_audio (i).silence (nframes);