XMLNode* pnode = new XMLNode (X_("Port"));
pnode->add_property (X_("type"), i->type().to_string());
+ pnode->add_property (X_("name"), i->name());
if (i->get_connections (connections)) {
client name is different.
*/
- pnode->add_property (X_("connection"), _session.engine().make_port_name_relative (*ci));
+ XMLNode* cnode = new XMLNode (X_("Connection"));
+
+ cnode->add_property (X_("other"), _session.engine().make_port_name_relative (*ci));
+ pnode->add_child_nocopy (*cnode);
}
}
_direction = (Direction) string_2_enum (prop->value(), _direction);
}
- if (!connecting_legal) {
- pending_state_node = new XMLNode (node);
- }
-
if (create_ports (node)) {
return -1;
}
}
} else {
-
+
+ pending_state_node = new XMLNode (node);
connection_legal_c = ConnectingLegal.connect (mem_fun (*this, &IO::connecting_became_legal));
}
{
const XMLProperty* prop;
- if ((prop = node.property ("connection")) != 0) {
- boost::shared_ptr<Bundle> c = find_possible_bundle (prop->value());
-
- if (!c) {
- return -1;
- }
-
- if (n_ports().get(c->type()) == c->nchannels() && c->ports_are_outputs()) {
- connect_ports_to_bundle (c, this);
- }
-
- return 0;
- }
-
- uint32_t n = 0;
-
for (XMLNodeConstIterator i = node.children().begin(); i != node.children().end(); ++i) {
if ((*i)->name() == "Bundle") {
}
if ((*i)->name() == "Port") {
- Port* p = nth (n++);
- XMLProperty* prop = (*i)->property ("connection");
- if (p && prop) {
- p->connect (prop->value());
+
+ prop = (*i)->property (X_("name"));
+
+ if (!prop) {
+ continue;
+ }
+
+ Port* p = port_by_name (prop->value());
+
+ if (p) {
+ for (XMLNodeConstIterator c = (*i)->children().begin(); c != (*i)->children().end(); ++c) {
+
+ XMLNode* cnode = (*c);
+
+ if (cnode->name() != X_("Connection")) {
+ continue;
+ }
+
+ if ((prop = cnode->property (X_("other"))) == 0) {
+ continue;
+ }
+
+ if (prop) {
+ p->connect (prop->value());
+ }
+ }
}
}
}
bool
IO::set_name (const string& requested_name)
{
- if (requested_name == _name) {
+ string name = requested_name;
+
+ if (name == _name) {
return true;
}
- string name;
- Route *rt;
- if ( (rt = dynamic_cast<Route *>(this))) {
- name = Route::ensure_track_or_route_name(requested_name, _session);
- } else {
- name = requested_name;
- }
-
-
/* replace all colons in the name. i wish we didn't have to do this */
if (replace_all (name, ":", "-")) {
i->set_name (current_name);
}
- bool const r = SessionObject::set_name(name);
+ bool const r = SessionObject::set_name (name);
setup_bundles ();
bool
IO::connected_to (boost::shared_ptr<const IO> other) const
{
+ if (!other) {
+ /* do we have any connections at all? */
+
+ for (PortSet::const_iterator p = _ports.begin(); p != _ports.end(); ++p) {
+ if (p->connected()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
assert (_direction != other->direction());
uint32_t i, j;
/* don't read the data into new buffers - just use the port buffers directly */
bufs.attach_buffers (_ports, nframes, 0);
- proc->run_in_place (bufs, start_frame, end_frame, nframes);
+ proc->run (bufs, start_frame, end_frame, nframes);
}
void
++o;
}
}
+
+Port*
+IO::port_by_name (const std::string& str) const
+{
+ /* to be called only from ::set_state() - no locking */
+
+ for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
+
+ const Port& p(*i);
+
+ if (p.name() == str) {
+ return const_cast<Port*>(&p);
+ }
+ }
+
+ return 0;
+}