aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALc.c
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r--Alc/ALc.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 9225f330..970b98c9 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -208,6 +208,9 @@ static tls_type LocalContext;
// Context Error
static ALCenum g_eLastContextError = ALC_NO_ERROR;
+// Mixing Priority Level
+ALint RTPrioLevel;
+
///////////////////////////////////////////////////////
@@ -253,6 +256,8 @@ static void alc_init(void)
tls_create(&LocalContext);
+ RTPrioLevel = GetConfigValueInt(NULL, "rt-prio", 0);
+
devs = GetConfigValue(NULL, "drivers", "");
if(devs[0])
{
@@ -424,6 +429,39 @@ DECL_APPEND_LIST_FUNC(AllDevice)
DECL_APPEND_LIST_FUNC(CaptureDevice)
+void EnableRTPrio(ALint level)
+{
+ ALboolean failed;
+
+#ifdef _WIN32
+ if(level > 0)
+ failed = !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
+ else
+ failed = !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
+#elif defined(HAVE_PTHREAD_SETSCHEDPARAM)
+ struct sched_param param;
+
+ if(level > 0)
+ {
+ /* Use the minimum real-time priority possible for now (on Linux this
+ * should be 1 for SCHED_RR) */
+ param.sched_priority = sched_get_priority_min(SCHED_RR);
+ failed = !!pthread_setschedparam(pthread_self(), SCHED_RR, &param);
+ }
+ else
+ {
+ param.sched_priority = 0;
+ failed = !!pthread_setschedparam(pthread_self(), SCHED_OTHER, &param);
+ }
+#else
+ /* Real-time priority not available */
+ failed = !!level;
+#endif
+ if(failed)
+ AL_PRINT("Failed to set priority level for thread\n");
+}
+
+
/*
IsDevice