replace fixed-point linear interpolation with double-based version, thereby removing...
[ardour.git] / libs / ardour / io.cc
index 014c0056779332adb44304fb362e953fcbb3fa66..8c14466b0082b8e24206b46036ec62c1b09ba9cf 100644 (file)
@@ -488,6 +488,7 @@ IO::state (bool full_state)
 
                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)) {
 
@@ -500,7 +501,10 @@ IO::state (bool full_state)
                                   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);
                        }       
                }
                
@@ -543,10 +547,6 @@ IO::set_state (const XMLNode& node)
                _direction = (Direction) string_2_enum (prop->value(), _direction);
        }
 
-       if (!connecting_legal) {
-               pending_state_node = new XMLNode (node);
-       } 
-
        if (create_ports (node)) {
                return -1;
        }
@@ -558,7 +558,8 @@ IO::set_state (const XMLNode& node)
                }
 
        } else {
-               
+
+               pending_state_node = new XMLNode (node);
                connection_legal_c = ConnectingLegal.connect (mem_fun (*this, &IO::connecting_became_legal));
        }
 
@@ -749,22 +750,6 @@ IO::make_connections (const XMLNode& node)
 {
        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") {
@@ -780,10 +765,32 @@ IO::make_connections (const XMLNode& node)
                }
 
                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());
+                                       }
+                               }
                        }
                }
        }
@@ -892,19 +899,12 @@ IO::parse_gain_string (const string& str, vector<string>& ports)
 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, ":", "-")) {
@@ -917,7 +917,7 @@ IO::set_name (const string& requested_name)
                i->set_name (current_name);
        }
 
-       bool const r = SessionObject::set_name(name);
+       bool const r = SessionObject::set_name (name);
 
        setup_bundles ();
 
@@ -1255,6 +1255,18 @@ IO::set_name_in_state (XMLNode& node, const string& new_name)
 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;
@@ -1280,7 +1292,7 @@ IO::process_input (boost::shared_ptr<Processor> proc, sframes_t start_frame, sfr
        /* 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
@@ -1336,3 +1348,20 @@ IO::copy_to_outputs (BufferSet& bufs, DataType type, nframes_t nframes, nframes_
                ++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;
+}