summaryrefslogtreecommitdiffstats
path: root/src/libs/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-08-10 21:44:30 +0000
committerDavid Robillard <d@drobilla.net>2007-08-10 21:44:30 +0000
commit153fe99497a7ccc91aac6082b29748a66792d374 (patch)
tree7b0026fb763a5ccf6c3dd435f9d628b4d6cda12f /src/libs/engine
parentc2ea92fd6a6a24520d7f8047cc9c0d8905bc3351 (diff)
downloadingen-153fe99497a7ccc91aac6082b29748a66792d374.tar.gz
ingen-153fe99497a7ccc91aac6082b29748a66792d374.tar.bz2
ingen-153fe99497a7ccc91aac6082b29748a66792d374.zip
Fix loading control values from deprecated Om patches.
Eliminate parallel processing overhead if running single threaded. git-svn-id: http://svn.drobilla.net/lad/ingen@693 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine')
-rw-r--r--src/libs/engine/CompiledPatch.hpp4
-rw-r--r--src/libs/engine/Patch.cpp44
-rw-r--r--src/libs/engine/Patch.hpp2
3 files changed, 35 insertions, 15 deletions
diff --git a/src/libs/engine/CompiledPatch.hpp b/src/libs/engine/CompiledPatch.hpp
index 9ab252b3..f5de52e1 100644
--- a/src/libs/engine/CompiledPatch.hpp
+++ b/src/libs/engine/CompiledPatch.hpp
@@ -31,9 +31,7 @@ using namespace std;
namespace Ingen {
-/** A node, and it's providers/dependants.
- *
- * This is all the information required to execute a node in a process thread.
+/** All information required about a node to execute it in an audio thread.
*/
struct CompiledNode {
CompiledNode(Node* n, size_t np, List<Node*>* d)
diff --git a/src/libs/engine/Patch.cpp b/src/libs/engine/Patch.cpp
index ad1459e8..8e0b8862 100644
--- a/src/libs/engine/Patch.cpp
+++ b/src/libs/engine/Patch.cpp
@@ -118,8 +118,6 @@ Patch::process(SampleCount nframes, FrameTime start, FrameTime end)
if (_compiled_patch == NULL || _compiled_patch->size() == 0 || !_process)
return;
- CompiledPatch* const cp = _compiled_patch;
-
/* Prepare input ports */
// This breaks MIDI input, somehow (?)
@@ -129,10 +127,30 @@ Patch::process(SampleCount nframes, FrameTime start, FrameTime end)
(*i)->pre_process(nframes, start, end);
- /* Start p-1 slaves */
+ if (_engine.process_slaves().size() > 0)
+ process_parallel(nframes, start, end);
+ else
+ process_single(nframes, start, end);
+
+
+ /* Write output ports */
+
+ for (Raul::List<Port*>::iterator i = _input_ports.begin(); i != _input_ports.end(); ++i)
+ (*i)->post_process(nframes, start, end);
+ for (Raul::List<Port*>::iterator i = _output_ports.begin(); i != _output_ports.end(); ++i)
+ (*i)->post_process(nframes, start, end);
+}
+
+void
+Patch::process_parallel(SampleCount nframes, FrameTime start, FrameTime end)
+{
size_t n_slaves = _engine.process_slaves().size();
+ CompiledPatch* const cp = _compiled_patch;
+
+ /* Start p-1 slaves */
+
if (n_slaves >= cp->size())
n_slaves = cp->size()-1;
@@ -186,6 +204,8 @@ Patch::process(SampleCount nframes, FrameTime start, FrameTime end)
index = (index + 1) % cp->size();
}
+
+ //cout << "Main Thread ran \t" << run_count << " nodes this cycle." << endl;
/* Tell slaves we're done in case we beat them, and pray they're
* really done by the start of next cycle.
@@ -193,18 +213,19 @@ Patch::process(SampleCount nframes, FrameTime start, FrameTime end)
*/
for (size_t i=0; i < n_slaves; ++i)
_engine.process_slaves()[i]->finish();
-
- //cout << "Main Thread ran \t" << run_count << " nodes this cycle." << endl;
+}
- /* Write output ports */
+
+void
+Patch::process_single(SampleCount nframes, FrameTime start, FrameTime end)
+{
+ CompiledPatch* const cp = _compiled_patch;
- for (Raul::List<Port*>::iterator i = _input_ports.begin(); i != _input_ports.end(); ++i)
- (*i)->post_process(nframes, start, end);
- for (Raul::List<Port*>::iterator i = _output_ports.begin(); i != _output_ports.end(); ++i)
- (*i)->post_process(nframes, start, end);
+ for (size_t i=0; i < cp->size(); ++i)
+ (*cp)[i].node()->process(nframes, start, end);
}
-
+
void
Patch::set_buffer_size(size_t size)
{
@@ -368,7 +389,6 @@ Patch::compile() const
CompiledPatch* const compiled_patch = new CompiledPatch();//_nodes.size());
- // FIXME: tweak algorithm so it just ends up like this and save the cost of iteration?
for (Raul::List<Node*>::const_iterator i = _nodes.begin(); i != _nodes.end(); ++i)
(*i)->traversed(false);
diff --git a/src/libs/engine/Patch.hpp b/src/libs/engine/Patch.hpp
index 7780c60b..8d17ee7c 100644
--- a/src/libs/engine/Patch.hpp
+++ b/src/libs/engine/Patch.hpp
@@ -97,6 +97,8 @@ public:
private:
inline void compile_recursive(Node* n, CompiledPatch* output) const;
+ void process_parallel(SampleCount nframes, FrameTime start, FrameTime end);
+ void process_single(SampleCount nframes, FrameTime start, FrameTime end);
Engine& _engine;
uint32_t _internal_poly;