NO-OP: whitespace
[ardour.git] / libs / ardour / internal_return.cc
1 /*
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>
6  *
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.
11  *
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.
16  *
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.
20  */
21
22 #include <glibmm/threads.h>
23
24 #include "ardour/internal_return.h"
25 #include "ardour/internal_send.h"
26 #include "ardour/route.h"
27
28 using namespace std;
29 using namespace ARDOUR;
30
31 InternalReturn::InternalReturn (Session& s)
32         : Return (s, true)
33 {
34         _display_to_user = false;
35 }
36
37 void
38 InternalReturn::run (BufferSet& bufs, samplepos_t /*start_sample*/, samplepos_t /*end_sample*/, double /*speed*/, pframes_t nframes, bool)
39 {
40         if (!_active && !_pending_active) {
41                 return;
42         }
43         _active = _pending_active;
44
45         Glib::Threads::Mutex::Lock lm (_sends_mutex, Glib::Threads::TRY_LOCK);
46
47         if (!lm.locked ()) {
48                 return;
49         }
50
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);
54                 }
55         }
56 }
57
58 void
59 InternalReturn::add_send (InternalSend* send)
60 {
61         Glib::Threads::Mutex::Lock lm (_sends_mutex);
62         _sends.push_back (send);
63 }
64
65 void
66 InternalReturn::remove_send (InternalSend* send)
67 {
68         Glib::Threads::Mutex::Lock lm (_sends_mutex);
69         _sends.remove (send);
70 }
71
72 void
73 InternalReturn::set_playback_offset (samplecnt_t cnt)
74 {
75         Processor::set_playback_offset (cnt);
76
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);
80         }
81 }
82
83 XMLNode&
84 InternalReturn::state ()
85 {
86         XMLNode& node (Return::state ());
87         /* override type */
88         node.set_property("type", "intreturn");
89         return node;
90 }
91
92 bool
93 InternalReturn::can_support_io_configuration (const ChanCount& in, ChanCount& out)
94 {
95         out = in;
96         return true;
97 }
98
99 bool
100 InternalReturn::configure_io (ChanCount in, ChanCount out)
101 {
102         IOProcessor::configure_io (in, out);
103         return true;
104 }