X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fardour%2Funknown_processor.cc;h=e7f738507dcacee814cfd4ab4e6fcdcb1d747214;hb=d58cb3daa3f0e091a11e3846b28e83bcf0f93587;hp=f6c713404f5d6ef6af3db8b6df9371cd6b331255;hpb=110311e1860d6fb18b1985ca47f33126ae69f678;p=ardour.git diff --git a/libs/ardour/unknown_processor.cc b/libs/ardour/unknown_processor.cc old mode 100755 new mode 100644 index f6c713404f..e7f738507d --- a/libs/ardour/unknown_processor.cc +++ b/libs/ardour/unknown_processor.cc @@ -17,6 +17,7 @@ */ +#include "ardour/audio_buffer.h" #include "ardour/unknown_processor.h" #include "i18n.h" @@ -27,11 +28,34 @@ using namespace ARDOUR; UnknownProcessor::UnknownProcessor (Session& s, XMLNode const & state) : Processor (s, "") , _state (state) + , have_ioconfig (false) + , saved_input (0) + , saved_output (0) { XMLProperty const * prop = state.property (X_("name")); if (prop) { set_name (prop->value ()); + _display_to_user = true; } + + int have_io = 0; + XMLNodeList kids = state.children (); + for (XMLNodeIterator i = kids.begin(); i != kids.end(); ++i) { + if ((*i)->name() == X_("ConfiguredInput")) { + have_io |= 1; + saved_input = new ChanCount(**i); + } + if ((*i)->name() == X_("ConfiguredOutput")) { + have_io |= 2; + saved_output = new ChanCount(**i); + } + } + have_ioconfig = (have_io == 3); +} + +UnknownProcessor::~UnknownProcessor () { + delete saved_input;; + delete saved_output; } XMLNode & @@ -40,3 +64,60 @@ UnknownProcessor::state (bool) return *(new XMLNode (_state)); } +bool +UnknownProcessor::can_support_io_configuration (const ChanCount &in, ChanCount & out) { + if (have_ioconfig && in == *saved_input) { + out = *saved_output; + return true; + } else if (!have_ioconfig) { + /* pass for old sessions. + * + * session load assumes processor config succeeds. + * if initial configuration fails, processors downstream + * remain unconfigured and at least the panner will assert/segfault. + * + * This may still result in impossible setup, however + * Route::configure_processors_unlocked() ignores configure_io() return value + * in the inner loop and configures all available processors. + * + * It can still lead to segfaults IFF the track has no inputs and this is a + * generator (processor_max_streams will be zero). + */ + PBD::warning << _("Using plugin-stub with unknown i/o configuration for: ") << name() << endmsg; +#if 0 + /* No output channels are fine (or should be, there may be edge-cases with e.g sends). + * + * Discussion needed. + * + * This is the safer option (no audio output, no possible damage) + * and the way to go in the long run. + * An even better solution is to disable the route if there are missing plugins + * and/or impossible configurations. + * + * Currently no output channels results in awkward GUI route display and also + * breaks semantics in mixbus (which assumes that the route has channels required + * for the always present mixer-strip plugin). + */ + out = ChanCount (); +#else + out = in; +#endif + return true; + } else { + PBD::error << _("Using plugin-stub with mismatching i/o configuration for: ") << name() << endmsg; + out = in; + } + return true; +} + +void +UnknownProcessor::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t nframes, bool) +{ + if (!have_ioconfig) { + return; + } + // silence excess output buffers + for (uint32_t i = saved_input->n_audio(); i < saved_output->n_audio(); ++i) { + bufs.get_audio (i).silence (nframes); + } +}