-IO::collect_input (BufferSet& outs, nframes_t nframes, nframes_t offset)
-{
- assert(outs.available() >= n_inputs());
-
- outs.set_count(n_inputs());
-
- if (outs.count() == ChanCount::ZERO)
- return;
-
- for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
-
- BufferSet::iterator o = outs.begin(*t);
- for (PortSet::iterator i = _inputs.begin(*t); i != _inputs.end(*t); ++i, ++o) {
- o->read_from(i->get_buffer(), nframes, offset);
- }
-
- }
-}
-
-void
-IO::just_meter_input (nframes_t start_frame, nframes_t end_frame,
- nframes_t nframes, nframes_t offset)
-{
- BufferSet& bufs = _session.get_scratch_buffers (n_inputs());
-
- collect_input (bufs, nframes, offset);
-
- _meter->run(bufs, nframes);
-}
-
-void
-IO::drop_input_connection ()
-{
- _input_connection = 0;
- input_connection_configuration_connection.disconnect();
- input_connection_connection_connection.disconnect();
- _session.set_dirty ();
-}
-
-void
-IO::drop_output_connection ()
-{
- _output_connection = 0;
- output_connection_configuration_connection.disconnect();
- output_connection_connection_connection.disconnect();
- _session.set_dirty ();
-}
-
-int
-IO::disconnect_input (Port* our_port, string other_port, void* src)
-{
- if (other_port.length() == 0 || our_port == 0) {
- return 0;
- }
-
- {
- BLOCK_PROCESS_CALLBACK ();
-
- {
- Glib::Mutex::Lock lm (io_lock);
-
- /* check that our_port is really one of ours */
-
- if ( ! _inputs.contains(our_port)) {
- return -1;
- }
-
- /* disconnect it from the source */
-
- if (_session.engine().disconnect (other_port, our_port->name())) {
- error << string_compose(_("IO: cannot disconnect input port %1 from %2"), our_port->name(), other_port) << endmsg;
- return -1;
- }
-
- drop_input_connection();
- }
- }
-
- input_changed (ConnectionsChanged, src); /* EMIT SIGNAL */
- _session.set_dirty ();
-
- return 0;
-}
-
-int
-IO::connect_input (Port* our_port, string other_port, void* src)
-{
- if (other_port.length() == 0 || our_port == 0) {
- return 0;
- }
-
- {
- BLOCK_PROCESS_CALLBACK ();
-
- {
- Glib::Mutex::Lock lm (io_lock);
-
- /* check that our_port is really one of ours */
-
- if ( ! _inputs.contains(our_port) ) {
- return -1;
- }
-
- /* connect it to the source */
-
- if (_session.engine().connect (other_port, our_port->name())) {
- return -1;
- }
-
- drop_input_connection ();
- }
- }
-
- input_changed (ConnectionsChanged, src); /* EMIT SIGNAL */
- _session.set_dirty ();
- return 0;
-}
-
-int
-IO::disconnect_output (Port* our_port, string other_port, void* src)
-{
- if (other_port.length() == 0 || our_port == 0) {
- return 0;
- }
-
- {
- BLOCK_PROCESS_CALLBACK ();
-
- {
- Glib::Mutex::Lock lm (io_lock);
-
- /* check that our_port is really one of ours */
-
- if ( ! _outputs.contains(our_port) ) {
- return -1;
- }
-
- /* disconnect it from the destination */
-
- if (_session.engine().disconnect (our_port->name(), other_port)) {
- error << string_compose(_("IO: cannot disconnect output port %1 from %2"), our_port->name(), other_port) << endmsg;
- return -1;
- }
-
- drop_output_connection ();
- }
- }
-
- output_changed (ConnectionsChanged, src); /* EMIT SIGNAL */
- _session.set_dirty ();
- return 0;
-}
-
-int
-IO::connect_output (Port* our_port, string other_port, void* src)
-{
- if (other_port.length() == 0 || our_port == 0) {
- return 0;
- }
-
- {
- BLOCK_PROCESS_CALLBACK ();
-
-
- {
- Glib::Mutex::Lock lm (io_lock);
-
- /* check that our_port is really one of ours */
-
- if ( ! _outputs.contains(our_port) ) {
- return -1;
- }
-
- /* connect it to the destination */
-
- if (_session.engine().connect (our_port->name(), other_port)) {
- return -1;
- }
-
- drop_output_connection ();
- }
- }
-
- output_changed (ConnectionsChanged, src); /* EMIT SIGNAL */
- _session.set_dirty ();
- return 0;
-}
-
-int
-IO::set_input (Port* other_port, void* src)
-{
- /* this removes all but one ports, and connects that one port
- to the specified source.
- */
-
- if (_input_minimum.get_total() > 1) {
- /* sorry, you can't do this */
- return -1;
- }
-
- if (other_port == 0) {
- if (_input_minimum == ChanCount::ZERO) {
- return ensure_inputs (ChanCount::ZERO, false, true, src);
- } else {
- return -1;
- }
- }
-
- if (ensure_inputs (ChanCount(other_port->type(), 1), true, true, src)) {
- return -1;
- }
-
- return connect_input (_inputs.port(0), other_port->name(), src);
-}
-
-int
-IO::remove_output_port (Port* port, void* src)
-{
- IOChange change (NoChange);
-
- {
- BLOCK_PROCESS_CALLBACK ();
-
-
- {
- Glib::Mutex::Lock lm (io_lock);
-
- if (n_outputs() <= _output_minimum) {
- /* sorry, you can't do this */
- return -1;
- }
-
- if (_outputs.remove(port)) {
- change = IOChange (change|ConfigurationChanged);
-
- if (port->connected()) {
- change = IOChange (change|ConnectionsChanged);
- }
-
- _session.engine().unregister_port (*port);
- drop_output_connection ();
-
- setup_peak_meters ();
- reset_panner ();
- }
- }
- }
-
- if (change != NoChange) {
- output_changed (change, src);
- _session.set_dirty ();
- return 0;
- }
-
- return -1;
-}
-
-/** Add an output port.
- *
- * @param destination Name of input port to connect new port to.
- * @param src Source for emitted ConfigurationChanged signal.
- * @param type Data type of port. Default value (NIL) will use this IO's default type.
- */
-int
-IO::add_output_port (string destination, void* src, DataType type)