[vlc-devel] commit: Force thread priorities in the supported range ( Rémi Denis-Courmont )

git version control git at videolan.org
Fri Jun 6 18:32:19 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Fri Jun  6 19:34:03 2008 +0300| [872bfb52d2563c38c8fe3f4c831d2503d3f3a104]

Force thread priorities in the supported range

(assuming rt-offset is zero)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=872bfb52d2563c38c8fe3f4c831d2503d3f3a104
---

 include/vlc_threads.h |   12 ++++++------
 src/misc/threads.c    |   18 +++++++++---------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index c3c8b4f..89e8ccc 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -58,12 +58,12 @@
 
 /* Thread priorities */
 #ifdef __APPLE__
-#   define VLC_THREAD_PRIORITY_LOW (-47)
-#   define VLC_THREAD_PRIORITY_INPUT 37
-#   define VLC_THREAD_PRIORITY_AUDIO 37
-#   define VLC_THREAD_PRIORITY_VIDEO (-47)
-#   define VLC_THREAD_PRIORITY_OUTPUT 37
-#   define VLC_THREAD_PRIORITY_HIGHEST 37
+#   define VLC_THREAD_PRIORITY_LOW      0
+#   define VLC_THREAD_PRIORITY_INPUT   22
+#   define VLC_THREAD_PRIORITY_AUDIO   22
+#   define VLC_THREAD_PRIORITY_VIDEO    0
+#   define VLC_THREAD_PRIORITY_OUTPUT  22
+#   define VLC_THREAD_PRIORITY_HIGHEST 22
 
 #elif defined(SYS_BEOS)
 #   define VLC_THREAD_PRIORITY_LOW 5
diff --git a/src/misc/threads.c b/src/misc/threads.c
index 90c6029..0ae8fb4 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -515,19 +515,19 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
     if( config_GetInt( p_this, "rt-priority" ) > 0 )
 #endif
     {
+        struct sched_param p = { .sched_priority = i_priority, };
+        int policy;
+
         /* Hack to avoid error msg */
         if( config_GetType( p_this, "rt-offset" ) )
-            i_priority += config_GetInt( p_this, "rt-offset" );
-        if( i_priority <= 0 )
-            pthread_attr_setschedpolicy (&attr, SCHED_OTHER);
+            p.sched_priority += config_GetInt( p_this, "rt-offset" );
+        if( p.sched_priority <= 0 )
+            p.sched_priority += sched_get_priority_max (policy = SCHED_OTHER);
         else
-        {
-            struct sched_param param = { .sched_priority = i_priority, };
+            p.sched_priority += sched_get_priority_min (policy = SCHED_RR);
 
-            param.sched_priority += sched_get_priority_min (SCHED_RR);
-            pthread_attr_setschedpolicy (&attr, SCHED_RR);
-            pthread_attr_setschedparam (&attr, &param);
-        }
+        pthread_attr_setschedpolicy (&attr, policy);
+        pthread_attr_setschedparam (&attr, &p);
     }
 
     i_ret = pthread_create( &p_priv->thread_id, &attr, thread_entry, boot );




More information about the vlc-devel mailing list