X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Faudio_port.cc;h=240224ea5e5b33112ae3e72f5e6c21ca5851eac8;hb=07112b55e0bb7ceb9e5c05ab4df167ecaf7edd9b;hp=23c8ab8335cb520d338210eed427e6435e20dcee;hpb=f3cf31009a3b52fa126356b6f826958393c6a956;p=ardour.git diff --git a/libs/ardour/audio_port.cc b/libs/ardour/audio_port.cc index 23c8ab8335..240224ea5e 100644 --- a/libs/ardour/audio_port.cc +++ b/libs/ardour/audio_port.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2006 Paul Davis + Copyright (C) 2006 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,35 +17,74 @@ */ #include -#include -#include + +#include "pbd/stacktrace.h" + +#include "ardour/audio_buffer.h" +#include "ardour/audio_port.h" +#include "ardour/data_type.h" using namespace ARDOUR; using namespace std; -nframes_t AudioPort::_short_over_length = 2; -nframes_t AudioPort::_long_over_length = 10; +AudioPort::AudioPort (const std::string& name, Flags flags) + : Port (name, DataType::AUDIO, flags) + , _buffer (new AudioBuffer (0)) +{ + assert (name.find_first_of (':') == string::npos); +} + +AudioPort::~AudioPort () +{ + delete _buffer; +} -AudioPort::AudioPort() - : _buffer (0) +void +AudioPort::cycle_start (pframes_t nframes) { - _type = DataType::AUDIO; - reset(); + /* caller must hold process lock */ + + Port::cycle_start (nframes); + + if (sends_output()) { + _buffer->prepare (); + } } void -AudioPort::reset() +AudioPort::cycle_end (pframes_t) { - Port::reset(); - if (_flags & IsOutput) { - if (_buffer.capacity() > 0) { - _buffer.clear(); + if (sends_output() && !_buffer->written()) { + /* we can't use nframes here because the current buffer capacity may + be shorter than the full buffer size if we split the cycle. + */ + if (_buffer->capacity () > 0) { + _buffer->silence (_buffer->capacity()); } - assert(_buffer.silent()); } - - _metering = 0; - reset_meters (); } +void +AudioPort::cycle_split () +{ +} + +AudioBuffer& +AudioPort::get_audio_buffer (pframes_t nframes) +{ + /* caller must hold process lock */ + _buffer->set_data ((Sample *) jack_port_get_buffer (_jack_port, _cycle_nframes) + + _global_port_buffer_offset + _port_buffer_offset, nframes); + return *_buffer; +} + +Sample* +AudioPort::engine_get_whole_audio_buffer () +{ + /* caller must hold process lock */ + return (Sample *) jack_port_get_buffer (_jack_port, _cycle_nframes); +} + + +