update route/processor semantics
[ardour.git] / libs / ardour / internal_return.cc
index 568604272b8785b44bba30293b36fc426b14efda..e42c067454823d7bc1341df08123f3c48e131424 100644 (file)
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
 
-#include "pbd/failed_constructor.h"
-
-#include "ardour/audio_buffer.h"
 #include "ardour/internal_return.h"
-#include "ardour/mute_master.h"
-#include "ardour/session.h"
 #include "ardour/internal_send.h"
-#include "ardour/audioengine.h"
+#include "ardour/route.h"
 
 using namespace std;
 using namespace ARDOUR;
@@ -37,17 +32,19 @@ InternalReturn::InternalReturn (Session& s)
 }
 
 void
-InternalReturn::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t nframes, bool)
+InternalReturn::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, double /*speed*/, pframes_t nframes, bool)
 {
        if (!_active && !_pending_active) {
                return;
        }
 
-       /* _sends is only modified with the process lock held, so this is ok, I think */
+       Glib::Threads::Mutex::Lock lm (_sends_mutex, Glib::Threads::TRY_LOCK);
 
-       for (list<InternalSend*>::iterator i = _sends.begin(); i != _sends.end(); ++i) {
-               if ((*i)->active ()) {
-                       bufs.merge_from ((*i)->get_buffers(), nframes);
+       if (lm.locked ()) {
+               for (list<InternalSend*>::iterator i = _sends.begin(); i != _sends.end(); ++i) {
+                       if ((*i)->active () && (!(*i)->source_route() || (*i)->source_route()->active())) {
+                               bufs.merge_from ((*i)->get_buffers(), nframes);
+                       }
                }
        }
 
@@ -57,14 +54,14 @@ InternalReturn::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*e
 void
 InternalReturn::add_send (InternalSend* send)
 {
-       Glib::Mutex::Lock lm (_session.engine().process_lock());
+       Glib::Threads::Mutex::Lock lm (_sends_mutex);
        _sends.push_back (send);
 }
 
 void
 InternalReturn::remove_send (InternalSend* send)
 {
-       Glib::Mutex::Lock lm (_session.engine().process_lock());
+       Glib::Threads::Mutex::Lock lm (_sends_mutex);
        _sends.remove (send);
 }
 
@@ -84,8 +81,15 @@ InternalReturn::get_state()
 }
 
 bool
-InternalReturn::can_support_io_configuration (const ChanCount& in, ChanCount& out) const
+InternalReturn::can_support_io_configuration (const ChanCount& in, ChanCount& out)
 {
        out = in;
        return true;
 }
+
+bool
+InternalReturn::configure_io (ChanCount in, ChanCount out)
+{
+       IOProcessor::configure_io (in, out);
+       return true;
+}