From f63d8dbf38352b9ca0f1dc5e8eab87242c81b3ee Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 29 Nov 2009 23:02:21 -0800 Subject: Enable real-time priority for ALSA, OSS, and DirectSound mixing loops --- OpenAL32/Include/alMain.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'OpenAL32/Include/alMain.h') diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index e235794a..0820b9dc 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -181,6 +181,22 @@ static __inline ALuint NextPowerOf2(ALuint value) return powerOf2; } +static __inline void EnableRTPrio() +{ +#ifdef _WIN32 + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); +#elif defined(HAVE_PTHREAD_SETSCHEDPARAM) + struct sched_param param; + + /* 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); + pthread_setschedparam(pthread_self(), SCHED_RR, ¶m); +#else + /* Real-time priority not available */ +#endif +} + typedef struct { ALCboolean (*OpenPlayback)(ALCdevice*, const ALCchar*); -- cgit v1.2.3