From c0af61632938f161dd2e15dec3c5260a3d5427ca Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 29 Sep 2007 21:39:53 +0000 Subject: Work towards port monitoring and better (higher utilization) parallel execution. git-svn-id: http://svn.drobilla.net/lad/ingen@784 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/InputPort.cpp | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) (limited to 'src/libs/engine/InputPort.cpp') diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp index 1adb53a0..4f2147c4 100644 --- a/src/libs/engine/InputPort.cpp +++ b/src/libs/engine/InputPort.cpp @@ -23,17 +23,30 @@ #include "Connection.hpp" #include "OutputPort.hpp" #include "Node.hpp" +#include "ProcessContext.hpp" #include "util.hpp" -using std::cerr; using std::cout; using std::endl; - +using namespace std; namespace Ingen { InputPort::InputPort(Node* parent, const string& name, uint32_t index, uint32_t poly, DataType type, size_t buffer_size) -: Port(parent, name, index, poly, type, buffer_size) + : Port(parent, name, index, poly, type, buffer_size) + , _last_reported_value(0.0f) // default? +{ +} + + +void +InputPort::set_buffer_size(size_t size) { + Port::set_buffer_size(size); + assert(_buffer_size = size); + + for (Raul::List::iterator c = _connections.begin(); c != _connections.end(); ++c) + (*c)->set_buffer_size(size); + } @@ -64,6 +77,10 @@ InputPort::add_connection(Raul::ListNode* const c) } Port::connect_buffers(); } + + // Automatically monitor connected control inputs + if (_type == DataType::FLOAT && _buffer_size == 1) + _monitor = true; } @@ -104,6 +121,10 @@ InputPort::remove_connection(const OutputPort* src_port) if (modify_buffers) Port::connect_buffers(); + + // Turn off monitoring if we're not connected any more (FIXME: not quite right..) + if (_type == DataType::FLOAT && _buffer_size == 1 && _connections.size() == 0) + _monitor = false; return connection; } @@ -195,16 +216,18 @@ InputPort::pre_process(SampleCount nframes, FrameTime start, FrameTime end) void -InputPort::set_buffer_size(size_t size) +InputPort::process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end) { - Port::set_buffer_size(size); - assert(_buffer_size = size); - - for (Raul::List::iterator c = _connections.begin(); c != _connections.end(); ++c) - (*c)->set_buffer_size(size); - + if (_monitor && _type == DataType::FLOAT && _buffer_size == 1) { + const Sample value = ((AudioBuffer*)(*_buffers)[0])->value_at(0); + if (value != _last_reported_value) { + context.event_sink().control_change(this, ((AudioBuffer*)(*_buffers)[0])->value_at(0)); + _last_reported_value = value; + } + } } + void InputPort::post_process(SampleCount nframes, FrameTime start, FrameTime end) { -- cgit v1.2.1