From 5d87212114e2df68a086eeb55829a70bed0940d3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 25 Feb 2010 01:20:13 +0000 Subject: Fix (remove) use of PatchImpl::_connections in the audio thread. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2490 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/CompiledPatch.hpp | 22 +++++++++++----------- src/engine/PatchImpl.cpp | 18 ++++++++++++------ 2 files changed, 23 insertions(+), 17 deletions(-) (limited to 'src/engine') diff --git a/src/engine/CompiledPatch.hpp b/src/engine/CompiledPatch.hpp index 7cb713e2..f2c99562 100644 --- a/src/engine/CompiledPatch.hpp +++ b/src/engine/CompiledPatch.hpp @@ -25,6 +25,7 @@ namespace Ingen { +class ConnectionImpl; /** All information required about a node to execute it in an audio thread. */ @@ -51,23 +52,22 @@ private: }; -/** A patch and a set of connections, "compiled" into a flat structure with - * the correct order so the audio thread(s) can execute it without - * threading problems (since the preprocessor thread fiddles with other - * things). - * - * Currently objects still have some 'heavyweight' connection state, but - * eventually this should be the only place a particular set of connections - * in a patch is stored, so various "connection presets" can be switched - * in a realtime safe way. +/** A patch ``compiled'' into a flat structure with the correct order so + * the audio thread(s) can execute it without threading problems (since + * the preprocessor thread modifies the graph). * * The nodes contained here are sorted in the order they must be executed. * The parallel processing algorithm guarantees no node will be executed - * before it's providers, using this order as well as semaphores. + * before its providers, using this order as well as semaphores. */ struct CompiledPatch : public std::vector , public Raul::Deletable - , public boost::noncopyable { + , public boost::noncopyable +{ + typedef std::vector QueuedConnections; + + /** All (audio context => other context) connections */ + std::vector queued_connections; }; diff --git a/src/engine/PatchImpl.cpp b/src/engine/PatchImpl.cpp index 6b31532a..7ee82803 100644 --- a/src/engine/PatchImpl.cpp +++ b/src/engine/PatchImpl.cpp @@ -172,12 +172,9 @@ PatchImpl::process(ProcessContext& context) } // Queue any cross-context connections - for (Connections::iterator i = _connections.begin(); i != _connections.end(); ++i) { - ConnectionImpl* const c = (ConnectionImpl*)i->get(); - if (c->src_port()->context() == Context::AUDIO && - c->dst_port()->context() == Context::MESSAGE) { - c->queue(context); - } + for (CompiledPatch::QueuedConnections::iterator i = _compiled_patch->queued_connections.begin(); + i != _compiled_patch->queued_connections.end(); ++i) { + (*i)->queue(context); } NodeImpl::post_process(context); @@ -480,6 +477,15 @@ PatchImpl::compile() const compile_recursive(node, compiled_patch); } + // Add any queued connections that must be run after a cycle + for (Connections::const_iterator i = _connections.begin(); i != _connections.end(); ++i) { + ConnectionImpl* const c = (ConnectionImpl*)i->get(); + if (c->src_port()->context() == Context::AUDIO && + c->dst_port()->context() == Context::MESSAGE) { + compiled_patch->queued_connections.push_back(c); + } + } + assert(compiled_patch->size() == _nodes.size()); return compiled_patch; -- cgit v1.2.1