From 6488ffb1a3fedb87b41add3a2a78a953755c949a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 3 Jun 2009 02:30:57 +0000 Subject: Clean up and shave some overhead from port value broadcasting. Clean up duplex port code and document weird semantics. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2075 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/DuplexPort.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'src/engine/DuplexPort.cpp') diff --git a/src/engine/DuplexPort.cpp b/src/engine/DuplexPort.cpp index 195d0468..2c4e81b9 100644 --- a/src/engine/DuplexPort.cpp +++ b/src/engine/DuplexPort.cpp @@ -52,30 +52,25 @@ DuplexPort::DuplexPort( } +/** Prepare for the execution of parent patch */ void DuplexPort::pre_process(ProcessContext& context) { - // - /*cerr << endl << "{ duplex pre" << endl; cerr << path() << " duplex pre: fixed buffers: " << fixed_buffers() << endl; cerr << path() << " duplex pre: buffer: " << buffer(0) << endl; cerr << path() << " duplex pre: is_output: " << _is_output << " { " << endl;*/ + // If we're a patch output, prepare buffers for write (so plugins can deliver to them) if (_is_output) { - for (uint32_t i=0; i < _poly; ++i) if (!_buffers->at(i)->is_joined()) _buffers->at(i)->prepare_write(context.start(), context.nframes()); + // Otherwise, we're a patch input, do whatever a normal node's input port does + // (mix down inputs from an outside "patch is a node" perspective) } else { - InputPort::pre_process(context); - - for (uint32_t i=0; i < _poly; ++i) - _buffers->at(i)->prepare_read(context.start(), context.nframes()); - - broadcast(context); } /*if (type() == DataType::EVENT) @@ -84,18 +79,14 @@ DuplexPort::pre_process(ProcessContext& context) << ((EventBuffer*)buffer(i))->event_count() << ", joined: " << _buffers->at(i)->is_joined() << ", is_output: " << _is_output << endl;*/ - //cerr << "} duplex pre " << path() << endl; - - // } +/** Finalize after the execution of parent patch (deliver outputs) */ void DuplexPort::post_process(ProcessContext& context) { - // - /*cerr << endl << "{ duplex post" << endl; cerr << path() << " duplex post: fixed buffers: " << fixed_buffers() << endl; cerr << path() << " duplex post: buffer: " << buffer(0) << endl; @@ -107,14 +98,19 @@ DuplexPort::post_process(ProcessContext& context) << ((EventBuffer*)buffer(i))->event_count() << ", joined: " << _buffers->at(i)->is_joined() << endl;*/ + // If we're a patch output + + if (_is_output) { - InputPort::pre_process(context); // Mix down inputs - broadcast(context); + // Then we've been delivered to as an input (internal perspective) + // Mix down this input so patch output ports (external perspective) are ready + InputPort::pre_process(context); + + if (_broadcast) + broadcast_value(context, false); } //cerr << "} duplex post " << path() << endl; - - // } -- cgit v1.2.1