Fix previous.
[ardour.git] / libs / ardour / capturing_processor.cc
1 /*
2     Copyright (C) 2011 Paul Davis
3     Author: Sakari Bergen
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #include "ardour/capturing_processor.h"
22 #include "ardour/session.h"
23 #include "ardour/audioengine.h"
24
25 namespace ARDOUR {
26
27 CapturingProcessor::CapturingProcessor (Session & session)
28         : Processor (session, X_("capture point"))
29         , block_size (session.engine().frames_per_cycle())
30 {
31         realloc_buffers ();
32 }
33
34 CapturingProcessor::~CapturingProcessor()
35 {
36 }
37
38 int
39 CapturingProcessor::set_block_size (pframes_t nframes)
40 {
41         block_size = nframes;
42         realloc_buffers();
43         return 0;
44 }
45
46 void
47 CapturingProcessor::run (BufferSet& bufs, framepos_t, framepos_t, pframes_t nframes, bool)
48 {
49         if (active()) {
50                 capture_buffers.read_from (bufs, nframes);
51         }
52 }
53
54 bool
55 CapturingProcessor::configure_io (ChanCount in, ChanCount out)
56 {
57         Processor::configure_io (in, out);
58         realloc_buffers();
59         return true;
60 }
61
62 bool
63 CapturingProcessor::can_support_io_configuration (const ChanCount& in, ChanCount& out) const
64 {
65         out = in;
66         return true;
67 }
68
69 void
70 CapturingProcessor::realloc_buffers()
71 {
72         capture_buffers.ensure_buffers (_configured_input, block_size);
73 }
74
75 XMLNode &
76 CapturingProcessor::state (bool full)
77 {
78         XMLNode& node = Processor::state (full);
79
80         node.add_property (X_("type"), X_("capture"));
81         return node;
82 }
83         
84 } // namespace ARDOUR