remove unused SHUTTLE_FRACT constant
[ardour2.git] / libs / ardour / internal_return.cc
blob0316f7f325056c3e4863d36ffa32e3fcfda265a8
1 /*
2 Copyright (C) 2009 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include <glibmm/thread.h>
21 #include "pbd/failed_constructor.h"
23 #include "ardour/internal_return.h"
24 #include "ardour/mute_master.h"
25 #include "ardour/session.h"
26 #include "ardour/internal_send.h"
28 using namespace std;
29 using namespace ARDOUR;
31 PBD::Signal1<void, pframes_t> InternalReturn::CycleStart;
33 InternalReturn::InternalReturn (Session& s)
34 : Return (s, true)
36 CycleStart.connect_same_thread (*this, boost::bind (&InternalReturn::cycle_start, this, _1));
37 _display_to_user = false;
40 void
41 InternalReturn::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t nframes, bool)
43 if (!_active && !_pending_active) {
44 return;
47 /* _sends is only modified with the process lock held, so this is ok, I think */
49 for (list<InternalSend*>::iterator i = _sends.begin(); i != _sends.end(); ++i) {
50 if ((*i)->active ()) {
51 bufs.merge_from ((*i)->get_buffers(), nframes);
55 _active = _pending_active;
58 bool
59 InternalReturn::configure_io (ChanCount in, ChanCount out)
61 IOProcessor::configure_io (in, out);
62 allocate_buffers (_session.engine().frames_per_cycle());
63 return true;
66 int
67 InternalReturn::set_block_size (pframes_t nframes)
69 allocate_buffers (nframes);
70 return 0;
73 void
74 InternalReturn::allocate_buffers (pframes_t nframes)
76 buffers.ensure_buffers (_configured_input, nframes);
77 buffers.set_count (_configured_input);
80 void
81 InternalReturn::add_send (InternalSend* send)
83 Glib::Mutex::Lock lm (_session.engine().process_lock());
84 _sends.push_back (send);
87 void
88 InternalReturn::remove_send (InternalSend* send)
90 Glib::Mutex::Lock lm (_session.engine().process_lock());
91 _sends.remove (send);
94 void
95 InternalReturn::cycle_start (pframes_t nframes)
97 /* called from process cycle - no lock necessary */
98 if (!_sends.empty ()) {
99 /* don't bother with this if nobody is going to feed us anything */
100 buffers.silence (nframes, 0);
104 XMLNode&
105 InternalReturn::state (bool full)
107 XMLNode& node (Return::state (full));
108 /* override type */
109 node.add_property("type", "intreturn");
110 return node;
113 XMLNode&
114 InternalReturn::get_state()
116 return state (true);
120 InternalReturn::set_state (const XMLNode& node, int version)
122 return Return::set_state (node, version);
125 bool
126 InternalReturn::can_support_io_configuration (const ChanCount& in, ChanCount& out) const
128 out = in;
129 return true;