OutputThread: use real-time priority

This commit is contained in:
Max Kellermann 2014-01-14 09:59:04 +01:00
parent 5d17731b73
commit 4734af747b
3 changed files with 17 additions and 0 deletions

1
NEWS
View File

@ -18,6 +18,7 @@ ver 0.19 (not yet released)
- shine: new encoder plugin - shine: new encoder plugin
* new resampler option using libsoxr * new resampler option using libsoxr
* the update thread runs at "idle" priority * the update thread runs at "idle" priority
* the output thread runs at "real-time" priority
ver 0.18.7 (2013/01/13) ver 0.18.7 (2013/01/13)
* playlist * playlist

View File

@ -30,6 +30,7 @@
#include "PlayerControl.hxx" #include "PlayerControl.hxx"
#include "MusicPipe.hxx" #include "MusicPipe.hxx"
#include "MusicChunk.hxx" #include "MusicChunk.hxx"
#include "thread/Util.hxx"
#include "system/FatalError.hxx" #include "system/FatalError.hxx"
#include "util/Error.hxx" #include "util/Error.hxx"
#include "Log.hxx" #include "Log.hxx"
@ -578,6 +579,8 @@ audio_output_task(void *arg)
{ {
struct audio_output *ao = (struct audio_output *)arg; struct audio_output *ao = (struct audio_output *)arg;
SetThreadRealtime();
ao->mutex.lock(); ao->mutex.lock();
while (1) { while (1) {

View File

@ -69,4 +69,17 @@ SetThreadIdlePriority()
#endif #endif
}; };
/**
* Raise the current thread's priority to "real-time" (very high).
*/
static inline void
SetThreadRealtime()
{
#ifdef __linux__
struct sched_param sched_param;
sched_param.sched_priority = 50;
sched_setscheduler(0, SCHED_FIFO, &sched_param);
#endif
};
#endif #endif