Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Steve Lhomme
VLC
Commits
270e1cb5
Commit
270e1cb5
authored
Dec 08, 2002
by
Christophe Massiot
Browse files
New vlc_thread_set_priority function, to set the priority of the main
thread.
parent
ec518727
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/vlc_threads_funcs.h
View file @
270e1cb5
...
...
@@ -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/1
1/11 14:39:11 sam
Exp $
* $Id: vlc_threads_funcs.h,v 1.
10
2002/1
2/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
*****************************************************************************/
...
...
src/libvlc.c
View file @
270e1cb5
...
...
@@ -2,7 +2,7 @@
* libvlc.c: main libvlc source
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.c,v 1.
49
2002/12/0
3 16:29:04 gitan
Exp $
* $Id: libvlc.c,v 1.
50
2002/12/0
8 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
)
...
...
src/misc/threads.c
View file @
270e1cb5
...
...
@@ -2,7 +2,7 @@
* threads.c : threads implementation for the VideoLAN client
*****************************************************************************
* Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
* $Id: threads.c,v 1.2
7
2002/12/0
6 10:10:40 sam
Exp $
* $Id: threads.c,v 1.2
8
2002/12/0
8 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
*****************************************************************************/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment