summaryrefslogtreecommitdiffstats
path: root/src/engine/events/Disconnect.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-04-20 01:15:09 +0000
committerDavid Robillard <d@drobilla.net>2011-04-20 01:15:09 +0000
commit050def448a88bd6eafb8453d5cf60f761c06b46b (patch)
tree4b4c0bf5f6ca9c22c6f3556351126b3b05a26e1d /src/engine/events/Disconnect.cpp
parent9e15d7859def446fb3f66f15d3ca1cd444bbf03e (diff)
downloadingen-050def448a88bd6eafb8453d5cf60f761c06b46b.tar.gz
ingen-050def448a88bd6eafb8453d5cf60f761c06b46b.tar.bz2
ingen-050def448a88bd6eafb8453d5cf60f761c06b46b.zip
Simplify disconnect code.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3177 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/events/Disconnect.cpp')
-rw-r--r--src/engine/events/Disconnect.cpp26
1 files changed, 10 insertions, 16 deletions
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<BufferFactory::Ref>(_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<AudioBuffer>(_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<AudioBuffer> abuf(PtrCast<AudioBuffer>(
- _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();
}