fix crash when copy'ing latent plugins
[ardour.git] / libs / ardour / return.cc
index 8433f7de0881aab113c3a3c827ca9971762336e9..5c92b9051cb2f0557deb6b6cfdb108b7bc388d18 100644 (file)
 #include "pbd/xml++.h"
 
 #include "ardour/amp.h"
-#include "ardour/audio_port.h"
+#include "ardour/audioengine.h"
 #include "ardour/buffer_set.h"
+#include "ardour/gain_control.h"
 #include "ardour/io.h"
 #include "ardour/meter.h"
-#include "ardour/panner.h"
-#include "ardour/port.h"
 #include "ardour/return.h"
 #include "ardour/session.h"
-#include "ardour/mute_master.h"
-#include "ardour/audioengine.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace ARDOUR;
 using namespace PBD;
@@ -53,19 +50,12 @@ Return::Return (Session& s, bool internal)
 {
        /* never muted */
 
-       _amp.reset (new Amp (_session));
-       _meter.reset (new PeakMeter (_session));
-}
-
-Return::Return (Session& s, const std::string& name, uint32_t bslot, bool internal)
-       : IOProcessor (s, (internal ? false : true), false, name)
-       , _metering (false)
-       , _bitslot (bslot)
-{
-       /* never muted */
+       boost::shared_ptr<AutomationList> gl (new AutomationList (Evoral::Parameter (GainAutomation)));
+       _gain_control = boost::shared_ptr<GainControl> (new GainControl (_session, Evoral::Parameter (GainAutomation), gl));
+       add_control (_gain_control);
 
-       _amp.reset (new Amp (_session));
-       _meter.reset (new PeakMeter (_session));
+       _amp.reset (new Amp (_session, X_("Fader"), _gain_control, true));
+       _meter.reset (new PeakMeter (_session, name()));
 }
 
 Return::~Return ()
@@ -96,7 +86,7 @@ Return::set_state (const XMLNode& node, int version)
 {
        XMLNodeList nlist = node.children();
        XMLNodeIterator niter;
-       const XMLProperty* prop;
+       XMLProperty const * prop;
        const XMLNode* insert_node = &node;
 
        /* Return has regular IO automation (gain, pan) */
@@ -125,7 +115,7 @@ Return::set_state (const XMLNode& node, int version)
 }
 
 void
-Return::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool)
+Return::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool)
 {
        if ((!_active && !_pending_active) || _input->n_ports() == ChanCount::ZERO) {
                return;
@@ -137,13 +127,13 @@ Return::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pfra
        // Can't automate gain for sends or returns yet because we need different buffers
        // so that we don't overwrite the main automation data for the route amp
        // _amp->setup_gain_automation (start_frame, end_frame, nframes);
-       _amp->run (bufs, start_frame, end_frame, nframes, true);
+       _amp->run (bufs, start_frame, end_frame, speed, nframes, true);
 
        if (_metering) {
                if (_amp->gain_control()->get_value() == 0) {
                        _meter->reset();
                } else {
-                       _meter->run (bufs, start_frame, end_frame, nframes, true);
+                       _meter->run (bufs, start_frame, end_frame, speed, nframes, true);
                }
        }
 
@@ -151,7 +141,7 @@ Return::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pfra
 }
 
 bool
-Return::can_support_io_configuration (const ChanCount& in, ChanCount& out) const
+Return::can_support_io_configuration (const ChanCount& in, ChanCount& out)
 {
        out = in + _input->n_ports();
        return true;
@@ -166,7 +156,7 @@ Return::configure_io (ChanCount in, ChanCount out)
 
        // Ensure there are enough buffers (since we add some)
        if (_session.get_scratch_buffers(in).count() < out) {
-               Glib::Mutex::Lock em (_session.engine().process_lock());
+               Glib::Threads::Mutex::Lock em (_session.engine().process_lock());
                IO::PortCountChanged(out);
        }
 
@@ -174,16 +164,3 @@ Return::configure_io (ChanCount in, ChanCount out)
 
        return true;
 }
-
-/** Set up the XML description of a return so that we will not
- *  reset its name or bitslot during ::set_state()
- *  @param state XML return state.
- */
-void
-Return::make_unique (XMLNode &state)
-{
-       state.add_property ("ignore-bitslot", "1");
-       state.add_property ("ignore-name", "1");
-}
-
-