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"
28 using namespace ARDOUR;
30 sigc::signal<void,nframes_t> InternalReturn::CycleStart;
32 InternalReturn::InternalReturn (Session& s)
36 CycleStart.connect (mem_fun (*this, &InternalReturn::cycle_start));
39 InternalReturn::InternalReturn (Session& s, const XMLNode& node)
40 : Return (s, node, true)
43 CycleStart.connect (mem_fun (*this, &InternalReturn::cycle_start));
47 InternalReturn::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
49 if (user_count == 0) {
50 /* nothing to do - nobody is feeding us anything */
54 /* XXX this should be merge() */
56 bufs.merge_from (buffers, nframes);
60 InternalReturn::configure_io (ChanCount in, ChanCount out)
62 IOProcessor::configure_io (in, out);
63 allocate_buffers (_session.get_block_size());
68 InternalReturn::set_block_size (nframes_t nframes)
70 allocate_buffers (nframes);
74 InternalReturn::allocate_buffers (nframes_t nframes)
76 buffers.ensure_buffers (DataType::AUDIO, _configured_input.n_audio(), nframes);
77 buffers.ensure_buffers (DataType::MIDI, _configured_input.n_midi(), nframes);
81 InternalReturn::get_buffers ()
83 Glib::Mutex::Lock lm (_session.engine().process_lock());
89 InternalReturn::release_buffers ()
91 Glib::Mutex::Lock lm (_session.engine().process_lock());
98 InternalReturn::cycle_start (nframes_t nframes)
100 /* called from process cycle - no lock necessary */
102 /* don't bother with this if nobody is going to feed us anything */
103 buffers.silence (nframes, 0);
108 InternalReturn::state (bool full)
110 XMLNode& node (Return::state (full));
112 node.add_property("type", "intreturn");
117 InternalReturn::get_state()
123 InternalReturn::set_state (const XMLNode& node)
125 return Return::set_state (node);
129 InternalReturn::can_support_io_configuration (const ChanCount& in, ChanCount& out) const