Commit 872bfb52 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Force thread priorities in the supported range

(assuming rt-offset is zero)
parent fbb8255d
...@@ -58,12 +58,12 @@ ...@@ -58,12 +58,12 @@
/* Thread priorities */ /* Thread priorities */
#ifdef __APPLE__ #ifdef __APPLE__
# define VLC_THREAD_PRIORITY_LOW (-47) # define VLC_THREAD_PRIORITY_LOW 0
# define VLC_THREAD_PRIORITY_INPUT 37 # define VLC_THREAD_PRIORITY_INPUT 22
# define VLC_THREAD_PRIORITY_AUDIO 37 # define VLC_THREAD_PRIORITY_AUDIO 22
# define VLC_THREAD_PRIORITY_VIDEO (-47) # define VLC_THREAD_PRIORITY_VIDEO 0
# define VLC_THREAD_PRIORITY_OUTPUT 37 # define VLC_THREAD_PRIORITY_OUTPUT 22
# define VLC_THREAD_PRIORITY_HIGHEST 37 # define VLC_THREAD_PRIORITY_HIGHEST 22
#elif defined(SYS_BEOS) #elif defined(SYS_BEOS)
# define VLC_THREAD_PRIORITY_LOW 5 # define VLC_THREAD_PRIORITY_LOW 5
......
...@@ -515,19 +515,19 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line ...@@ -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 ) if( config_GetInt( p_this, "rt-priority" ) > 0 )
#endif #endif
{ {
struct sched_param p = { .sched_priority = i_priority, };
int policy;
/* Hack to avoid error msg */ /* Hack to avoid error msg */
if( config_GetType( p_this, "rt-offset" ) ) if( config_GetType( p_this, "rt-offset" ) )
i_priority += config_GetInt( p_this, "rt-offset" ); p.sched_priority += config_GetInt( p_this, "rt-offset" );
if( i_priority <= 0 ) if( p.sched_priority <= 0 )
pthread_attr_setschedpolicy (&attr, SCHED_OTHER); p.sched_priority += sched_get_priority_max (policy = SCHED_OTHER);
else else
{ p.sched_priority += sched_get_priority_min (policy = SCHED_RR);
struct sched_param param = { .sched_priority = i_priority, };
param.sched_priority += sched_get_priority_min (SCHED_RR); pthread_attr_setschedpolicy (&attr, policy);
pthread_attr_setschedpolicy (&attr, SCHED_RR); pthread_attr_setschedparam (&attr, &p);
pthread_attr_setschedparam (&attr, &param);
}
} }
i_ret = pthread_create( &p_priv->thread_id, &attr, thread_entry, boot ); i_ret = pthread_create( &p_priv->thread_id, &attr, thread_entry, boot );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment