summaryrefslogtreecommitdiff
path: root/libs/ardour/audio_port.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-02-11 00:58:24 +0000
committerCarl Hetherington <carl@carlh.net>2009-02-11 00:58:24 +0000
commitd469cc3e3a536fceedbfc41e52ad3d7d178f7b0d (patch)
tree5cee0af05edc00f5b19116727b1aebfd3bc52719 /libs/ardour/audio_port.cc
parentfe4e98a72987f197239a025413bfddb4c29b8ba8 (diff)
Remove internal ports.
git-svn-id: svn://localhost/ardour2/branches/3.0@4525 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/audio_port.cc')
-rw-r--r--libs/ardour/audio_port.cc129
1 files changed, 15 insertions, 114 deletions
diff --git a/libs/ardour/audio_port.cc b/libs/ardour/audio_port.cc
index 0e48c2a699..558ae72a97 100644
--- a/libs/ardour/audio_port.cc
+++ b/libs/ardour/audio_port.cc
@@ -25,30 +25,15 @@
using namespace ARDOUR;
using namespace std;
-AudioPort::AudioPort (const std::string& name, Flags flags, bool ext, nframes_t capacity)
- : Port (name, DataType::AUDIO, flags, ext)
- , _has_been_mixed_down (false)
- , _buffer (0)
- , _internal_buffer (false)
+AudioPort::AudioPort (const std::string& name, Flags flags)
+ : Port (name, DataType::AUDIO, flags)
+ , _buffer_data_set (false)
+ , _buffer (new AudioBuffer (0))
{
assert (name.find_first_of (':') == string::npos);
-
- if (external ()) {
-
- /* external ports use the external port buffer */
- _buffer = new AudioBuffer (0);
-
- } else {
-
- /* internal ports need their own buffers */
- _buffer = new AudioBuffer (capacity);
- }
-
- check_buffer_status ();
-
}
-AudioPort::~AudioPort()
+AudioPort::~AudioPort ()
{
delete _buffer;
}
@@ -58,20 +43,22 @@ AudioPort::cycle_start (nframes_t nframes, nframes_t offset)
{
/* caller must hold process lock */
- /* For external (JACK) ports, get_buffer() must only be run
- on outputs here in cycle_start().
+ /* get_buffer() must only be run on outputs here in cycle_start().
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 (!receives_input() && external ()) {
+
+ if (sends_output() && !_buffer_data_set) {
+
_buffer->set_data ((Sample *) jack_port_get_buffer (_jack_port, nframes) + offset, nframes);
+ _buffer_data_set = true;
+
}
if (receives_input()) {
- _has_been_mixed_down = false;
+ _buffer_data_set = false;
} else {
_buffer->silence (nframes, offset);
}
@@ -82,19 +69,10 @@ AudioPort::get_audio_buffer (nframes_t nframes, nframes_t offset)
{
/* caller must hold process lock */
- if (receives_input () && !_has_been_mixed_down) {
+ if (receives_input () && !_buffer_data_set) {
- /* external ports use JACK's memory unless otherwise noted */
+ _buffer->set_data ((Sample *) jack_port_get_buffer (_jack_port, nframes) + offset, nframes);
- if (external()) {
- if (!using_internal_data()) {
- _buffer->set_data ((Sample *) jack_port_get_buffer (_jack_port, nframes) + offset, nframes);
- } else {
- _buffer->silence (nframes, offset);
- }
- }
-
- mixdown (nframes, offset, !external ());
}
return *_buffer;
@@ -103,82 +81,5 @@ AudioPort::get_audio_buffer (nframes_t nframes, nframes_t offset)
void
AudioPort::cycle_end (nframes_t nframes, nframes_t offset)
{
- _has_been_mixed_down = false;
-}
-
-void
-AudioPort::mixdown (nframes_t cnt, nframes_t offset, bool first_overwrite)
-{
- /* note: this is only called for input ports */
-
- if (_connections.empty()) {
-
- /* no internal mixing to do, so for internal ports
- just make sure the buffer is silent.
- */
-
- if (!external()) {
- _buffer->silence (cnt, offset);
- }
-
- } else {
-
- set<Port*>::const_iterator p = _connections.begin();
-
- /* mix in internally-connected ports. if this is an external port
- then it may already have data present from JACK. in that case, we
- do not want to overwrite that data, so we skip the initial ::read_from()
- call and do everything with accumulate_from()
- */
-
- if (!external()) {
- _buffer->read_from (dynamic_cast<AudioPort*>(*p)->get_audio_buffer (cnt, offset), cnt, offset);
- ++p;
-
- }
-
- for (; p != _connections.end (); ++p) {
- _buffer->accumulate_from (dynamic_cast<AudioPort*>(*p)->get_audio_buffer (cnt, offset), cnt, offset);
-
- }
- }
-
- /* XXX horrible heuristic designed to check that we worked the whole buffer.
- Needs fixing but its a hard problem.
- */
-
- if (cnt && offset == 0) {
- _has_been_mixed_down = true;
- }
-}
-
-void
-AudioPort::reset ()
-{
- Port::reset ();
-
- if (_buffer->capacity () != 0) {
- _buffer->resize (_engine->frames_per_cycle ());
- _buffer->clear ();
- }
-}
-
-bool
-AudioPort::using_internal_data () const
-{
- return _internal_buffer;
-}
-
-void
-AudioPort::use_internal_data ()
-{
- _buffer->replace_data (_buffer->capacity());
- _internal_buffer = true;
-}
-
-void
-AudioPort::use_external_data ()
-{
- _internal_buffer = false;
- _buffer->drop_data ();
+ _buffer_data_set = false;
}