summaryrefslogtreecommitdiffstats
path: root/src/server/events
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-10-24 19:27:39 +0000
committerDavid Robillard <d@drobilla.net>2015-10-24 19:27:39 +0000
commit732bfb33105b4a534bc17caae9a50a1ccfcd7570 (patch)
treebad9715a99f11d17342adaef372361c3697beee9 /src/server/events
parentade7143eb2af64fd6743a64ebf1786dd5bbe1092 (diff)
downloadingen-732bfb33105b4a534bc17caae9a50a1ccfcd7570.tar.gz
ingen-732bfb33105b4a534bc17caae9a50a1ccfcd7570.tar.bz2
ingen-732bfb33105b4a534bc17caae9a50a1ccfcd7570.zip
Zero-copy to/from driver ports where possible
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5778 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/events')
-rw-r--r--src/server/events/Connect.cpp16
-rw-r--r--src/server/events/CreatePort.cpp18
-rw-r--r--src/server/events/Disconnect.cpp35
-rw-r--r--src/server/events/SetPortValue.cpp2
4 files changed, 44 insertions, 27 deletions
diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp
index 1f22e6f2..5eff8854 100644
--- a/src/server/events/Connect.cpp
+++ b/src/server/events/Connect.cpp
@@ -123,11 +123,13 @@ Connect::pre_process()
lock.unlock();
- _voices = new Raul::Array<PortImpl::Voice>(_head->poly());
- _head->get_buffers(*_engine.buffer_factory(),
- _voices,
- _head->poly(),
- false);
+ if (!_head->is_driver_port()) {
+ _voices = new Raul::Array<PortImpl::Voice>(_head->poly());
+ _head->get_buffers(*_engine.buffer_factory(),
+ _voices,
+ _head->poly(),
+ false);
+ }
if (_graph->enabled()) {
_compiled_graph = _graph->compile();
@@ -141,7 +143,9 @@ Connect::execute(ProcessContext& context)
{
if (_status == Status::SUCCESS) {
_head->add_arc(context, _arc.get());
- _engine.maid()->dispose(_head->set_voices(context, _voices));
+ if (!_head->is_driver_port()) {
+ _engine.maid()->dispose(_head->set_voices(context, _voices));
+ }
_head->connect_buffers();
_graph->set_compiled_graph(_compiled_graph);
}
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index 173b8a73..0b58ee89 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -125,12 +125,19 @@ CreatePort::pre_process()
poly_i->second.type() == uris.forge.Bool &&
poly_i->second.get<int32_t>());
- if (!(_graph_port = _graph->create_port(
- bufs, Raul::Symbol(_path.symbol()),
- _port_type, _buf_type, buf_size, _is_output, polyphonic))) {
- return Event::pre_process_done(Status::CREATION_FAILED, _path);
+ // Create 0 value if the port requires one
+ Atom value;
+ if (_port_type == PortType::CONTROL || _port_type == PortType::CV) {
+ value = bufs.forge().make(0.0f);
}
+ // Create port
+ _graph_port = new DuplexPort(bufs, _graph, Raul::Symbol(_path.symbol()),
+ _graph->num_ports_non_rt(),
+ polyphonic,
+ _port_type, _buf_type, buf_size,
+ value, _is_output);
+
_graph_port->properties().insert(_properties.begin(), _properties.end());
_engine.store()->add(_graph_port);
@@ -141,8 +148,7 @@ CreatePort::pre_process()
}
if (!_graph->parent()) {
- _engine_port = _engine.driver()->create_port(
- dynamic_cast<DuplexPort*>(_graph_port));
+ _engine_port = _engine.driver()->create_port(_graph_port);
}
_ports_array = new Raul::Array<PortImpl*>(old_n_ports + 1, NULL);
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index 87c192b4..66aee38e 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -91,21 +91,25 @@ Disconnect::Impl::Impl(Engine& e,
_dst_input_port->decrement_num_arcs();
if (_dst_input_port->num_arcs() == 0) {
- _voices = new Raul::Array<PortImpl::Voice>(_dst_input_port->poly());
- _dst_input_port->get_buffers(*_engine.buffer_factory(),
- _voices,
- _dst_input_port->poly(),
- false);
-
- const bool is_control = _dst_input_port->is_a(PortType::CONTROL) ||
- _dst_input_port->is_a(PortType::CV);
- const float value = is_control ? _dst_input_port->value().get<float>() : 0;
- for (uint32_t i = 0; i < _voices->size(); ++i) {
- if (is_control) {
- Buffer* buf = _voices->at(i).buffer.get();
- buf->set_block(value, 0, buf->nframes());
+ if (!_dst_input_port->is_driver_port()) {
+ _voices = new Raul::Array<PortImpl::Voice>(_dst_input_port->poly());
+ _dst_input_port->get_buffers(*_engine.buffer_factory(),
+ _voices,
+ _dst_input_port->poly(),
+ false);
+
+ if (_dst_input_port->is_a(PortType::CONTROL) ||
+ _dst_input_port->is_a(PortType::CV)) {
+ // Reset buffer to control value
+ const float value = _dst_input_port->value().get<float>();
+ for (uint32_t i = 0; i < _voices->size(); ++i) {
+ Buffer* buf = _voices->at(i).buffer.get();
+ buf->set_block(value, 0, buf->nframes());
+ }
} else {
- _voices->at(i).buffer->clear();
+ for (uint32_t i = 0; i < _voices->size(); ++i) {
+ _voices->at(i).buffer->clear();
+ }
}
}
}
@@ -177,8 +181,11 @@ Disconnect::Impl::execute(ProcessContext& context, bool set_dst_buffers)
{
ArcImpl* const port_arc =
_dst_input_port->remove_arc(context, _src_output_port);
+
if (!port_arc) {
return false;
+ } else if (_dst_input_port->is_driver_port()) {
+ return true;
}
if (set_dst_buffers) {
diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp
index e069e474..fd10c94f 100644
--- a/src/server/events/SetPortValue.cpp
+++ b/src/server/events/SetPortValue.cpp
@@ -107,7 +107,7 @@ SetPortValue::apply(Context& context)
_status = Status::NO_SPACE;
}
} else if (buf->type() == uris.atom_URID) {
- ((LV2_Atom_URID*)buf->atom())->body = _value.get<int32_t>();
+ buf->get<LV2_Atom_URID>()->body = _value.get<int32_t>();
} else {
_status = Status::BAD_VALUE_TYPE;
}