]> git.sesse.net Git - vlc/blobdiff - src/misc/threads.c
Rescale POSIX realtime priorities within a portable range
[vlc] / src / misc / threads.c
index 11b3d478fd476a88fed11bbe6af5e0f439918f6a..90c6029ef545aeb5f87c85ab11eca36f4ac218ee 100644 (file)
@@ -48,6 +48,8 @@
 static volatile unsigned i_initializations = 0;
 
 #if defined( LIBVLC_USE_PTHREAD )
+# include <sched.h>
+
 static pthread_mutex_t once_mutex = PTHREAD_MUTEX_INITIALIZER;
 #endif
 
@@ -520,8 +522,10 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
             pthread_attr_setschedpolicy (&attr, SCHED_OTHER);
         else
         {
-            struct sched_param param = { .sched_priority = +i_priority, };
-            pthread_attr_setschedpolicy (&attr, SCHED_OTHER);
+            struct sched_param param = { .sched_priority = i_priority, };
+
+            param.sched_priority += sched_get_priority_min (SCHED_RR);
+            pthread_attr_setschedpolicy (&attr, SCHED_RR);
             pthread_attr_setschedparam (&attr, &param);
         }
     }