summaryrefslogtreecommitdiffstats
path: root/src/server/events
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-11-23 14:24:07 -0500
committerDavid Robillard <d@drobilla.net>2016-10-02 12:24:56 -0400
commit938456884934a74a2850c02edc17575021131709 (patch)
treeca3b5296ee9ab3b911499f2fbef8eafdc826bc0c /src/server/events
parenta077166ec6c31ad4aaab738b9dffc139bf3a4d50 (diff)
downloadingen-938456884934a74a2850c02edc17575021131709.tar.gz
ingen-938456884934a74a2850c02edc17575021131709.tar.bz2
ingen-938456884934a74a2850c02edc17575021131709.zip
Add parallelism-aware graph traversal
Diffstat (limited to 'src/server/events')
-rw-r--r--src/server/events/Connect.cpp34
-rw-r--r--src/server/events/Copy.cpp2
-rw-r--r--src/server/events/CreateBlock.cpp4
-rw-r--r--src/server/events/CreateGraph.cpp2
-rw-r--r--src/server/events/Delete.cpp4
-rw-r--r--src/server/events/Delta.cpp7
-rw-r--r--src/server/events/Delta.hpp2
-rw-r--r--src/server/events/Disconnect.cpp2
-rw-r--r--src/server/events/DisconnectAll.cpp7
9 files changed, 42 insertions, 22 deletions
diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp
index 66f726a6..57bfb975 100644
--- a/src/server/events/Connect.cpp
+++ b/src/server/events/Connect.cpp
@@ -27,6 +27,7 @@
#include "OutputPort.hpp"
#include "PortImpl.hpp"
#include "types.hpp"
+#include "internals/BlockDelay.hpp"
namespace Ingen {
namespace Server {
@@ -111,19 +112,31 @@ Connect::pre_process()
provider...
*/
if (tail_block != head_block && tail_block->parent() == head_block->parent()) {
+ // Connection is between blocks inside a graph, compile graph
+
// The tail block is now a dependency (provider) of the head block
head_block->providers().insert(tail_block);
- tail_block->dependants().insert(head_block);
+
+ if (!dynamic_cast<Internals::BlockDelayNode*>(tail_block)) {
+ /* Arcs leaving a delay node are ignored for the purposes of
+ compilation, since the output is from the previous cycle and
+ does not affect execution order. Otherwise, the head block is
+ now a dependant of the head block. */
+ tail_block->dependants().insert(head_block);
+ }
+
+ if (_graph->enabled()) {
+ if (!(_compiled_graph = CompiledGraph::compile(_graph))) {
+ head_block->providers().erase(tail_block);
+ tail_block->dependants().erase(head_block);
+ return Event::pre_process_done(Status::COMPILATION_FAILED);
+ }
+ }
}
_graph->add_arc(_arc);
_head->increment_num_arcs();
- tail_output->inherit_neighbour(_head, _tail_remove, _tail_add);
- _head->inherit_neighbour(tail_output, _head_remove, _head_add);
-
- lock.unlock();
-
if (!_head->is_driver_port()) {
_voices = new Raul::Array<PortImpl::Voice>(_head->poly());
_head->get_buffers(*_engine.buffer_factory(),
@@ -132,9 +145,8 @@ Connect::pre_process()
false);
}
- if (_graph->enabled()) {
- _compiled_graph = _graph->compile();
- }
+ tail_output->inherit_neighbour(_head, _tail_remove, _tail_add);
+ _head->inherit_neighbour(tail_output, _head_remove, _head_add);
return Event::pre_process_done(Status::SUCCESS);
}
@@ -148,7 +160,9 @@ Connect::execute(RunContext& context)
_engine.maid()->dispose(_head->set_voices(context, _voices));
}
_head->connect_buffers();
- _graph->set_compiled_graph(_compiled_graph);
+ if (_compiled_graph) {
+ _graph->set_compiled_graph(_compiled_graph);
+ }
}
}
diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp
index 0ff53843..04c77316 100644
--- a/src/server/events/Copy.cpp
+++ b/src/server/events/Copy.cpp
@@ -126,7 +126,7 @@ Copy::engine_to_engine()
// Compile graph with new block added for insertion in audio thread
if (_parent->enabled()) {
- _compiled_graph = _parent->compile();
+ _compiled_graph = CompiledGraph::compile(_parent);
}
return Event::pre_process_done(Status::SUCCESS);
diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp
index 28afe4b2..d1060fa4 100644
--- a/src/server/events/CreateBlock.cpp
+++ b/src/server/events/CreateBlock.cpp
@@ -138,7 +138,7 @@ CreateBlock::pre_process()
TODO: Since the block is not connected at this point, a full compilation
could be avoided and the block simply appended. */
if (_graph->enabled()) {
- _compiled_graph = _graph->compile();
+ _compiled_graph = CompiledGraph::compile(_graph);
}
_update.put_block(_block);
@@ -149,7 +149,7 @@ CreateBlock::pre_process()
void
CreateBlock::execute(RunContext& context)
{
- if (_block) {
+ if (_status == Status::SUCCESS) {
_graph->set_compiled_graph(_compiled_graph);
_compiled_graph = NULL; // Graph takes ownership
}
diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp
index ca36f258..a2e4e6c4 100644
--- a/src/server/events/CreateGraph.cpp
+++ b/src/server/events/CreateGraph.cpp
@@ -163,7 +163,7 @@ CreateGraph::pre_process()
_parent->add_block(*_graph);
if (_parent->enabled()) {
_graph->enable();
- _compiled_graph = _parent->compile();
+ _compiled_graph = CompiledGraph::compile(_parent);
}
}
diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp
index 5ca70a3a..12c9a3f1 100644
--- a/src/server/events/Delete.cpp
+++ b/src/server/events/Delete.cpp
@@ -94,7 +94,7 @@ Delete::pre_process()
_disconnect_event->pre_process();
if (parent->enabled()) {
- _compiled_graph = parent->compile();
+ _compiled_graph = CompiledGraph::compile(parent);
}
} else if (_port) {
parent->remove_port(*_port);
@@ -102,7 +102,7 @@ Delete::pre_process()
_disconnect_event->pre_process();
if (parent->enabled()) {
- _compiled_graph = parent->compile();
+ _compiled_graph = CompiledGraph::compile(parent);
_ports_array = parent->build_ports_array();
assert(_ports_array->size() == parent->num_ports_non_rt());
}
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index 49ea27ff..8c94fac7 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -374,8 +374,11 @@ Delta::pre_process()
if (value.type() == uris.forge.Bool) {
op = SpecialType::ENABLE;
// FIXME: defer this until all other metadata has been processed
- if (value.get<int32_t>() && !_graph->enabled())
- _compiled_graph = _graph->compile();
+ if (value.get<int32_t>() && !_graph->enabled()) {
+ if (!(_compiled_graph = CompiledGraph::compile(_graph))) {
+ _status = Status::COMPILATION_FAILED;
+ }
+ }
} else {
_status = Status::BAD_VALUE_TYPE;
}
diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp
index 8b00fd3a..24330199 100644
--- a/src/server/events/Delta.hpp
+++ b/src/server/events/Delta.hpp
@@ -38,7 +38,7 @@ namespace Server {
class CompiledGraph;
class Engine;
class GraphImpl;
-class ProcessContext;
+class RunContext;
namespace Events {
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index 8d47ac5a..9d1b18a3 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -167,7 +167,7 @@ Disconnect::pre_process()
dynamic_cast<InputPort*>(head));
if (_graph->enabled())
- _compiled_graph = _graph->compile();
+ _compiled_graph = CompiledGraph::compile(_graph);
return Event::pre_process_done(Status::SUCCESS);
}
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index 380aced5..e4866d30 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -136,8 +136,11 @@ DisconnectAll::pre_process()
dynamic_cast<InputPort*>(a->head())));
}
- if (!_deleting && _parent->enabled())
- _compiled_graph = _parent->compile();
+ if (!_deleting && _parent->enabled()) {
+ if (!(_compiled_graph = CompiledGraph::compile(_parent))) {
+ return Event::pre_process_done(Status::COMPILATION_FAILED);
+ }
+ }
return Event::pre_process_done(Status::SUCCESS);
}