diff options
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; +} |