New test.
[ardour.git] / libs / ardour / io.cc
index 4f1b03dfdaf8d4684766b525878339db5cb9e5d8..aac2adf7849dbd25813cba9e67b3fb5aa472b33c 100644 (file)
@@ -292,6 +292,15 @@ IO::add_port (string destination, void* src, DataType type)
                type = _default_type;
        }
 
+       ChanCount before = _ports.count ();
+       ChanCount after = before;
+       after.set (type, after.get (type) + 1);
+       
+       bool const r = PortCountChanging (after); /* EMIT SIGNAL */
+       if (r) {
+               return -1;
+       }
+       
        IOChange change;
 
        {
@@ -1478,10 +1487,14 @@ IO::name_from_state (const XMLNode& node)
 void
 IO::set_name_in_state (XMLNode& node, const string& new_name)
 {
-       const XMLProperty* prop;
-
-       if ((prop = node.property ("name")) != 0) {
-               node.add_property ("name", new_name);
+       node.add_property (X_("name"), new_name);
+       XMLNodeList children = node.children ();
+       for (XMLNodeIterator i = children.begin(); i != children.end(); ++i) {
+               if ((*i)->name() == X_("Port")) {
+                       string const old_name = (*i)->property(X_("name"))->value();
+                       string const old_name_second_part = old_name.substr (old_name.find_first_of ("/") + 1);
+                       (*i)->add_property (X_("name"), string_compose ("%1/%2", new_name, old_name_second_part));
+               }
        }
 }
 
@@ -1535,12 +1548,19 @@ IO::connected_to (const string& str) const
        return false;
 }
 
-/** Caller must hold process lock */
+/** Call a processor's ::run() method, giving it our buffers
+ *  Caller must hold process lock.
+ */
 void
 IO::process_input (boost::shared_ptr<Processor> proc, framepos_t start_frame, framepos_t end_frame, pframes_t nframes)
 {
        /* don't read the data into new buffers - just use the port buffers directly */
 
+       if (n_ports().n_total() == 0) {
+               /* We have no ports, so nothing to process */
+               return;
+       }
+
        _buffers.get_jack_port_addresses (_ports, nframes);
        proc->run (_buffers, start_frame, end_frame, nframes, true);
 }