LV2 support.
[ardour.git] / libs / ardour / send.cc
index b37168807e9e06f04435a12e51a7737bb7ef1526..614195ac2d890659b1b8da6155910f7880f218c2 100644 (file)
@@ -15,7 +15,6 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 */
 
 #include <algorithm>
@@ -32,12 +31,11 @@ using namespace ARDOUR;
 using namespace PBD;
 
 Send::Send (Session& s, Placement p)
-       : Redirect (s, s.next_send_name(), p)
+       : Redirect (s, string_compose (_("send %1"), (bitslot = s.next_send_id()) + 1), p)
 {
        _metering = false;
        expected_inputs = 0;
-       save_state (_("initial state"));
-        RedirectCreated (this); /* EMIT SIGNAL */
+       RedirectCreated (this); /* EMIT SIGNAL */
 }
 
 Send::Send (Session& s, const XMLNode& node)
@@ -46,20 +44,21 @@ Send::Send (Session& s, const XMLNode& node)
        _metering = false;
        expected_inputs = 0;
 
+       bitslot = 0xffffffff;
+
        if (set_state (node)) {
                throw failed_constructor();
        }
 
-       save_state (_("initial state"));
-        RedirectCreated (this); /* EMIT SIGNAL */
+       RedirectCreated (this); /* EMIT SIGNAL */
 }
 
 Send::Send (const Send& other)
-       : Redirect (other._session, other._session.next_send_name(), other.placement())
+       : Redirect (other._session, string_compose (_("send %1"), (bitslot = other._session.next_send_id()) + 1), other.placement())
 {
        _metering = false;
        expected_inputs = 0;
-       save_state (_("initial state"));
+
        RedirectCreated (this); /* EMIT SIGNAL */
 }
 
@@ -78,7 +77,10 @@ XMLNode&
 Send::state(bool full)
 {
        XMLNode *node = new XMLNode("Send");
-       node->add_child_nocopy (Redirect::state(full));
+       char buf[32];
+       node->add_child_nocopy (Redirect::state (full));
+       snprintf (buf, sizeof (buf), "%" PRIu32, bitslot);
+       node->add_property ("bitslot", buf);
        return *node;
 }
 
@@ -87,11 +89,27 @@ Send::set_state(const XMLNode& node)
 {
        XMLNodeList nlist = node.children();
        XMLNodeIterator niter;
-       
+       const XMLProperty* prop;
+
+       if ((prop = node.property ("bitslot")) == 0) {
+               bitslot = _session.next_send_id();
+       } else {
+               uint32_t old_bitslot = bitslot;
+               sscanf (prop->value().c_str(), "%" PRIu32, &bitslot);
+
+               if (bitslot != old_bitslot) {
+                       _session.mark_send_id (bitslot);
+               }
+       }
+
+       /* Send has regular IO automation (gain, pan) */
+
        for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
                if ((*niter)->name() == Redirect::state_node_name) {
                        Redirect::set_state (**niter);
                        break;
+               } else if ((*niter)->name() == X_("Automation")) {
+                       IO::set_automation_state (*(*niter));
                }
        }