diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-06-24 14:13:45 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-06-24 14:13:45 +0000 |
commit | 0f5bdd666fa66bd279f8629a670d8058780a613d (patch) | |
tree | 2456f101d56c9d2f091631293f8b85645389f031 /libs/ardour/audioengine.cc | |
parent | fe229a830e0164e56d3aceaf3d539e4148f322a6 (diff) |
use JACK thread creation functions to create process-graph threads; provide GUI control over number of threads-relative-to-number-of-CPUS
git-svn-id: svn://localhost/ardour2/branches/3.0@7296 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/audioengine.cc')
-rw-r--r-- | libs/ardour/audioengine.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 903fbb227d..2282a20809 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -25,6 +25,9 @@ #include <sstream> #include <glibmm/timer.h> +#include <jack/jack.h> +#include <jack/thread.h> + #include "pbd/pthread_utils.h" #include "pbd/stacktrace.h" #include "pbd/unknown_type.h" @@ -1480,3 +1483,30 @@ AudioEngine::is_realtime () const GET_PRIVATE_JACK_POINTER_RET (_jack,false); return jack_is_realtime (_priv_jack); } + +pthread_t +AudioEngine::create_process_thread (boost::function<void()> f, 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), + jack_is_realtime (_priv_jack), _start_process_thread, td)) { + return -1; + } + + return thread; +} + +void* +AudioEngine::_start_process_thread (void* arg) +{ + ThreadData* td = reinterpret_cast<ThreadData*> (arg); + boost::function<void()> f = td->f; + delete td; + + f (); + + return 0; +} |