diff options
author | David Robillard <d@drobilla.net> | 2007-09-29 21:39:53 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-09-29 21:39:53 +0000 |
commit | c0af61632938f161dd2e15dec3c5260a3d5427ca (patch) | |
tree | 950bcfc1bc1fb232f8244c42504b8da3d5b511f5 /src/libs/engine/InputPort.cpp | |
parent | 85923e8b4f9f1601f008a9120d376d944f2478a2 (diff) | |
download | ingen-c0af61632938f161dd2e15dec3c5260a3d5427ca.tar.gz ingen-c0af61632938f161dd2e15dec3c5260a3d5427ca.tar.bz2 ingen-c0af61632938f161dd2e15dec3c5260a3d5427ca.zip |
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
Diffstat (limited to 'src/libs/engine/InputPort.cpp')
-rw-r--r-- | src/libs/engine/InputPort.cpp | 43 |
1 files changed, 33 insertions, 10 deletions
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<Connection*>::iterator c = _connections.begin(); c != _connections.end(); ++c) + (*c)->set_buffer_size(size); + } @@ -64,6 +77,10 @@ InputPort::add_connection(Raul::ListNode<Connection*>* 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<Connection*>::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) { |