From 69c5e7fe16b7d9d08db81a6d5e2762f0be3b081f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 6 Jan 2007 19:39:56 +0000 Subject: Added ability to get Raul Thread for current calling context. Strong threading assertions. Flowcanvas port removal fixes. Patch port destruction. Code cleanups, bug fixes. git-svn-id: http://svn.drobilla.net/lad/ingen@234 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/Patch.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'src/libs/engine/Patch.cpp') diff --git a/src/libs/engine/Patch.cpp b/src/libs/engine/Patch.cpp index d1d3e84a..549c9e0f 100644 --- a/src/libs/engine/Patch.cpp +++ b/src/libs/engine/Patch.cpp @@ -17,6 +17,7 @@ #include #include #include +#include "ThreadManager.h" #include "Node.h" #include "Patch.h" #include "Plugin.h" @@ -244,6 +245,19 @@ Patch::remove_bridge_node(const InternalNode* node) } #endif + +size_t +Patch::num_ports() const +{ + ThreadID context = ThreadManager::current_thread_id(); + + if (context == THREAD_PROCESS) + return NodeBase::num_ports(); + else + return _input_ports.size() + _output_ports.size(); +} + + /** Create a port. Not realtime safe. */ Port* @@ -266,12 +280,18 @@ Patch::create_port(const string& name, DataType type, size_t buffer_size, bool i } -/** Remove a port. - * Realtime safe. Preprocessing thread. +/** Remove port from ports list used in pre-processing thread. + * + * Port is not removed from ports array for process thread (which could be + * simultaneously running). + * + * Realtime safe. Preprocessing thread only. */ ListNode* Patch::remove_port(const string& name) { + assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS); + bool found = false; ListNode* ret = NULL; for (List::iterator i = _input_ports.begin(); i != _input_ports.end(); ++i) { @@ -296,6 +316,25 @@ Patch::remove_port(const string& name) } +Array* +Patch::build_ports_array() const +{ + assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS); + + Array* const result = new Array(_input_ports.size() + _output_ports.size()); + + size_t i = 0; + + for (List::const_iterator p = _input_ports.begin(); p != _input_ports.end(); ++p,++i) + result->at(i) = *p; + + for (List::const_iterator p = _output_ports.begin(); p != _output_ports.end(); ++p,++i) + result->at(i) = *p; + + return result; +} + + /** Find the process order for this Patch. * * The process order is a flat list that the patch will execute in order @@ -309,6 +348,8 @@ Patch::remove_port(const string& name) Array* Patch::build_process_order() const { + assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS); + cerr << "*********** Building process order for " << path() << endl; Array* const process_order = new Array(_nodes.size(), NULL); -- cgit v1.2.1