A few comments.
authorCarl Hetherington <carl@carlh.net>
Sat, 5 Nov 2011 15:58:38 +0000 (15:58 +0000)
committerCarl Hetherington <carl@carlh.net>
Sat, 5 Nov 2011 15:58:38 +0000 (15:58 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10459 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/graphnode.h
libs/ardour/graph.cc
libs/ardour/graphnode.cc

index 0c99a31a6cc361ace8323b84002ca038dcdf94f6..191babdb12ea3db49e1bc6af691fb6b8a2304879 100644 (file)
@@ -37,6 +37,7 @@ typedef boost::shared_ptr<GraphNode> 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> _graph;
 
        gint _refcount;
+       /** The number of nodes that we directly feed us (one count for each chain) */
        gint _init_refcount[2];
 };
 
index cb5ac65f11075ee26c713979edc4067f37c1f6f7..0950ee28c08a65cbb187021944d37771697c3f18 100644 (file)
@@ -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> 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<GraphNode> (*ri);
 
@@ -322,9 +331,21 @@ Graph::rechain (boost::shared_ptr<RouteList> 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<Route> rp = boost::dynamic_pointer_cast<Route>( *ni);
 
                 for (RouteList::iterator ri=routelist->begin(); ri!=routelist->end(); ri++) {
@@ -346,6 +367,7 @@ Graph::rechain (boost::shared_ptr<RouteList> 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;
                 }
index a919efcff3a6e8b3ec890d0f657a2aaf2927aff6..72b64abae0305d827f0c30b463a231f71cf98e53 100644 (file)
@@ -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();
         }
 }