summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-06-24 16:20:32 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-06-24 16:20:32 +0000
commit59a3dd2383829b5794704065cfbe535b70e8f0ad (patch)
tree778ac9f75e35112a868aa23f054682cee93830d9
parentea2f5f170bdad35989241662f1d1fe875d5a24a3 (diff)
clear activation_sets component of Graph, thus restoring full Route deletion
git-svn-id: svn://localhost/ardour2/branches/3.0@7298 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/ardour/ardour/graph.h5
-rw-r--r--libs/ardour/graph.cc39
-rw-r--r--libs/ardour/session.cc11
3 files changed, 45 insertions, 10 deletions
diff --git a/libs/ardour/ardour/graph.h b/libs/ardour/ardour/graph.h
index f38ef12721..a6863fc86b 100644
--- a/libs/ardour/ardour/graph.h
+++ b/libs/ardour/ardour/graph.h
@@ -81,6 +81,8 @@ class Graph : public SessionHandleRef
void process_one_route (Route * route);
+ void clear_other_chain ();
+
protected:
virtual void session_going_away ();
@@ -95,11 +97,10 @@ class Graph : public SessionHandleRef
std::vector<GraphNode *> _trigger_queue;
pthread_mutex_t _trigger_mutex;
-
sem_t _execution_sem;
-
sem_t _callback_start_sem;
sem_t _callback_done_sem;
+ sem_t _cleanup_sem;
volatile gint _execution_tokens;
volatile gint _finished_refcount;
diff --git a/libs/ardour/graph.cc b/libs/ardour/graph.cc
index 5b6a42437b..dd56cb9880 100644
--- a/libs/ardour/graph.cc
+++ b/libs/ardour/graph.cc
@@ -17,7 +17,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+#include <iostream>
#include <stdio.h>
#include <cmath>
@@ -38,6 +38,7 @@
using namespace ARDOUR;
using namespace PBD;
+using namespace std;
Graph::Graph (Session & session)
@@ -48,6 +49,7 @@ Graph::Graph (Session & session)
sem_init( &_callback_start_sem, 0, 0 );
sem_init( &_callback_done_sem, 0, 0 );
+ sem_init( &_cleanup_sem, 0, 0 );
_execution_tokens = 0;
@@ -100,7 +102,7 @@ Graph::session_going_away()
sem_post( &_callback_start_sem);
- for (std::list<pthread_t>::iterator i = _thread_list.begin(); i != _thread_list.end(); i++) {
+ for (list<pthread_t>::iterator i = _thread_list.begin(); i != _thread_list.end(); i++) {
void* status;
pthread_join (*i, &status);
}
@@ -114,6 +116,33 @@ Graph::session_going_away()
}
void
+Graph::clear_other_chain ()
+{
+ while (1) {
+ pthread_mutex_lock (&_swap_mutex);
+ if (_setup_chain != _pending_chain) {
+
+ for (node_list_t::iterator ni=_nodes_rt[_setup_chain].begin(); ni!=_nodes_rt[_setup_chain].end(); ni++) {
+ (*ni)->_activation_set[_setup_chain].clear();
+ }
+
+ _nodes_rt[_setup_chain].clear ();
+ _init_trigger_list[_setup_chain].clear ();
+ pthread_mutex_unlock (&_swap_mutex);
+
+ return;
+ }
+ pthread_mutex_unlock (&_swap_mutex);
+ /* setup chain == pending chain - we have
+ to wait till this is no longer true.
+ */
+ cerr << "Wait for setup != pending (currently " << _setup_chain << '/' << _pending_chain << endl;
+ int ret = sem_wait (&_cleanup_sem);
+ cerr << " back from that wait, ret = " << ret << endl;
+ }
+}
+
+void
Graph::prep()
{
node_list_t::iterator i;
@@ -123,9 +152,11 @@ Graph::prep()
// we got the swap mutex.
if (_current_chain != _pending_chain)
{
- //printf ("chain swap ! %d -> %d\n", _current_chain, _pending_chain);
+ printf ("chain swap ! %d -> %d\n", _current_chain, _pending_chain);
_setup_chain = _current_chain;
_current_chain = _pending_chain;
+ printf ("\tNOW: setup %d current %d pending %d\n", _setup_chain, _current_chain, _pending_chain);
+ sem_post (&_cleanup_sem);
}
pthread_mutex_unlock (&_swap_mutex);
}
@@ -295,7 +326,7 @@ Graph::run_one()
to_run = 0;
}
- int wakeup = std::min ((int) _execution_tokens, (int) _trigger_queue.size());
+ int wakeup = min ((int) _execution_tokens, (int) _trigger_queue.size());
_execution_tokens -= wakeup;
for (int i=0; i<wakeup; i++ ) {
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 94945b95c2..7a4a4c4e9f 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -1317,9 +1317,7 @@ Session::resort_routes ()
return;
}
-
{
-
RCUWriter<RouteList> writer (routes);
shared_ptr<RouteList> r = writer.get_copy ();
resort_routes_using (r);
@@ -1381,7 +1379,7 @@ Session::resort_routes_using (shared_ptr<RouteList> r)
RouteSorter cmp;
r->sort (cmp);
- route_graph->rechain( r );
+ route_graph->rechain (r);
#ifndef NDEBUG
DEBUG_TRACE (DEBUG::Graph, "Routes resorted, order follows:\n");
@@ -2081,7 +2079,7 @@ Session::remove_route (shared_ptr<Route> route)
/* writer goes out of scope, forces route list update */
}
-
+
update_route_solo_state ();
update_session_range_location_marker ();
@@ -2105,6 +2103,11 @@ Session::remove_route (shared_ptr<Route> route)
update_latency_compensation (false, false);
set_dirty();
+ /* flush references out of the graph
+ */
+
+ route_graph->clear_other_chain ();
+
/* get rid of it from the dead wood collection in the route list manager */
/* XXX i think this is unsafe as it currently stands, but i am not sure. (pd, october 2nd, 2006) */