From b2d51e16571190becea1476080cff1b0a258a4f6 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 13 Oct 2008 01:59:53 +0000 Subject: Fix various problems with subpatch connecting/disconnecting (and probably introduce new ones). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1668 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/ConnectionImpl.cpp | 27 ++++++++++++++++++++------- src/engine/ConnectionImpl.hpp | 7 ++++--- src/engine/DuplexPort.cpp | 4 ++++ src/engine/InputPort.hpp | 2 +- src/engine/events/ConnectionEvent.cpp | 21 ++++++++++----------- src/engine/events/DisconnectionEvent.cpp | 20 ++++++++++---------- 6 files changed, 49 insertions(+), 32 deletions(-) diff --git a/src/engine/ConnectionImpl.cpp b/src/engine/ConnectionImpl.cpp index 64d51edf..53cef102 100644 --- a/src/engine/ConnectionImpl.cpp +++ b/src/engine/ConnectionImpl.cpp @@ -72,7 +72,9 @@ ConnectionImpl::~ConnectionImpl() void ConnectionImpl::set_mode() { - if (must_mix()) + if (must_copy()) + _mode = COPY; + else if (must_mix()) _mode = MIX; else if (must_extend()) _mode = EXTEND; @@ -97,13 +99,18 @@ ConnectionImpl::set_buffer_size(size_t size) bool -ConnectionImpl::must_mix() const +ConnectionImpl::must_copy() const { - bool mix = ( /*(_src_port->poly() != _dst_port->poly()) - ||*/ (_src_port->polyphonic() && !_dst_port->polyphonic()) - || (_src_port->parent()->polyphonic() && !_dst_port->parent()->polyphonic()) ); + return (_dst_port->fixed_buffers() && (_src_port->poly() == _dst_port->poly())); +} - return mix; + +bool +ConnectionImpl::must_mix() const +{ + return ( (_src_port->polyphonic() && !_dst_port->polyphonic()) + || (_src_port->parent()->polyphonic() && !_dst_port->parent()->polyphonic()) + || (_dst_port->fixed_buffers()) ); } @@ -164,7 +171,13 @@ ConnectionImpl::process(ProcessContext& context) << " -> " << dst_port()->path() << " * " << dst_port()->poly() << "\t\tmode: " << (int)_mode << endl;*/ - if (_mode == MIX) { + if (_mode == COPY) { + assert(src_port()->poly() == dst_port()->poly()); + const size_t copy_size = std::min(src_port()->buffer_size(), dst_port()->buffer_size()); + for (uint32_t i=0; i < src_port()->poly(); ++i) { + dst_port()->buffer(i)->copy(src_port()->buffer(i), 0, copy_size); + } + } else if (_mode == MIX) { assert(type() == DataType::AUDIO || type() == DataType::CONTROL); const AudioBuffer* const src_buffer = (AudioBuffer*)src_port()->buffer(0); diff --git a/src/engine/ConnectionImpl.hpp b/src/engine/ConnectionImpl.hpp index b3d7cf4b..a5a61c85 100644 --- a/src/engine/ConnectionImpl.hpp +++ b/src/engine/ConnectionImpl.hpp @@ -65,7 +65,7 @@ public: * buffer, and will return accordingly (ie the same buffer for every voice * in a mono->poly connection). */ - inline Buffer* buffer(size_t voice) const; + inline Buffer* buffer(uint32_t voice) const; inline size_t buffer_size() const { return _buffer_size; } @@ -73,6 +73,7 @@ public: void prepare_poly(uint32_t poly); void apply_poly(Raul::Maid& maid, uint32_t poly); + bool must_copy() const; bool must_mix() const; bool must_extend() const; @@ -82,7 +83,7 @@ public: DataType type() const { return _src_port->type(); } protected: - enum { DIRECT, MIX, EXTEND } _mode; + enum { DIRECT, MIX, COPY, EXTEND } _mode; void set_mode(); PortImpl* const _src_port; @@ -94,7 +95,7 @@ protected: inline Buffer* -ConnectionImpl::buffer(size_t voice) const +ConnectionImpl::buffer(uint32_t voice) const { if (_mode == MIX) { return _local_buffer; diff --git a/src/engine/DuplexPort.cpp b/src/engine/DuplexPort.cpp index 31bfbe09..5f5b8606 100644 --- a/src/engine/DuplexPort.cpp +++ b/src/engine/DuplexPort.cpp @@ -38,6 +38,7 @@ DuplexPort::DuplexPort(NodeImpl* parent, const string& name, uint32_t index, uin , _is_output(is_output) { assert(PortImpl::_parent == parent); + _fixed_buffers = true; } @@ -57,6 +58,9 @@ DuplexPort::pre_process(ProcessContext& context) << ((EventBuffer*)buffer(i))->event_count() << ", joined: " << _buffers->at(i)->is_joined() << endl;*/ + for (Connections::iterator c = _connections.begin(); c != _connections.end(); ++c) + (*c)->process(context); + if (_is_output) { for (uint32_t i=0; i < _poly; ++i) diff --git a/src/engine/InputPort.hpp b/src/engine/InputPort.hpp index abc63a91..23732fa9 100644 --- a/src/engine/InputPort.hpp +++ b/src/engine/InputPort.hpp @@ -77,7 +77,7 @@ public: virtual void set_buffer_size(size_t size); -private: +protected: bool can_direct() const; Connections _connections; diff --git a/src/engine/events/ConnectionEvent.cpp b/src/engine/events/ConnectionEvent.cpp index 772679fa..22bda824 100644 --- a/src/engine/events/ConnectionEvent.cpp +++ b/src/engine/events/ConnectionEvent.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - #include #include #include @@ -37,16 +36,16 @@ namespace Ingen { ConnectionEvent::ConnectionEvent(Engine& engine, SharedPtr responder, SampleCount timestamp, const string& src_port_path, const string& dst_port_path) -: QueuedEvent(engine, responder, timestamp), - _src_port_path(src_port_path), - _dst_port_path(dst_port_path), - _patch(NULL), - _src_port(NULL), - _dst_port(NULL), - _compiled_patch(NULL), - _patch_listnode(NULL), - _port_listnode(NULL), - _error(NO_ERROR) + : QueuedEvent(engine, responder, timestamp) + , _src_port_path(src_port_path) + , _dst_port_path(dst_port_path) + , _patch(NULL) + , _src_port(NULL) + , _dst_port(NULL) + , _compiled_patch(NULL) + , _patch_listnode(NULL) + , _port_listnode(NULL) + , _error(NO_ERROR) { } diff --git a/src/engine/events/DisconnectionEvent.cpp b/src/engine/events/DisconnectionEvent.cpp index d98718e9..fa045639 100644 --- a/src/engine/events/DisconnectionEvent.cpp +++ b/src/engine/events/DisconnectionEvent.cpp @@ -37,16 +37,16 @@ namespace Ingen { DisconnectionEvent::DisconnectionEvent(Engine& engine, SharedPtr responder, SampleCount timestamp, const string& src_port_path, const string& dst_port_path) -: QueuedEvent(engine, responder, timestamp), - _src_port_path(src_port_path), - _dst_port_path(dst_port_path), - _patch(NULL), - _src_port(NULL), - _dst_port(NULL), - _lookup(true), - _patch_connection(NULL), - _compiled_patch(NULL), - _error(NO_ERROR) + : QueuedEvent(engine, responder, timestamp) + , _src_port_path(src_port_path) + , _dst_port_path(dst_port_path) + , _patch(NULL) + , _src_port(NULL) + , _dst_port(NULL) + , _lookup(true) + , _patch_connection(NULL) + , _compiled_patch(NULL) + , _error(NO_ERROR) { } -- cgit v1.2.1