fix redrawing of canvas with an optimized build
[ardour.git] / libs / ardour / graph.cc
index c38106506edc8f21146d839a2313f92686aea00d..d183bcd7d271e41bcfa839dd3a4c4d281111e9d1 100644 (file)
@@ -96,24 +96,23 @@ Graph::reset_thread_list ()
            number of threads.
         */
 
-        if (_thread_list.size() == num_threads) {
+        if (AudioEngine::instance()->process_thread_count() == num_threads) {
                 return;
         }
 
-        Glib::Mutex::Lock lm (_session.engine().process_lock());
-       pthread_t a_thread;
+        Glib::Threads::Mutex::Lock lm (_session.engine().process_lock());
 
-        if (!_thread_list.empty()) {
+        if (AudioEngine::instance()->process_thread_count() != 0) {
                 drop_threads ();
         }
 
-       if (AudioEngine::instance()->create_process_thread (boost::bind (&Graph::main_thread, this), &a_thread, 100000) == 0) {
-               _thread_list.push_back (a_thread);
+       if (AudioEngine::instance()->create_process_thread (boost::bind (&Graph::main_thread, this)) != 0) {
+               throw failed_constructor ();
        }
 
         for (uint32_t i = 1; i < num_threads; ++i) {
-               if (AudioEngine::instance()->create_process_thread (boost::bind (&Graph::helper_thread, this), &a_thread, 100000) == 0) {
-                       _thread_list.push_back (a_thread);
+               if (AudioEngine::instance()->create_process_thread (boost::bind (&Graph::helper_thread, this))) {
+                       throw failed_constructor ();
                }
         }
 }
@@ -136,18 +135,15 @@ Graph::drop_threads ()
 {
         _quit_threads = true;
 
-        for (unsigned int i=0; i< _thread_list.size(); i++) {
+        uint32_t thread_count = AudioEngine::instance()->process_thread_count ();
+
+        for (unsigned int i=0; i < thread_count; i++) {
                _execution_sem.signal ();
         }
 
         _callback_start_sem.signal ();
 
-        for (list<pthread_t>::iterator i = _thread_list.begin(); i != _thread_list.end(); ++i) {
-                void* status;
-                pthread_join (*i, &status);
-        }
-
-        _thread_list.clear ();
+       AudioEngine::instance()->join_process_threads ();
 
        _execution_tokens = 0;
 
@@ -157,7 +153,7 @@ Graph::drop_threads ()
 void
 Graph::clear_other_chain ()
 {
-        Glib::Mutex::Lock ls (_swap_mutex);
+        Glib::Threads::Mutex::Lock ls (_swap_mutex);
 
         while (1) {
                 if (_setup_chain != _pending_chain) {
@@ -227,7 +223,7 @@ Graph::trigger (GraphNode* n)
 void
 Graph::dec_ref()
 {
-        if (g_atomic_int_dec_and_test (&_finished_refcount)) {
+        if (g_atomic_int_dec_and_test (const_cast<gint*> (&_finished_refcount))) {
 
                /* 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.
@@ -270,7 +266,7 @@ Graph::restart_cycle()
 void
 Graph::rechain (boost::shared_ptr<RouteList> routelist, GraphEdges const & edges)
 {
-        Glib::Mutex::Lock ls (_swap_mutex);
+        Glib::Threads::Mutex::Lock ls (_swap_mutex);
 
         int chain = _setup_chain;
         DEBUG_TRACE (DEBUG::Graph, string_compose ("============== setup %1\n", chain));
@@ -580,10 +576,5 @@ Graph::process_one_route (Route* route)
 bool
 Graph::in_process_thread () const
 {
-       for (list<pthread_t>::const_iterator i = _thread_list.begin (); i != _thread_list.end(); ++i) {
-               if (*i == pthread_self()) {
-                       return true;
-               }
-       }
-       return false;
+       return AudioEngine::instance()->in_process_thread ();
 }