From 59a3dd2383829b5794704065cfbe535b70e8f0ad Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 24 Jun 2010 16:20:32 +0000 Subject: 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 --- libs/ardour/ardour/graph.h | 5 +++-- libs/ardour/graph.cc | 39 +++++++++++++++++++++++++++++++++++---- libs/ardour/session.cc | 11 +++++++---- 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 _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 #include #include @@ -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::iterator i = _thread_list.begin(); i != _thread_list.end(); i++) { + for (list::iterator i = _thread_list.begin(); i != _thread_list.end(); i++) { void* status; pthread_join (*i, &status); } @@ -113,6 +115,33 @@ Graph::session_going_away() _trigger_queue.clear(); } +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() { @@ -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 writer (routes); shared_ptr r = writer.get_copy (); resort_routes_using (r); @@ -1381,7 +1379,7 @@ Session::resort_routes_using (shared_ptr 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) /* 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) 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) */ -- cgit v1.2.3