+/*****************************************************************************
+ * vlc_thread_set_priority: set the priority of the current thread when we
+ * couldn't set it in vlc_thread_create (for instance for the main thread)
+ *****************************************************************************/
+int __vlc_thread_set_priority( vlc_object_t *p_this, char * psz_file,
+ int i_line, int i_priority )
+{
+#if defined( WIN32 ) || defined( UNDER_CE )
+ if ( !SetThreadPriority(GetCurrentThread(), i_priority) )
+ {
+ msg_Warn( p_this, "couldn't set a faster priority" );
+ return 1;
+ }
+
+#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
+ if ( i_priority )
+ {
+ struct sched_param param;
+ memset( ¶m, 0, sizeof(struct sched_param) );
+ param.sched_priority = i_priority;
+ if ( pthread_setschedparam( pthread_self(), SCHED_RR, ¶m ) )
+ {
+ msg_Warn( p_this, "couldn't go to real-time priority (%s:%d)",
+ psz_file, i_line );
+ return 1;
+ }
+ }
+
+#else
+ return 1;
+#endif
+
+ return 0;
+}
+