implement stub UnknownProcessor
[ardour.git] / libs / ardour / unknown_processor.cc
1 /*
2     Copyright (C) 2010 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #include "ardour/audio_buffer.h"
21 #include "ardour/unknown_processor.h"
22
23 #include "i18n.h"
24
25 using namespace std;
26 using namespace ARDOUR;
27
28 UnknownProcessor::UnknownProcessor (Session& s, XMLNode const & state)
29         : Processor (s, "")
30         , _state (state)
31         , have_ioconfig (false)
32         , saved_input (0)
33         , saved_output (0)
34 {
35         XMLProperty const * prop = state.property (X_("name"));
36         if (prop) {
37                 set_name (prop->value ());
38                 _display_to_user = true;
39         }
40
41         int have_io = 0;
42         XMLNodeList kids = state.children ();
43         for (XMLNodeIterator i = kids.begin(); i != kids.end(); ++i) {
44                 if ((*i)->name() == X_("ConfiguredInput")) {
45                         have_io |= 1;
46                         saved_input = new ChanCount(**i);
47                 }
48                 if ((*i)->name() == X_("ConfiguredOutput")) {
49                         have_io |= 2;
50                         saved_output = new ChanCount(**i);
51                 }
52         }
53         have_ioconfig = (have_io == 3);
54 }
55
56 UnknownProcessor::~UnknownProcessor () {
57         delete saved_input;;
58         delete saved_output;
59 }
60
61 XMLNode &
62 UnknownProcessor::state (bool)
63 {
64         return *(new XMLNode (_state));
65 }
66
67 bool
68 UnknownProcessor::can_support_io_configuration (const ChanCount &in, ChanCount & out) {
69         if (have_ioconfig && in == *saved_input) {
70                 out = *saved_output;
71                 return true;
72         }
73         return false;
74 }
75
76 void
77 UnknownProcessor::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t nframes, bool)
78 {
79         if (!have_ioconfig) {
80                 return;
81         }
82         // silence excess output buffers
83         for (uint32_t i = saved_input->n_audio(); i < saved_output->n_audio(); ++i) {
84                 bufs.get_audio (i).silence (nframes);
85         }
86 }