assert() to help find some possible causes of #2991. Fix some confusion with GTK...
[ardour.git] / libs / ardour / internal_send.cc
index 7d1f316c78f9a292031ed0390f78024a55d1b541..4a4823a29f0b7efbbebbe18b688f8e987080abc0 100644 (file)
@@ -43,13 +43,16 @@ InternalSend::InternalSend (Session& s, boost::shared_ptr<MuteMaster> mm, boost:
 
        set_name (sendto->name());
 
-       _send_to->GoingAway.connect (mem_fun (*this, &InternalSend::send_to_going_away));
+       _send_to->DropReferences.connect_same_thread (*this, boost::bind (&InternalSend::send_to_going_away, this));
+       _send_to->NameChanged.connect_same_thread (*this, boost::bind (&InternalSend::send_to_name_changed, this));
 }
 
 InternalSend::InternalSend (Session& s, boost::shared_ptr<MuteMaster> mm, const XMLNode& node)
-       : Send (s, mm, node, Delivery::Aux /* will be reset in set_state() */)
+       : Send (s, mm, node, Stateful::loading_state_version, Delivery::Aux /* will be reset in set_state() */),
+         target (0)
 {
-       set_state (node);
+       /* Send constructor will set its state, so here we just need to set up our own */
+       set_our_state (node, Stateful::loading_state_version);
 }
 
 InternalSend::~InternalSend ()
@@ -70,7 +73,7 @@ InternalSend::send_to_going_away ()
 }
 
 void
-InternalSend::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
+InternalSend::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool)
 {
        if ((!_active && !_pending_active) || !target || !_send_to) {
                _meter->reset ();
@@ -109,12 +112,11 @@ InternalSend::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame,
                Amp::apply_simple_gain (mixbufs, nframes, tgain);
        }
 
-
        // 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 (mixbufs, start_frame, end_frame, nframes);
+       _amp->run (mixbufs, start_frame, end_frame, nframes, true);
 
        /* XXX NEED TO PAN */
 
@@ -124,7 +126,7 @@ InternalSend::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame,
                if (_amp->gain_control()->get_value() == 0) {
                        _meter->reset();
                } else {
-                       _meter->run (mixbufs, start_frame, end_frame, nframes);
+                       _meter->run (mixbufs, start_frame, end_frame, nframes, true);
                }
        }
 
@@ -153,7 +155,7 @@ InternalSend::state (bool full)
 {
        XMLNode& node (Send::state (full));
 
-       /* this replaces any existing property */
+       /* this replaces any existing "type" property */
 
        node.add_property ("type", "intsend");
 
@@ -171,12 +173,10 @@ InternalSend::get_state()
 }
 
 int
-InternalSend::set_state (const XMLNode& node)
+InternalSend::set_our_state (const XMLNode& node, int /*version*/)
 {
        const XMLProperty* prop;
 
-       Send::set_state (node);
-
        if ((prop = node.property ("target")) != 0) {
 
                _send_to_id = prop->value();
@@ -187,7 +187,7 @@ InternalSend::set_state (const XMLNode& node)
                */
 
                if (!IO::connecting_legal) {
-                       connect_c = IO::ConnectingLegal.connect (mem_fun (*this, &InternalSend::connect_when_legal));
+                       IO::ConnectingLegal.connect_same_thread (connect_c, boost::bind (&InternalSend::connect_when_legal, this));
                } else {
                        connect_when_legal ();
                }
@@ -196,6 +196,13 @@ InternalSend::set_state (const XMLNode& node)
        return 0;
 }
 
+int
+InternalSend::set_state (const XMLNode& node, int version)
+{
+       Send::set_state (node, version);
+       return set_our_state (node, version);
+}
+
 int
 InternalSend::connect_when_legal ()
 {
@@ -260,3 +267,9 @@ InternalSend::visible () const
 
        return false;
 }
+
+void
+InternalSend::send_to_name_changed ()
+{
+       set_name (_send_to->name ());
+}