X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Faudio_port.cc;h=e2bb20dbe958c20753422e202e0d74cf8a911fa8;hb=91ab5e31751105d59386aab6a6e16ac5582904dc;hp=558ae72a97810dd8a809610fde64c323e27493da;hpb=d469cc3e3a536fceedbfc41e52ad3d7d178f7b0d;p=ardour.git diff --git a/libs/ardour/audio_port.cc b/libs/ardour/audio_port.cc index 558ae72a97..e2bb20dbe9 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,17 +17,22 @@ */ #include -#include -#include -#include -#include + +#include "pbd/stacktrace.h" + +#include "ardour/audio_buffer.h" +#include "ardour/audioengine.h" +#include "ardour/audio_port.h" +#include "ardour/data_type.h" +#include "ardour/port_engine.h" using namespace ARDOUR; using namespace std; -AudioPort::AudioPort (const std::string& name, Flags flags) +#define port_engine AudioEngine::instance()->port_engine() + +AudioPort::AudioPort (const std::string& name, PortFlags flags) : Port (name, DataType::AUDIO, flags) - , _buffer_data_set (false) , _buffer (new AudioBuffer (0)) { assert (name.find_first_of (':') == string::npos); @@ -39,47 +44,48 @@ AudioPort::~AudioPort () } void -AudioPort::cycle_start (nframes_t nframes, nframes_t offset) +AudioPort::cycle_start (pframes_t nframes) { /* caller must hold process lock */ - /* get_buffer() must only be run on outputs here in cycle_start(). + Port::cycle_start (nframes); - Inputs must be done in the correct processing order, which - requires interleaving with route processing. that will - happen when Port::get_buffer() is called. - */ - - if (sends_output() && !_buffer_data_set) { - - _buffer->set_data ((Sample *) jack_port_get_buffer (_jack_port, nframes) + offset, nframes); - _buffer_data_set = true; - + if (sends_output()) { + _buffer->prepare (); } +} - if (receives_input()) { - _buffer_data_set = false; - } else { - _buffer->silence (nframes, offset); +void +AudioPort::cycle_end (pframes_t nframes) +{ + if (sends_output() && !_buffer->written()) { + if (_buffer->capacity() >= nframes) { + _buffer->silence (nframes); + } } } -AudioBuffer & -AudioPort::get_audio_buffer (nframes_t nframes, nframes_t offset) +void +AudioPort::cycle_split () { - /* caller must hold process lock */ - - if (receives_input () && !_buffer_data_set) { +} - _buffer->set_data ((Sample *) jack_port_get_buffer (_jack_port, nframes) + offset, nframes); - - } - +AudioBuffer& +AudioPort::get_audio_buffer (pframes_t nframes) +{ + /* caller must hold process lock */ + _buffer->set_data ((Sample *) port_engine.get_buffer (_port_handle, _cycle_nframes) + + _global_port_buffer_offset + _port_buffer_offset, nframes); return *_buffer; } -void -AudioPort::cycle_end (nframes_t nframes, nframes_t offset) +Sample* +AudioPort::engine_get_whole_audio_buffer () { - _buffer_data_set = false; + /* caller must hold process lock */ + return (Sample *) port_engine.get_buffer (_port_handle, _cycle_nframes); } + + + +