first part of fixing up send/return metering ; make send-controlling faders work...
[ardour.git] / libs / ardour / send.cc
index 61c235e60ae395ce9afc7d5885b33d43d1722b0e..ea4c16a416f04ded663236f91bb220b41a709b29 100644 (file)
@@ -36,8 +36,8 @@
 using namespace ARDOUR;
 using namespace PBD;
 
-Send::Send (Session& s, boost::shared_ptr<MuteMaster> mm)
-       : Delivery (s, mm, string_compose (_("send %1"), (_bitslot = s.next_send_id()) + 1), Delivery::Send)
+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)
        , _metering (false)
 {
        _amp.reset (new Amp (_session, _mute_master));
@@ -46,8 +46,8 @@ Send::Send (Session& s, boost::shared_ptr<MuteMaster> mm)
        ProcessorCreated (this); /* EMIT SIGNAL */
 }
 
-Send::Send (Session& s, boost::shared_ptr<MuteMaster> mm, const XMLNode& node)
-       : Delivery (s, mm, "send", Delivery::Send)
+Send::Send (Session& s, boost::shared_ptr<MuteMaster> mm, const XMLNode& node, Role r)
+        : Delivery (s, mm, "send", r)
        , _metering (false)
 {
        _amp.reset (new Amp (_session, _mute_master));
@@ -66,7 +66,25 @@ Send::~Send ()
 }
 
 void
-Send::run_in_place (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
+Send::activate ()
+{
+       _amp->activate ();
+       _meter->activate ();
+
+       Processor::activate ();
+}
+
+void
+Send::deactivate ()
+{
+       _amp->deactivate ();
+       _meter->deactivate ();
+
+       Processor::deactivate ();
+}
+
+void
+Send::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
 {
        if (!_active || _output->n_ports() == ChanCount::ZERO) {
                _meter->reset ();
@@ -85,11 +103,11 @@ Send::run_in_place (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame,
        // 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_in_place (sendbufs, start_frame, end_frame, nframes);
+       _amp->run (sendbufs, start_frame, end_frame, nframes);
 
        /* deliver to outputs */
 
-       Delivery::run_in_place (sendbufs, start_frame, end_frame, nframes);
+       Delivery::run (sendbufs, start_frame, end_frame, nframes);
 
        /* consider metering */
        
@@ -97,7 +115,7 @@ Send::run_in_place (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame,
                if (_amp->gain_control()->get_value() == 0) {
                        _meter->reset();
                } else {
-                       _meter->run_in_place (*_output_buffers, start_frame, end_frame, nframes);
+                       _meter->run (*_output_buffers, start_frame, end_frame, nframes);
                }
        }
 }
@@ -111,8 +129,9 @@ Send::get_state(void)
 XMLNode&
 Send::state(bool full)
 {
-       XMLNode& node = IOProcessor::state(full);
+       XMLNode& node = Delivery::state(full);
        char buf[32];
+
        node.add_property ("type", "send");
        snprintf (buf, sizeof (buf), "%" PRIu32, _bitslot);
        node.add_property ("bitslot", buf);
@@ -146,22 +165,22 @@ Send::set_state(const XMLNode& node)
 bool
 Send::can_support_io_configuration (const ChanCount& in, ChanCount& out) const
 {
-       if (_output->n_ports() == ChanCount::ZERO) {
-
-               /* not configured yet, we can support anything */
-
-               out = in;
-               return true; /* we can support anything the first time we're asked */
-
-       } else {
-
-               /* for a send, processor input corresponds to IO output */
+       /* sends have no impact at all on the channel configuration of the
+          streams passing through the route. so, out == in.
+       */
+       
+       out = in;
+       return true;
+}
 
-               out = in;
-               return true;
+bool
+Send::configure_io (ChanCount in, ChanCount out)
+{
+       if (!_amp->configure_io (in, out) || !_meter->configure_io (in, out)) {
+               return false;
        }
-
-       return false;
+       
+       return Processor::configure_io (in, out);
 }
 
 /** Set up the XML description of a send so that its name is unique.
@@ -182,6 +201,7 @@ Send::make_unique (XMLNode &state, Session &session)
        state.property("name")->set_value (name);
 
        XMLNode* io = state.child ("IO");
+
        if (io) {
                io->property("name")->set_value (name);
        }
@@ -190,12 +210,26 @@ Send::make_unique (XMLNode &state, Session &session)
 bool
 Send::set_name (const std::string& new_name)
 {
-       char buf[32];
        std::string unique_name;
 
-       snprintf (buf, sizeof (buf), "%u", _bitslot);
-       unique_name = new_name;
-       unique_name += buf;
+       if (_role == Delivery::Send) {
+               char buf[32];
+               snprintf (buf, sizeof (buf), "%u", _bitslot);
+               unique_name = new_name;
+               unique_name += buf;
+       } else {
+               unique_name = new_name;
+       }
 
        return Delivery::set_name (unique_name);
 }
+
+bool
+Send::visible () const
+{
+       if (_role == Listen) {
+               return false;
+       }
+
+       return true;
+}