]> git.sesse.net Git - vlc/blobdiff - src/misc/threads.c
Thread priority management on BeOS.
[vlc] / src / misc / threads.c
index 36c4d3d849d69eaac070d98a9ec967bd7fd761ba..269a63b863676281ea0712e94e57f13149ff4cf5 100644 (file)
@@ -2,7 +2,7 @@
  * threads.c : threads implementation for the VideoLAN client
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
- * $Id: threads.c,v 1.29 2002/12/14 19:19:08 gbazin Exp $
+ * $Id: threads.c,v 1.34 2003/01/10 17:01:53 titer Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -607,15 +607,18 @@ int __vlc_thread_create( vlc_object_t *p_this, char * psz_file, int i_line,
 
     if ( i_priority )
     {
+        int i_error;
         struct sched_param param;
         memset( &param, 0, sizeof(struct sched_param) );
         param.sched_priority = i_priority;
-        if ( pthread_setschedparam( p_this->thread_id, SCHED_RR, &param ) )
+        if ( (i_error = pthread_setschedparam( p_this->thread_id,
+                                               SCHED_RR, &param )) )
         {
-            msg_Warn( p_this, "couldn't go to real-time priority (%s:%d)",
-                      psz_file, i_line );
+            msg_Warn( p_this, "couldn't go to real-time priority (%s:%d): %s",
+                      psz_file, i_line, strerror(i_error) );
             i_priority = 0;
         }
+
     }
 
 #elif defined( HAVE_CTHREADS_H )
@@ -624,7 +627,7 @@ int __vlc_thread_create( vlc_object_t *p_this, char * psz_file, int i_line,
 
 #elif defined( HAVE_KERNEL_SCHEDULER_H )
     p_this->thread_id = spawn_thread( (thread_func)func, psz_name,
-                                      B_NORMAL_PRIORITY, (void *)p_this );
+                                      i_priority/* B_NORMAL_PRIORITY */, (void *)p_this );
     i_ret = resume_thread( p_this->thread_id );
 
 #endif
@@ -651,7 +654,7 @@ int __vlc_thread_create( vlc_object_t *p_this, char * psz_file, int i_line,
         p_this->b_thread = 1;
 
         msg_Dbg( p_this, "thread %d (%s) created at priority %d (%s:%d)",
-                 p_this->thread_id, psz_name, i_priority,
+                 (int)p_this->thread_id, psz_name, i_priority,
                  psz_file, i_line );
 
         vlc_mutex_unlock( &p_this->object_lock );
@@ -688,19 +691,19 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, char * psz_file,
 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
     if ( i_priority )
     {
+        int i_error;
         struct sched_param param;
         memset( &param, 0, sizeof(struct sched_param) );
         param.sched_priority = i_priority;
-        if ( pthread_setschedparam( pthread_self(), SCHED_RR, &param ) )
+        if ( (i_error = pthread_setschedparam( pthread_self(),
+                                               SCHED_RR, &param )) )
         {
-            msg_Warn( p_this, "couldn't go to real-time priority (%s:%d)",
-                      psz_file, i_line );
-            return 1;
+            msg_Warn( p_this, "couldn't go to real-time priority (%s:%d): %s",
+                      psz_file, i_line, strerror(i_error) );
+            i_priority = 0;
         }
     }
 
-#else
-    return 1;
 #endif
 
     return 0;
@@ -752,16 +755,17 @@ void __vlc_thread_join( vlc_object_t *p_this, char * psz_file, int i_line )
     {
 #ifdef HAVE_STRERROR
         msg_Err( p_this, "thread_join(%d) failed at %s:%d (%s)",
-                         p_this->thread_id, psz_file, i_line, strerror(i_ret) );
+                         (int)p_this->thread_id, psz_file, i_line,
+                         strerror(i_ret) );
 #else
         msg_Err( p_this, "thread_join(%d) failed at %s:%d",
-                         p_this->thread_id, psz_file, i_line );
+                         (int)p_this->thread_id, psz_file, i_line );
 #endif
     }
     else
     {
         msg_Dbg( p_this, "thread %d joined (%s:%d)",
-                         p_this->thread_id, psz_file, i_line );
+                         (int)p_this->thread_id, psz_file, i_line );
     }
 
     p_this->b_thread = 0;