From 050def448a88bd6eafb8453d5cf60f761c06b46b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 20 Apr 2011 01:15:09 +0000 Subject: Simplify disconnect code. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3177 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/events/Disconnect.cpp | 26 ++++++++++---------------- src/engine/events/Disconnect.hpp | 5 ++--- 2 files changed, 12 insertions(+), 19 deletions(-) (limited to 'src/engine/events') diff --git a/src/engine/events/Disconnect.cpp b/src/engine/events/Disconnect.cpp index 9de5d0fd..33a65ed8 100644 --- a/src/engine/events/Disconnect.cpp +++ b/src/engine/events/Disconnect.cpp @@ -55,7 +55,6 @@ Disconnect::Disconnect( , _buffers(NULL) , _internal(false) , _reconnect_dst_port(true) - , _clear_dst_port(false) { } @@ -76,7 +75,6 @@ Disconnect::Disconnect( , _buffers(NULL) , _internal(true) , _reconnect_dst_port(reconnect_dst_port) - , _clear_dst_port(false) { } @@ -161,7 +159,16 @@ Disconnect::pre_process() _buffers = new Raul::Array(_dst_input_port->poly()); _dst_input_port->get_buffers(*_engine.buffer_factory(), _buffers, _dst_input_port->poly()); - _clear_dst_port = true; + + const bool is_control = _dst_input_port->is_a(PortType::CONTROL); + const float value = is_control ? _dst_input_port->value().get_float() : 0; + for (uint32_t i = 0; i < _buffers->size(); ++i) { + if (is_control) { + PtrCast(_buffers->at(i))->set_value(value, 0, 0); + } else { + _buffers->at(i)->clear(); + } + } } if (!_internal && _patch->enabled()) @@ -184,19 +191,6 @@ Disconnect::execute(ProcessContext& context) else _dst_input_port->setup_buffers(*_engine.buffer_factory(), _dst_input_port->poly()); _dst_input_port->connect_buffers(); - if (_clear_dst_port) { - for (uint32_t v = 0; v < _dst_input_port->poly(); ++v) { - if (_dst_input_port->is_a(PortType::CONTROL)) { - IntrusivePtr abuf(PtrCast( - _dst_input_port->buffer(v))); - if (abuf) - abuf->set_value(_dst_input_port->value().get_float(), - context.start(), context.start()); - } else { - _dst_input_port->buffer(v)->clear(); - } - } - } } else { _dst_input_port->recycle_buffers(); } diff --git a/src/engine/events/Disconnect.hpp b/src/engine/events/Disconnect.hpp index f7e965e0..9c741293 100644 --- a/src/engine/events/Disconnect.hpp +++ b/src/engine/events/Disconnect.hpp @@ -91,9 +91,8 @@ private: Raul::Array* _buffers; - bool _internal; - bool _reconnect_dst_port; - bool _clear_dst_port; + bool _internal; + bool _reconnect_dst_port; }; } // namespace Events -- cgit v1.2.1