remove offset from process callback tree. some breakage may have occured. yes, really.
[ardour.git] / libs / ardour / send.cc
index a80e99a1ee216277807fe3fd46baf1a5112b842e..ef6f954dd2ea40c8afaebdc08fc2ff4486e2d2ca 100644 (file)
 
 #include <algorithm>
 
-#include <pbd/xml++.h>
-
-#include <ardour/send.h>
-#include <ardour/session.h>
-#include <ardour/port.h>
-#include <ardour/audio_port.h>
-#include <ardour/buffer_set.h>
-#include <ardour/meter.h>
+#include "pbd/xml++.h"
+
+#include "ardour/send.h"
+#include "ardour/session.h"
+#include "ardour/port.h"
+#include "ardour/audio_port.h"
+#include "ardour/buffer_set.h"
+#include "ardour/meter.h"
+#include "ardour/panner.h"
+#include "ardour/io.h"
+
 #include "i18n.h"
 
 using namespace ARDOUR;
@@ -40,7 +43,7 @@ Send::Send (Session& s, Placement p)
 }
 
 Send::Send (Session& s, const XMLNode& node)
-       : IOProcessor (s,  "send", PreFader)
+       : IOProcessor (s, "send", PreFader)
 {
        _metering = false;
 
@@ -51,13 +54,6 @@ Send::Send (Session& s, const XMLNode& node)
        ProcessorCreated (this); /* EMIT SIGNAL */
 }
 
-Send::Send (const Send& other)
-       : IOProcessor (other._session, string_compose (_("send %1"), (bitslot = other._session.next_send_id()) + 1), other.placement())
-{
-       _metering = false;
-       ProcessorCreated (this); /* EMIT SIGNAL */
-}
-
 Send::~Send ()
 {
        GoingAway ();
@@ -103,7 +99,7 @@ Send::set_state(const XMLNode& node)
                if ((*niter)->name() == "IOProcessor") {
                        insert_node = *niter;
                } else if ((*niter)->name() == X_("Automation")) {
-                       _io->set_automation_state (*(*niter), Parameter(GainAutomation));
+                       // _io->set_automation_state (*(*niter), Evoral::Parameter(GainAutomation));
                }
        }
        
@@ -113,7 +109,7 @@ Send::set_state(const XMLNode& node)
 }
 
 void
-Send::run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset)
+Send::run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes)
 {
        if (active()) {
 
@@ -125,21 +121,21 @@ Send::run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame,
                sendbufs.read_from(bufs, nframes);
                assert(sendbufs.count() == bufs.count());
 
-               _io->deliver_output (sendbufs, start_frame, end_frame, nframes, offset);
+               _io->deliver_output (sendbufs, start_frame, end_frame, nframes);
 
                if (_metering) {
-                       if (_io->_gain == 0) {
-                               _io->_meter->reset();
+                       if (_io->effective_gain() == 0) {
+                               _io->peak_meter().reset();
                        } else {
-                               _io->_meter->run_in_place(_io->output_buffers(), start_frame, end_frame, nframes, offset);
+                               _io->peak_meter().run_in_place(_io->output_buffers(), start_frame, end_frame, nframes);
                        }
                }
 
        } else {
-               _io->silence (nframes, offset);
+               _io->silence (nframes);
                
                if (_metering) {
-                       _io->_meter->reset();
+                       _io->peak_meter().reset();
                }
        }
 }
@@ -227,3 +223,26 @@ Send::expect_inputs (const ChanCount& expected)
                _io->reset_panner ();
        }
 }
+
+/** Set up the XML description of a send so that its name is unique.
+ *  @param state XML send state.
+ *  @param session Session.
+ */
+void
+Send::make_unique (XMLNode &state, Session &session)
+{
+       uint32_t const bitslot = session.next_send_id() + 1;
+
+       char buf[32];
+       snprintf (buf, sizeof (buf), "%" PRIu32, bitslot);
+       state.property("bitslot")->set_value (buf);
+
+       std::string const name = string_compose (_("send %1"), bitslot);
+       
+       state.property("name")->set_value (name);
+
+       XMLNode* io = state.child ("IO");
+       if (io) {
+               io->property("name")->set_value (name);
+       }
+}