2 * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
3 * Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
4 * Copyright (C) 2009-2017 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2013-2017 Robin Gareus <robin@gareus.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <glibmm/threads.h>
24 #include "ardour/internal_return.h"
25 #include "ardour/internal_send.h"
26 #include "ardour/route.h"
29 using namespace ARDOUR;
31 InternalReturn::InternalReturn (Session& s)
34 _display_to_user = false;
38 InternalReturn::run (BufferSet& bufs, samplepos_t /*start_sample*/, samplepos_t /*end_sample*/, double /*speed*/, pframes_t nframes, bool)
40 if (!_active && !_pending_active) {
43 _active = _pending_active;
45 Glib::Threads::Mutex::Lock lm (_sends_mutex, Glib::Threads::TRY_LOCK);
51 for (list<InternalSend*>::iterator i = _sends.begin(); i != _sends.end(); ++i) {
52 if ((*i)->active () && (!(*i)->source_route() || (*i)->source_route()->active())) {
53 bufs.merge_from ((*i)->get_buffers(), nframes);
59 InternalReturn::add_send (InternalSend* send)
61 Glib::Threads::Mutex::Lock lm (_sends_mutex);
62 _sends.push_back (send);
66 InternalReturn::remove_send (InternalSend* send)
68 Glib::Threads::Mutex::Lock lm (_sends_mutex);
73 InternalReturn::set_playback_offset (samplecnt_t cnt)
75 Processor::set_playback_offset (cnt);
77 Glib::Threads::Mutex::Lock lm (_sends_mutex); // TODO reader lock
78 for (list<InternalSend*>::iterator i = _sends.begin(); i != _sends.end(); ++i) {
79 (*i)->set_delay_out (cnt);
84 InternalReturn::state ()
86 XMLNode& node (Return::state ());
88 node.set_property("type", "intreturn");
93 InternalReturn::can_support_io_configuration (const ChanCount& in, ChanCount& out)
100 InternalReturn::configure_io (ChanCount in, ChanCount out)
102 IOProcessor::configure_io (in, out);