- if ((input_port = _session.engine().register_input_port (*t, buf, _public_ports)) == 0) {
- error << string_compose(_("IO: cannot register input port %1"), buf) << endmsg;
- return -1;
- }
- }
-
- catch (AudioEngine::PortRegistrationFailure& err) {
- setup_peak_meters ();
- reset_panner ();
- /* pass it on */
- throw AudioEngine::PortRegistrationFailure();
- }
-
- _inputs.add (input_port);
- changed = true;
- }
- }
-
- if (changed) {
- check_bundles_connected_to_inputs ();
- setup_peak_meters ();
- reset_panner ();
- PortCountChanged (n_inputs()); /* EMIT SIGNAL */
- _session.set_dirty ();
- }
-
- if (clear) {
- /* disconnect all existing ports so that we get a fresh start */
- for (PortSet::iterator i = _inputs.begin(); i != _inputs.end(); ++i) {
- _session.engine().disconnect (*i);
- }
- }
-
- return changed;
-}
-
-/** Attach output_buffers to port buffers.
- *
- * Connected to IO's own PortCountChanged signal.
- */
-void
-IO::attach_buffers(ChanCount ignored)
-{
- _output_buffers->attach_buffers(_outputs);
-}
-
-int
-IO::ensure_io (ChanCount in, ChanCount out, bool clear, void* src)
-{
- bool in_changed = false;
- bool out_changed = false;
- bool need_pan_reset = false;
-
- in = min (_input_maximum, in);
-
- out = min (_output_maximum, out);
-
- if (in == n_inputs() && out == n_outputs() && !clear) {
- return 0;
- }
-
- {
- BLOCK_PROCESS_CALLBACK ();
- Glib::Mutex::Lock lm (io_lock);
-
- Port* port;
-
- if (n_outputs() != out) {
- need_pan_reset = true;
- }
-
- for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
-
- const size_t nin = in.get(*t);
- const size_t nout = out.get(*t);
-
- Port* output_port = 0;
- Port* input_port = 0;
-
- /* remove unused output ports */
- for (size_t i = n_outputs().get(*t); i > nout; --i) {
- output_port = _outputs.port(*t, i-1);
-
- assert(output_port);
- _outputs.remove(output_port);
- _session.engine().unregister_port (*output_port);
-
- out_changed = true;
- }
-
- /* remove unused input ports */
- for (size_t i = n_inputs().get(*t); i > nin; --i) {
- input_port = _inputs.port(*t, i-1);
-
- assert(input_port);
- _inputs.remove(input_port);
- _session.engine().unregister_port (*input_port);
-
- in_changed = true;
- }
-
- /* create any necessary new input ports */
-
- while (n_inputs().get(*t) < nin) {
-
- char buf[64];
-
- /* Create a new input port */
-
- if (_input_maximum.get(*t) == 1) {
- snprintf (buf, sizeof (buf), _("%s/in"), _name.c_str());
- } else {
- snprintf (buf, sizeof (buf), _("%s/in %u"), _name.c_str(), find_input_port_hole());
- }
-
- try {
- if ((port = _session.engine().register_input_port (*t, buf, _public_ports)) == 0) {
- error << string_compose(_("IO: cannot register input port %1"), buf) << endmsg;