diff options
author | Chris Robinson <[email protected]> | 2009-12-01 23:15:09 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-12-01 23:15:09 -0800 |
commit | 6cfc31777b7cca6714cf926fbc6e491c00a3f836 (patch) | |
tree | e535e539c85a82d29fc0956ee477aae2e25bc85e /Alc/ALc.c | |
parent | 0e1e8503e0f6fb73d06ba0dff6e5b2771b1df856 (diff) |
Add an option for real-time priority mixing
Default to disable for now, as a safety precaution
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r-- | Alc/ALc.c | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -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, ¶m); + } + else + { + param.sched_priority = 0; + failed = !!pthread_setschedparam(pthread_self(), SCHED_OTHER, ¶m); + } +#else + /* Real-time priority not available */ + failed = !!level; +#endif + if(failed) + AL_PRINT("Failed to set priority level for thread\n"); +} + + /* IsDevice |