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 <ardour/base_audio_port.h>
22 #include <ardour/audioengine.h>
23 #include <ardour/data_type.h>
25 using namespace ARDOUR;
28 nframes_t BaseAudioPort::_short_over_length = 2;
29 nframes_t BaseAudioPort::_long_over_length = 10;
31 BaseAudioPort::BaseAudioPort (const std::string& name, Flags flgs)
36 _type = DataType::AUDIO;
37 _mixdown = default_mixdown;
40 BaseAudioPort::~BaseAudioPort ()
42 if (_own_buffer && _buffer) {
48 BaseAudioPort::reset()
52 if (_own_buffer && _buffer) {
53 _buffer->resize (engine->frames_per_cycle());
62 BaseAudioPort::default_mixdown (const set<Port*>& ports, AudioBuffer* dest, nframes_t cnt, nframes_t offset, bool first_overwrite)
64 set<Port*>::const_iterator p = ports.begin();
66 if (first_overwrite) {
67 dest->read_from ((dynamic_cast<BaseAudioPort*>(*p))->get_audio_buffer(), cnt, offset);
71 for (; p != ports.end(); ++p) {
72 dest->accumulate_from ((dynamic_cast<BaseAudioPort*>(*p))->get_audio_buffer(), cnt, offset);
77 BaseAudioPort::set_mixdown_function (void (*func)(const set<Port*>&, AudioBuffer*, nframes_t, nframes_t, bool))
79 g_atomic_pointer_set(&_mixdown, func);