diff --git a/libs/backends/coreaudio/coreaudio_backend.cc b/libs/backends/coreaudio/coreaudio_backend.cc index 72ec0d277d..04e07000d1 100644 --- a/libs/backends/coreaudio/coreaudio_backend.cc +++ b/libs/backends/coreaudio/coreaudio_backend.cc @@ -830,6 +830,11 @@ void * CoreAudioBackend::coreaudio_process_thread (void *arg) { ThreadData* td = reinterpret_cast (arg); + + if (pbd_mach_set_realtime_policy (pthread_self (), period_ns, false)) { + PBD::warning << _("AudioEngine: process thread failed to set mach realtime policy.") << endmsg; + } + #if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000 if (td->_joined_workgroup) { /* have WG */ @@ -871,7 +876,7 @@ int CoreAudioBackend::create_process_thread (boost::function func) { pthread_t thread_id; - ThreadData* td = new ThreadData (this, func, PBD_RT_STACKSIZE_PROC); + ThreadData* td = new ThreadData (this, func, PBD_RT_STACKSIZE_PROC, 1e9 * _samples_per_period / _samplerate); #if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000 if (_pcmio->workgroup (td->_workgroup)) { @@ -890,10 +895,6 @@ CoreAudioBackend::create_process_thread (boost::function func) PBD::warning << _("AudioEngine: process thread failed to acquire realtime permissions.") << endmsg; } - if (pbd_mach_set_realtime_policy (thread_id, 1e9 * _samples_per_period / _samplerate, false)) { - PBD::warning << _("AudioEngine: process thread failed to set mach realtime policy.") << endmsg; - } - _threads.push_back (thread_id); return 0; } diff --git a/libs/backends/coreaudio/coreaudio_backend.h b/libs/backends/coreaudio/coreaudio_backend.h index 34c17590b8..6ccf1bf3f7 100644 --- a/libs/backends/coreaudio/coreaudio_backend.h +++ b/libs/backends/coreaudio/coreaudio_backend.h @@ -388,6 +388,7 @@ class CoreAudioBackend : public AudioBackend, public PortEngineSharedImpl { CoreAudioBackend* engine; boost::function f; size_t stacksize; + double period_ns; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000 bool _joined_workgroup; @@ -395,8 +396,8 @@ class CoreAudioBackend : public AudioBackend, public PortEngineSharedImpl { os_workgroup_join_token_s _join_token; #endif - ThreadData (CoreAudioBackend* e, boost::function fp, size_t stacksz) - : engine (e) , f (fp) , stacksize (stacksz) {} + ThreadData (CoreAudioBackend* e, boost::function fp, size_t stacksz, double period) + : engine (e) , f (fp) , stacksize (stacksz), period_ns {} }; /* port engine */