2 Copyright (C) 2006 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.
20 #include <ardour/audio_port.h>
21 #include <ardour/jack_audio_port.h>
22 #include <ardour/audioengine.h>
23 #include <ardour/data_type.h>
25 using namespace ARDOUR;
28 AudioPort::AudioPort (const std::string& name, Flags flags, bool external, nframes_t capacity)
30 , BaseAudioPort (name, flags)
31 , PortFacade (name, flags)
33 if (!external || receives_input()) {
35 /* internal-only and input ports need their own buffers.
36 external output ports use the external port buffer.
39 _buffer = new AudioBuffer (capacity);
50 /* make the JackAudioPort create its own buffer. For input,
51 we will copy from it during cycle_start(). For output,
52 we will set up our buffer to point to its buffer, which
53 will in turn be using the JACK port buffer for data.
56 _ext_port = new JackAudioPort (name, flags, 0);
59 _buffer = &dynamic_cast<JackAudioPort*>(_ext_port)->get_audio_buffer();
62 Port::set_name (_ext_port->name());
68 AudioPort::~AudioPort()
79 BaseAudioPort::reset();
88 AudioPort::cycle_start (nframes_t nframes, nframes_t offset)
90 /* caller must hold process lock */
93 _ext_port->cycle_start (nframes, offset);
96 if (_flags & IsInput) {
99 _buffer->read_from (dynamic_cast<BaseAudioPort*>(_ext_port)->get_audio_buffer(), nframes, offset);
101 if (!_connections.empty()) {
102 (*_mixdown) (_connections, _buffer, nframes, offset, false);
107 if (_connections.empty()) {
108 _buffer->silence (nframes, offset);
110 (*_mixdown) (_connections, _buffer, nframes, offset, true);
116 // XXX if we could get the output stage to not purely mix into, but also
117 // to initially overwrite the buffer, we could avoid this silence step.
119 _buffer->silence (nframes, offset);
124 AudioPort::cycle_end (nframes_t nframes, nframes_t offset)