Commit 270e1cb5 authored by Christophe Massiot's avatar Christophe Massiot

New vlc_thread_set_priority function, to set the priority of the main

thread.
parent ec518727
......@@ -3,7 +3,7 @@
* This header provides a portable threads implementation.
*****************************************************************************
* Copyright (C) 1999, 2002 VideoLAN
* $Id: vlc_threads_funcs.h,v 1.9 2002/11/11 14:39:11 sam Exp $
* $Id: vlc_threads_funcs.h,v 1.10 2002/12/08 00:41:06 massiot Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
......@@ -35,9 +35,11 @@ VLC_EXPORT( int, __vlc_mutex_destroy, ( char *, int, vlc_mutex_t * ) );
VLC_EXPORT( int, __vlc_cond_init, ( vlc_object_t *, vlc_cond_t * ) );
VLC_EXPORT( int, __vlc_cond_destroy, ( char *, int, vlc_cond_t * ) );
VLC_EXPORT( int, __vlc_thread_create, ( vlc_object_t *, char *, int, char *, void * ( * ) ( void * ), int, vlc_bool_t ) );
VLC_EXPORT( int, __vlc_thread_set_priority, ( vlc_object_t *, char *, int, int ) );
VLC_EXPORT( void, __vlc_thread_ready, ( vlc_object_t * ) );
VLC_EXPORT( void, __vlc_thread_join, ( vlc_object_t *, char *, int ) );
/*****************************************************************************
* vlc_threads_init: initialize threads system
*****************************************************************************/
......@@ -684,6 +686,12 @@ static inline int __vlc_cond_wait( char * psz_file, int i_line,
#define vlc_thread_create( P_THIS, PSZ_NAME, FUNC, PRIORITY, WAIT ) \
__vlc_thread_create( VLC_OBJECT(P_THIS), __FILE__, __LINE__, PSZ_NAME, (void * ( * ) ( void * ))FUNC, PRIORITY, WAIT )
/*****************************************************************************
* vlc_thread_set_priority: set the priority of the calling thread
*****************************************************************************/
#define vlc_thread_set_priority( P_THIS, PRIORITY ) \
__vlc_thread_set_priority( VLC_OBJECT(P_THIS), __FILE__, __LINE__, PRIORITY )
/*****************************************************************************
* vlc_thread_ready: tell the parent thread we were successfully spawned
*****************************************************************************/
......
......@@ -2,7 +2,7 @@
* libvlc.c: main libvlc source
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.c,v 1.49 2002/12/03 16:29:04 gitan Exp $
* $Id: libvlc.c,v 1.50 2002/12/08 00:41:06 massiot Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -763,7 +763,8 @@ int VLC_Play( int i_object )
VLC_AddIntf( 0, "sap", VLC_FALSE );
}
vlc_thread_set_priority( p_vlc, VLC_THREAD_PRIORITY_LOW );
p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_CHILD );
if( !p_playlist )
......
......@@ -2,7 +2,7 @@
* threads.c : threads implementation for the VideoLAN client
*****************************************************************************
* Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
* $Id: threads.c,v 1.27 2002/12/06 10:10:40 sam Exp $
* $Id: threads.c,v 1.28 2002/12/08 00:41:06 massiot Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -612,7 +612,8 @@ int __vlc_thread_create( vlc_object_t *p_this, char * psz_file, int i_line,
param.sched_priority = i_priority;
if ( pthread_setschedparam( p_this->thread_id, SCHED_RR, &param ) )
{
msg_Warn( p_this, "couldn't go to real-time priority" );
msg_Warn( p_this, "couldn't go to real-time priority (%s:%d)",
psz_file, i_line );
i_priority = 0;
}
}
......@@ -670,6 +671,32 @@ int __vlc_thread_create( vlc_object_t *p_this, char * psz_file, int i_line,
return i_ret;
}
/*****************************************************************************
* 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 )
/* FIXME: implement it under Win32 ! */
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
if ( i_priority )
{
struct sched_param param;
memset( &param, 0, sizeof(struct sched_param) );
param.sched_priority = i_priority;
if ( pthread_setschedparam( pthread_self(), SCHED_RR, &param ) )
{
msg_Warn( p_this, "couldn't go to real-time priority (%s:%d)",
psz_file, i_line );
i_priority = 0;
}
}
#endif
}
/*****************************************************************************
* vlc_thread_ready: tell the parent thread we were successfully spawned
*****************************************************************************/
......
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