From e12432cc632125821d6ed192d129ef385fb25002 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 5 Nov 2011 15:58:38 +0000 Subject: A few comments. git-svn-id: svn://localhost/ardour2/branches/3.0@10459 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/graphnode.h | 2 ++ libs/ardour/graph.cc | 26 ++++++++++++++++++++++++-- libs/ardour/graphnode.cc | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/graphnode.h b/libs/ardour/ardour/graphnode.h index 0c99a31a6c..191babdb12 100644 --- a/libs/ardour/ardour/graphnode.h +++ b/libs/ardour/ardour/graphnode.h @@ -37,6 +37,7 @@ typedef boost::shared_ptr node_ptr_t; typedef std::set< node_ptr_t > node_set_t; typedef std::list< node_ptr_t > node_list_t; +/** A node on our processing graph, ie a Route */ class GraphNode { public: @@ -57,6 +58,7 @@ class GraphNode boost::shared_ptr _graph; gint _refcount; + /** The number of nodes that we directly feed us (one count for each chain) */ gint _init_refcount[2]; }; diff --git a/libs/ardour/graph.cc b/libs/ardour/graph.cc index cb5ac65f11..0950ee28c0 100644 --- a/libs/ardour/graph.cc +++ b/libs/ardour/graph.cc @@ -238,8 +238,9 @@ Graph::dec_ref() { if (g_atomic_int_dec_and_test (&_finished_refcount)) { - // ok... this cycle is finished now. - // we are the only thread alive. + /* We have run all the nodes that are at the `output' end of + the graph, so there is nothing more to do this time around. + */ this->restart_cycle(); } @@ -306,11 +307,19 @@ Graph::rechain (boost::shared_ptr routelist) DEBUG_TRACE (DEBUG::Graph, string_compose ("============== setup %1\n", chain)); // set all refcounts to 0; + /* This will become the number of nodes that do not feed any other node; + once we have processed this number of those nodes, we have finished. + */ _init_finished_refcount[chain] = 0; + + /* This will become a list of nodes that are not fed by another node, ie + those at the `input' end. + */ _init_trigger_list[chain].clear(); _nodes_rt[chain].clear(); + /* Clear things out, and make _nodes_rt[chain] a copy of routelist */ for (RouteList::iterator ri=routelist->begin(); ri!=routelist->end(); ri++) { node_ptr_t n = boost::dynamic_pointer_cast (*ri); @@ -322,9 +331,21 @@ Graph::rechain (boost::shared_ptr routelist) // now add refs for the connections. for (ni=_nodes_rt[chain].begin(); ni!=_nodes_rt[chain].end(); ni++) { + + /* We will set this to true if the node *ni is directly or + indirectly fed by anything (without feedback) + */ bool has_input = false; + + /* We will set this to true if the node *ni directly feeds + anything (without feedback) + */ bool has_output = false; + /* We will also set up *ni's _activation_set to contain any nodes + that it directly feeds. + */ + boost::shared_ptr rp = boost::dynamic_pointer_cast( *ni); for (RouteList::iterator ri=routelist->begin(); ri!=routelist->end(); ri++) { @@ -346,6 +367,7 @@ Graph::rechain (boost::shared_ptr routelist) } } + /* Increment the refcount of any route that we directly feed */ for (node_set_t::iterator ai=(*ni)->_activation_set[chain].begin(); ai!=(*ni)->_activation_set[chain].end(); ai++) { (*ai)->_init_refcount[chain] += 1; } diff --git a/libs/ardour/graphnode.cc b/libs/ardour/graphnode.cc index a919efcff3..72b64abae0 100644 --- a/libs/ardour/graphnode.cc +++ b/libs/ardour/graphnode.cc @@ -58,6 +58,7 @@ GraphNode::finish (int chain) } if (!feeds_somebody) { + /* This node does not feed anybody, so decrement the graph's finished count */ _graph->dec_ref(); } } -- cgit v1.2.3