summaryrefslogtreecommitdiff
path: root/libs/pbd
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-02-24 04:38:49 +0100
committerRobin Gareus <robin@gareus.org>2020-02-24 04:38:49 +0100
commite737a9b00046c976409752da0f3b317c0599da27 (patch)
treef6e74f6086e06b90832b0730456cd8049660b292 /libs/pbd
parent7eb16db6285de164396ad2a904613cfb29556682 (diff)
Fix setting CoreAudio RT-priority
Diffstat (limited to 'libs/pbd')
-rw-r--r--libs/pbd/pthread_utils.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc
index e8a17792c2..2e2d2c820e 100644
--- a/libs/pbd/pthread_utils.cc
+++ b/libs/pbd/pthread_utils.cc
@@ -36,6 +36,12 @@ DECLARE_DEFAULT_COMPARISONS(pthread_t) // Needed for 'DECLARE_DEFAULT_COMPARISO
// to be the case with ptw32 'pthread_t' which is a simple struct.
#endif
+#ifdef __APPLE__
+#include <mach/thread_policy.h>
+#include <mach/thread_act.h>
+#include <mach/mach_time.h>
+#endif
+
using namespace std;
typedef std::list<pthread_t> ThreadMap;
@@ -271,15 +277,15 @@ pbd_set_thread_priority (pthread_t thread, const int policy, int priority)
bool
pbd_mach_set_realtime_policy (pthread_t thread_id, double period_ns)
{
-#ifdef _APPLE_
+#ifdef __APPLE__
thread_time_constraint_policy_data_t policy;
#ifndef NDEBUG
mach_msg_type_number_t msgt = 4;
boolean_t dflt = false;
- kern_return_t rv = thread_policy_get (pthread_mach_thread_np (_main_thread),
+ kern_return_t rv = thread_policy_get (pthread_mach_thread_np (thread_id),
THREAD_TIME_CONSTRAINT_POLICY, (thread_policy_t) &policy,
&msgt, &dflt);
- printf ("Mach Thread(%p) %d %d %d %d DFLT %d OK: %d\n", _main_thread, policy.period, policy.computation, policy.constraint, policy.preemptible, dflt, rv == KERN_SUCCESS);
+ printf ("Mach Thread(%p) %d %d %d %d DFLT %d OK: %d\n", thread_id, policy.period, policy.computation, policy.constraint, policy.preemptible, dflt, rv == KERN_SUCCESS);
#endif
mach_timebase_info_data_t timebase_info;