Fix broken whitespace. I'd apologize for the compile times if it was my fault :D
[ardour.git] / libs / ardour / send.cc
index 9d5d2398c7224489d338c082f546c4510b028296..f537c9dfdfc7b21fb45d93103800c039f6950b2b 100644 (file)
@@ -38,8 +38,8 @@ using namespace ARDOUR;
 using namespace PBD;
 using namespace std;
 
-Send::Send (Session& s, boost::shared_ptr<MuteMaster> mm, Role r)
-       : Delivery (s, mm, string_compose (_("send %1"), (_bitslot = s.next_send_id()) + 1), r)
+Send::Send (Session& s, boost::shared_ptr<Pannable> p, boost::shared_ptr<MuteMaster> mm, Role r)
+       : Delivery (s, p, mm, string_compose (_("send %1"), (_bitslot = s.next_send_id()) + 1), r)
        , _metering (false)
 {
        _amp.reset (new Amp (_session));
@@ -66,12 +66,12 @@ Send::deactivate ()
        _amp->deactivate ();
        _meter->deactivate ();
        _meter->reset ();
-       
+
        Processor::deactivate ();
 }
 
 void
-Send::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, nframes_t nframes, bool)
+Send::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool)
 {
        if (_output->n_ports() == ChanCount::ZERO) {
                _meter->reset ();
@@ -133,14 +133,18 @@ Send::state (bool full)
        snprintf (buf, sizeof (buf), "%" PRIu32, _bitslot);
        node.add_property ("bitslot", buf);
 
+       node.add_child_nocopy (_amp->state (full));
+
        return node;
 }
 
 int
 Send::set_state (const XMLNode& node, int version)
 {
-       XMLNodeList nlist = node.children();
-       XMLNodeIterator niter;
+       if (version < 3000) {
+               return set_state_2X (node, version);
+       }
+
        const XMLProperty* prop;
 
        Delivery::set_state (node, version);
@@ -157,7 +161,47 @@ Send::set_state (const XMLNode& node, int version)
                 _session.mark_send_id (_bitslot);
         }
 
-       /* XXX need to load automation state & data for amp */
+       XMLNodeList nlist = node.children();
+       for (XMLNodeIterator i = nlist.begin(); i != nlist.end(); ++i) {
+               if ((*i)->name() == X_("Processor")) {
+                       _amp->set_state (**i, version);
+               }
+       }
+
+       return 0;
+}
+
+int
+Send::set_state_2X (const XMLNode& node, int /* version */)
+{
+       /* use the IO's name for the name of the send */
+       XMLNodeList const & children = node.children ();
+
+       XMLNodeList::const_iterator i = children.begin();
+       while (i != children.end() && (*i)->name() != X_("Redirect")) {
+               ++i;
+       }
+
+       if (i == children.end()) {
+               return -1;
+       }
+
+       XMLNodeList const & grand_children = (*i)->children ();
+       XMLNodeList::const_iterator j = grand_children.begin ();
+       while (j != grand_children.end() && (*j)->name() != X_("IO")) {
+               ++j;
+       }
+
+       if (j == grand_children.end()) {
+               return -1;
+       }
+
+       XMLProperty const * prop = (*j)->property (X_("name"));
+       if (!prop) {
+               return -1;
+       }
+
+       set_name (prop->value ());
 
        return 0;
 }
@@ -173,6 +217,7 @@ Send::can_support_io_configuration (const ChanCount& in, ChanCount& out) const
        return true;
 }
 
+/** Caller must hold process lock */
 bool
 Send::configure_io (ChanCount in, ChanCount out)
 {