*/
IO::IO (Session& s, const string& name,
int input_min, int input_max, int output_min, int output_max,
- DataType default_type, bool public_ports)
+ DataType default_type)
: SessionObject(s, name),
AutomatableControls (s),
_output_buffers (new BufferSet()),
_active(true),
_default_type (default_type),
- _public_ports (public_ports),
_input_minimum (ChanCount::ZERO),
_input_maximum (ChanCount::INFINITE),
_output_minimum (ChanCount::ZERO),
_session.add_controllable (_gain_control);
- create_bundles_for_inputs_and_outputs ();
+ setup_bundles_for_inputs_and_outputs ();
}
IO::IO (Session& s, const XMLNode& node, DataType dt)
_default_type (dt)
{
_meter = new PeakMeter (_session);
- _public_ports = true; // XXX get this from node
_panner = 0;
deferred_state = 0;
no_panner_reset = false;
_session.add_controllable (_gain_control);
- create_bundles_for_inputs_and_outputs ();
+ setup_bundles_for_inputs_and_outputs ();
}
IO::~IO ()
if (ok) {
new_list.push_back (*i);
} else {
- i->configuration_changed.disconnect ();
- i->ports_changed.disconnect ();
+ i->changed.disconnect ();
}
}
/* disconnect it from the source */
- if (_session.engine().disconnect (other_port, our_port->name())) {
+ if (our_port->disconnect (other_port)) {
error << string_compose(_("IO: cannot disconnect input port %1 from %2"), our_port->name(), other_port) << endmsg;
return -1;
}
/* connect it to the source */
- if (_session.engine().connect (other_port, our_port->name())) {
+ if (our_port->connect (other_port)) {
return -1;
}
}
/* disconnect it from the destination */
- if (_session.engine().disconnect (our_port->name(), other_port)) {
+ if (our_port->disconnect (other_port)) {
error << string_compose(_("IO: cannot disconnect output port %1 from %2"), our_port->name(), other_port) << endmsg;
return -1;
}
/* connect it to the destination */
- if (_session.engine().connect (our_port->name(), other_port)) {
+ if (our_port->connect (other_port)) {
return -1;
}
}
}
if (change == ConfigurationChanged) {
- setup_bundles_for_inputs_and_outputs ();
+ setup_bundle_for_outputs ();
}
if (change != NoChange) {
string portname = build_legal_port_name (type, false);
- if ((our_port = _session.engine().register_output_port (type, portname, _public_ports)) == 0) {
+ if ((our_port = _session.engine().register_output_port (type, portname)) == 0) {
error << string_compose(_("IO: cannot register output port %1"), portname) << endmsg;
return -1;
}
}
if (destination.length()) {
- if (_session.engine().connect (our_port->name(), destination)) {
+ if (our_port->connect (destination)) {
return -1;
}
}
// pan_changed (src); /* EMIT SIGNAL */
output_changed (ConfigurationChanged, src); /* EMIT SIGNAL */
- setup_bundles_for_inputs_and_outputs ();
+ setup_bundle_for_outputs ();
_session.set_dirty ();
return 0;
}
if (change == ConfigurationChanged) {
- setup_bundles_for_inputs_and_outputs ();
+ setup_bundle_for_inputs ();
}
if (change != NoChange) {
string portname = build_legal_port_name (type, true);
- if ((our_port = _session.engine().register_input_port (type, portname, _public_ports)) == 0) {
+ if ((our_port = _session.engine().register_input_port (type, portname)) == 0) {
error << string_compose(_("IO: cannot register input port %1"), portname) << endmsg;
return -1;
}
if (source.length()) {
- if (_session.engine().connect (source, our_port->name())) {
+ if (our_port->connect (source)) {
return -1;
}
}
// pan_changed (src); /* EMIT SIGNAL */
input_changed (ConfigurationChanged, src); /* EMIT SIGNAL */
- setup_bundles_for_inputs_and_outputs ();
+ setup_bundle_for_inputs ();
_session.set_dirty ();
return 0;
Glib::Mutex::Lock lm (io_lock);
for (PortSet::iterator i = _inputs.begin(); i != _inputs.end(); ++i) {
- _session.engine().disconnect (*i);
+ i->disconnect_all ();
}
check_bundles_connected_to_inputs ();
Glib::Mutex::Lock lm (io_lock);
for (PortSet::iterator i = _outputs.begin(); i != _outputs.end(); ++i) {
- _session.engine().disconnect (*i);
+ i->disconnect_all ();
}
check_bundles_connected_to_outputs ();
try {
- if ((input_port = _session.engine().register_input_port (*t, portname, _public_ports)) == 0) {
+ if ((input_port = _session.engine().register_input_port (*t, portname)) == 0) {
error << string_compose(_("IO: cannot register input port %1"), portname) << endmsg;
return -1;
}
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);
+ i->disconnect_all ();
}
}
string portname = build_legal_port_name (*t, true);
try {
- if ((port = _session.engine().register_input_port (*t, portname, _public_ports)) == 0) {
+ if ((port = _session.engine().register_input_port (*t, portname)) == 0) {
error << string_compose(_("IO: cannot register input port %1"), portname) << endmsg;
return -1;
}
string portname = build_legal_port_name (*t, false);
try {
- if ((port = _session.engine().register_output_port (*t, portname, _public_ports)) == 0) {
+ if ((port = _session.engine().register_output_port (*t, portname)) == 0) {
error << string_compose(_("IO: cannot register output port %1"), portname) << endmsg;
return -1;
}
/* 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);
+ i->disconnect_all ();
}
for (PortSet::iterator i = _outputs.begin(); i != _outputs.end(); ++i) {
- _session.engine().disconnect (*i);
+ i->disconnect_all ();
}
}
if (out_changed) {
check_bundles_connected_to_outputs ();
output_changed (ConfigurationChanged, src); /* EMIT SIGNAL */
+ setup_bundle_for_outputs ();
}
if (in_changed) {
check_bundles_connected_to_inputs ();
input_changed (ConfigurationChanged, src); /* EMIT SIGNAL */
+ setup_bundle_for_inputs ();
}
if (in_changed || out_changed) {
PortCountChanged (max (n_outputs(), n_inputs())); /* EMIT SIGNAL */
- setup_bundles_for_inputs_and_outputs ();
_session.set_dirty ();
}
if (changed) {
input_changed (ConfigurationChanged, src); /* EMIT SIGNAL */
- setup_bundles_for_inputs_and_outputs ();
+ setup_bundle_for_inputs ();
_session.set_dirty ();
}
return 0;
string portname = build_legal_port_name (*t, false);
- if ((output_port = _session.engine().register_output_port (*t, portname, _public_ports)) == 0) {
+ if ((output_port = _session.engine().register_output_port (*t, portname)) == 0) {
error << string_compose(_("IO: cannot register output port %1"), portname) << endmsg;
return -1;
}
if (clear) {
/* disconnect all existing ports so that we get a fresh start */
for (PortSet::iterator i = _outputs.begin(); i != _outputs.end(); ++i) {
- _session.engine().disconnect (*i);
+ i->disconnect_all ();
}
}
if (changed) {
output_changed (ConfigurationChanged, src); /* EMIT SIGNAL */
- setup_bundles_for_inputs_and_outputs ();
+ setup_bundle_for_outputs ();
}
return 0;
if ((prop = node.property ("name")) != 0) {
_name = prop->value();
/* used to set panner name with this, but no more */
- }
+ }
if ((prop = node.property ("id")) != 0) {
_id = prop->value ();
BLOCK_PROCESS_CALLBACK ();
Glib::Mutex::Lock lm2 (io_lock);
- /* Connect to the bundle, not worrying about any connections
- that are already made. */
-
- uint32_t cnt = c->nchannels ();
-
- for (uint32_t n = 0; n < cnt; ++n) {
- const Bundle::PortList& pl = c->channel_ports (n);
-
- for (Bundle::PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) {
-
- if (!_inputs.port(n)->connected_to (*i)) {
-
- if (_session.engine().connect (*i, _inputs.port(n)->name())) {
- return -1;
- }
- }
-
- }
- }
+ c->connect (_bundle_for_inputs, _session.engine());
/* If this is a UserBundle, make a note of what we've done */
}
int
-IO::connect_output_ports_to_bundle (boost::shared_ptr<Bundle> c, void* src)
+IO::disconnect_input_ports_from_bundle (boost::shared_ptr<Bundle> c, void* src)
{
{
BLOCK_PROCESS_CALLBACK ();
Glib::Mutex::Lock lm2 (io_lock);
- /* Connect to the bundle, not worrying about any connections
- that are already made. */
-
- uint32_t cnt = c->nchannels ();
-
- for (uint32_t n = 0; n < cnt; ++n) {
+ c->disconnect (_bundle_for_inputs, _session.engine());
+
+ /* If this is a UserBundle, make a note of what we've done */
- const Bundle::PortList& pl = c->channel_ports (n);
+ boost::shared_ptr<UserBundle> ub = boost::dynamic_pointer_cast<UserBundle> (c);
+ if (ub) {
- for (Bundle::PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) {
+ std::vector<UserBundleInfo>::iterator i = _bundles_connected_to_inputs.begin();
+ while (i != _bundles_connected_to_inputs.end() && i->bundle != ub) {
+ ++i;
+ }
- if (!_outputs.port(n)->connected_to (*i)) {
-
- if (_session.engine().connect (_outputs.port(n)->name(), *i)) {
- return -1;
- }
- }
+ if (i != _bundles_connected_to_inputs.end()) {
+ _bundles_connected_to_inputs.erase (i);
}
}
+ }
+
+ input_changed (IOChange (ConfigurationChanged|ConnectionsChanged), src); /* EMIT SIGNAL */
+ return 0;
+}
+
+int
+IO::connect_output_ports_to_bundle (boost::shared_ptr<Bundle> c, void* src)
+{
+ {
+ BLOCK_PROCESS_CALLBACK ();
+ Glib::Mutex::Lock lm2 (io_lock);
+
+ c->connect (_bundle_for_outputs, _session.engine());
/* If this is a UserBundle, make a note of what we've done */
return 0;
}
+int
+IO::disconnect_output_ports_from_bundle (boost::shared_ptr<Bundle> c, void* src)
+{
+ {
+ BLOCK_PROCESS_CALLBACK ();
+ Glib::Mutex::Lock lm2 (io_lock);
+
+ c->disconnect (_bundle_for_outputs, _session.engine());
+
+ /* If this is a UserBundle, make a note of what we've done */
+
+ boost::shared_ptr<UserBundle> ub = boost::dynamic_pointer_cast<UserBundle> (c);
+ if (ub) {
+
+ std::vector<UserBundleInfo>::iterator i = _bundles_connected_to_outputs.begin();
+ while (i != _bundles_connected_to_outputs.end() && i->bundle != ub) {
+ ++i;
+ }
+
+ if (i != _bundles_connected_to_outputs.end()) {
+ _bundles_connected_to_outputs.erase (i);
+ }
+ }
+ }
+
+ output_changed (IOChange (ConfigurationChanged|ConnectionsChanged), src); /* EMIT SIGNAL */
+ return 0;
+}
+
+
int
IO::disable_connecting ()
{
}
void
-IO::bundle_configuration_changed ()
+IO::bundle_changed (Bundle::Change c)
{
//XXX
// connect_input_ports_to_bundle (_input_bundle, this);
}
-void
-IO::bundle_ports_changed (int ignored)
-{
- //XXX
-// connect_output_ports_to_bundle (_output_bundle, this);
-}
-
void
IO::GainControl::set_value (float val)
{
/**
- * Setup bundles that describe our inputs and outputs.
+ * Setup bundles that describe our inputs and outputs. Also creates bundles if necessary.
*/
void
IO::setup_bundles_for_inputs_and_outputs ()
+{
+ setup_bundle_for_inputs ();
+ setup_bundle_for_outputs ();
+}
+
+
+void
+IO::setup_bundle_for_inputs ()
{
char buf[32];
+ if (!_bundle_for_inputs) {
+ _bundle_for_inputs.reset (new Bundle (true));
+ }
+
+ _bundle_for_inputs->suspend_signals ();
+
+ _bundle_for_inputs->set_type (default_type ());
+
_bundle_for_inputs->remove_channels ();
- _bundle_for_outputs->remove_channels ();
-
+
snprintf(buf, sizeof (buf), _("%s in"), _name.c_str());
_bundle_for_inputs->set_name (buf);
uint32_t const ni = inputs().num_ports();
_bundle_for_inputs->set_port (i, _session.engine().make_port_name_non_relative (inputs().port(i)->name()));
}
+ _bundle_for_inputs->resume_signals ();
+}
+
+
+void
+IO::setup_bundle_for_outputs ()
+{
+ char buf[32];
+
+ if (!_bundle_for_outputs) {
+ _bundle_for_outputs.reset (new Bundle (false));
+ }
+
+ _bundle_for_outputs->suspend_signals ();
+
+ _bundle_for_outputs->set_type (default_type ());
+
+ _bundle_for_outputs->remove_channels ();
+
snprintf(buf, sizeof (buf), _("%s out"), _name.c_str());
_bundle_for_outputs->set_name (buf);
uint32_t const no = outputs().num_ports();
_bundle_for_outputs->add_channel (bundle_channel_name (i, no));
_bundle_for_outputs->set_port (i, _session.engine().make_port_name_non_relative (outputs().port(i)->name()));
}
-}
-
-/**
- * Create and setup bundles that describe our inputs and outputs.
- */
-
-void
-IO::create_bundles_for_inputs_and_outputs ()
-{
- _bundle_for_inputs = boost::shared_ptr<Bundle> (new Bundle (true));
- _bundle_for_outputs = boost::shared_ptr<Bundle> (new Bundle (false));
- setup_bundles_for_inputs_and_outputs ();
+ _bundle_for_outputs->resume_signals ();
}
+
/** @return Bundles connected to our inputs */
BundleList
IO::bundles_connected_to_inputs ()
bundles.push_back (i->bundle);
}
- /* Normal bundles */
+ /* Session bundles */
boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
- if ((*i)->ports_are_outputs() == false || (*i)->nchannels() != n_inputs().n_total()) {
- continue;
+ if ((*i)->connected_to (_bundle_for_inputs, _session.engine())) {
+ bundles.push_back (*i);
}
+ }
- for (uint32_t j = 0; j < n_inputs().n_total(); ++j) {
-
- Bundle::PortList const& pl = (*i)->channel_ports (j);
- if (!pl.empty() && input(j)->connected_to (pl[0])) {
- bundles.push_back (*i);
- }
-
+ /* Route bundles */
+ boost::shared_ptr<ARDOUR::RouteList> r = _session.get_routes ();
+ for (ARDOUR::RouteList::iterator i = r->begin(); i != r->end(); ++i) {
+ if ((*i)->bundle_for_outputs()->connected_to (_bundle_for_inputs, _session.engine())) {
+ bundles.push_back ((*i)->bundle_for_outputs());
}
}
-
+
return bundles;
}
bundles.push_back (i->bundle);
}
- /* Auto bundles */
+ /* Session bundles */
boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
- if ((*i)->ports_are_inputs() == false || (*i)->nchannels() != n_outputs().n_total()) {
- continue;
+ if ((*i)->connected_to (_bundle_for_outputs, _session.engine())) {
+ bundles.push_back (*i);
}
+ }
- for (uint32_t j = 0; j < n_outputs().n_total(); ++j) {
-
- Bundle::PortList const& pl = (*i)->channel_ports (j);
-
- if (!pl.empty() && output(j)->connected_to (pl[0])) {
- bundles.push_back (*i);
- }
+ /* Route bundles */
+ boost::shared_ptr<ARDOUR::RouteList> r = _session.get_routes ();
+ for (ARDOUR::RouteList::iterator i = r->begin(); i != r->end(); ++i) {
+ if ((*i)->bundle_for_inputs()->connected_to (_bundle_for_outputs, _session.engine())) {
+ bundles.push_back ((*i)->bundle_for_inputs());
}
}
IO::UserBundleInfo::UserBundleInfo (IO* io, boost::shared_ptr<UserBundle> b)
{
bundle = b;
- configuration_changed = b->ConfigurationChanged.connect (
- sigc::mem_fun (*io, &IO::bundle_configuration_changed)
- );
- ports_changed = b->PortsChanged.connect (
- sigc::mem_fun (*io, &IO::bundle_ports_changed)
+ changed = b->Changed.connect (
+ sigc::mem_fun (*io, &IO::bundle_changed)
);
}