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.
21 #include "pbd/stacktrace.h"
23 #include "ardour/audio_buffer.h"
24 #include "ardour/audioengine.h"
25 #include "ardour/audio_port.h"
26 #include "ardour/data_type.h"
27 #include "ardour/port_engine.h"
29 using namespace ARDOUR;
32 #define port_engine AudioEngine::instance()->port_engine()
34 AudioPort::AudioPort (const std::string& name, PortFlags flags)
35 : Port (name, DataType::AUDIO, flags)
36 , _buffer (new AudioBuffer (0))
38 assert (name.find_first_of (':') == string::npos);
41 AudioPort::~AudioPort ()
47 AudioPort::cycle_start (pframes_t nframes)
49 /* caller must hold process lock */
51 Port::cycle_start (nframes);
59 AudioPort::cycle_end (pframes_t nframes)
61 if (sends_output() && !_buffer->written()) {
62 if (_buffer->capacity() >= nframes) {
63 _buffer->silence (nframes);
69 AudioPort::cycle_split ()
74 AudioPort::get_audio_buffer (pframes_t nframes)
76 /* caller must hold process lock */
77 _buffer->set_data ((Sample *) port_engine.get_buffer (_port_handle, _cycle_nframes) +
78 _global_port_buffer_offset + _port_buffer_offset, nframes);
83 AudioPort::engine_get_whole_audio_buffer ()
85 /* caller must hold process lock */
86 return (Sample *) port_engine.get_buffer (_port_handle, _cycle_nframes);