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/audioengine.h>
22 #include <ardour/data_type.h>
23 #include <ardour/audio_buffer.h>
25 using namespace ARDOUR;
28 AudioPort::AudioPort (const std::string& name, Flags flags)
29 : Port (name, DataType::AUDIO, flags)
30 , _buffer_data_set (false)
31 , _buffer (new AudioBuffer (0))
33 assert (name.find_first_of (':') == string::npos);
36 AudioPort::~AudioPort ()
42 AudioPort::cycle_start (nframes_t nframes, nframes_t offset)
44 /* caller must hold process lock */
46 /* get_buffer() must only be run on outputs here in cycle_start().
48 Inputs must be done in the correct processing order, which
49 requires interleaving with route processing. that will
50 happen when Port::get_buffer() is called.
53 if (sends_output() && !_buffer_data_set) {
55 _buffer->set_data ((Sample *) jack_port_get_buffer (_jack_port, nframes) + offset, nframes);
56 _buffer_data_set = true;
60 if (receives_input()) {
61 _buffer_data_set = false;
63 _buffer->silence (nframes, offset);
68 AudioPort::get_audio_buffer (nframes_t nframes, nframes_t offset)
70 /* caller must hold process lock */
72 if (receives_input () && !_buffer_data_set) {
74 _buffer->set_data ((Sample *) jack_port_get_buffer (_jack_port, nframes) + offset, nframes);
82 AudioPort::cycle_end (nframes_t nframes, nframes_t offset)
84 _buffer_data_set = false;