diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index 0226e23282..7060e68331 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -240,7 +240,7 @@ _ the regular process() call to session->process() is not made. static AudioEngine* instance() { return _instance; } void died (); - pthread_t create_process_thread (boost::function, size_t stacksize); + int create_process_thread (boost::function, pthread_t*, size_t stacksize); private: static AudioEngine* _instance; diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 7a3c279705..5f619d8392 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -1477,19 +1477,18 @@ AudioEngine::is_realtime () const return jack_is_realtime (_priv_jack); } -pthread_t -AudioEngine::create_process_thread (boost::function f, size_t stacksize) +int +AudioEngine::create_process_thread (boost::function f, pthread_t* thread, size_t stacksize) { GET_PRIVATE_JACK_POINTER_RET (_jack, 0); - pthread_t thread; ThreadData* td = new ThreadData (this, f, stacksize); - if (jack_client_create_thread (_priv_jack, &thread, jack_client_real_time_priority (_priv_jack), + if (jack_client_create_thread (_priv_jack, thread, jack_client_real_time_priority (_priv_jack), jack_is_realtime (_priv_jack), _start_process_thread, td)) { return -1; } - return thread; + return 0; } void* diff --git a/libs/ardour/graph.cc b/libs/ardour/graph.cc index 0987b979a2..6dc76673ff 100644 --- a/libs/ardour/graph.cc +++ b/libs/ardour/graph.cc @@ -82,10 +82,15 @@ Graph::Graph (Session & session) info << string_compose (_("Using %2 threads on %1 CPUs"), num_cpu, num_threads) << endmsg; - _thread_list.push_back (AudioEngine::instance()->create_process_thread (boost::bind (&Graph::main_thread, this), 100000)); + pthread_t a_thread; + + if (AudioEngine::instance()->create_process_thread (boost::bind (&Graph::main_thread, this), &a_thread, 100000) == 0) { + _thread_list.push_back (a_thread); + } for (int i = 1; i < num_threads; ++i) { - _thread_list.push_back (AudioEngine::instance()->create_process_thread (boost::bind (&Graph::helper_thread, this), 100000)); + if (AudioEngine::instance()->create_process_thread (boost::bind (&Graph::helper_thread, this), &a_thread, 100000)); + _thread_list.push_back (a_thread); } } @@ -317,7 +322,10 @@ Graph::run_one() to_run = 0; } - int wakeup = min ((int) _execution_tokens, (int) _trigger_queue.size()); + int et = _execution_tokens; + int ts = _trigger_queue.size(); + + int wakeup = min (et, ts); _execution_tokens -= wakeup; for (int i=0; i