Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
3afd1ff1
Commit
3afd1ff1
authored
May 08, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move pthread to the front.
If anyone wants to try on Win32, that's going to help.
parent
55aeca35
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
129 additions
and
159 deletions
+129
-159
src/misc/threads.c
src/misc/threads.c
+129
-159
No files found.
src/misc/threads.c
View file @
3afd1ff1
...
@@ -46,10 +46,7 @@
...
@@ -46,10 +46,7 @@
*****************************************************************************/
*****************************************************************************/
static
volatile
unsigned
i_initializations
=
0
;
static
volatile
unsigned
i_initializations
=
0
;
#if defined( UNDER_CE )
#if defined( LIBVLC_USE_PTHREAD )
#elif defined( WIN32 )
#elif defined( HAVE_KERNEL_SCHEDULER_H )
#elif defined( LIBVLC_USE_PTHREAD )
static
pthread_mutex_t
once_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
static
pthread_mutex_t
once_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
#endif
#endif
...
@@ -133,10 +130,7 @@ int vlc_threads_init( void )
...
@@ -133,10 +130,7 @@ int vlc_threads_init( void )
/* If we have lazy mutex initialization, use it. Otherwise, we just
/* If we have lazy mutex initialization, use it. Otherwise, we just
* hope nothing wrong happens. */
* hope nothing wrong happens. */
#if defined( UNDER_CE )
#if defined( LIBVLC_USE_PTHREAD )
#elif defined( WIN32 )
#elif defined( HAVE_KERNEL_SCHEDULER_H )
#elif defined( LIBVLC_USE_PTHREAD )
pthread_mutex_lock
(
&
once_mutex
);
pthread_mutex_lock
(
&
once_mutex
);
#endif
#endif
...
@@ -158,10 +152,7 @@ int vlc_threads_init( void )
...
@@ -158,10 +152,7 @@ int vlc_threads_init( void )
out:
out:
/* If we have lazy mutex initialization support, unlock the mutex.
/* If we have lazy mutex initialization support, unlock the mutex.
* Otherwize, we are screwed. */
* Otherwize, we are screwed. */
#if defined( UNDER_CE )
#if defined( LIBVLC_USE_PTHREAD )
#elif defined( WIN32 )
#elif defined( HAVE_KERNEL_SCHEDULER_H )
#elif defined( LIBVLC_USE_PTHREAD )
pthread_mutex_unlock
(
&
once_mutex
);
pthread_mutex_unlock
(
&
once_mutex
);
#endif
#endif
...
@@ -175,10 +166,7 @@ out:
...
@@ -175,10 +166,7 @@ out:
*****************************************************************************/
*****************************************************************************/
void
vlc_threads_end
(
void
)
void
vlc_threads_end
(
void
)
{
{
#if defined( UNDER_CE )
#if defined( LIBVLC_USE_PTHREAD )
#elif defined( WIN32 )
#elif defined( HAVE_KERNEL_SCHEDULER_H )
#elif defined( LIBVLC_USE_PTHREAD )
pthread_mutex_lock
(
&
once_mutex
);
pthread_mutex_lock
(
&
once_mutex
);
#endif
#endif
...
@@ -188,10 +176,7 @@ void vlc_threads_end( void )
...
@@ -188,10 +176,7 @@ void vlc_threads_end( void )
vlc_object_release
(
p_root
);
vlc_object_release
(
p_root
);
i_initializations
--
;
i_initializations
--
;
#if defined( UNDER_CE )
#if defined( LIBVLC_USE_PTHREAD )
#elif defined( WIN32 )
#elif defined( HAVE_KERNEL_SCHEDULER_H )
#elif defined( LIBVLC_USE_PTHREAD )
pthread_mutex_unlock
(
&
once_mutex
);
pthread_mutex_unlock
(
&
once_mutex
);
#endif
#endif
}
}
...
@@ -206,7 +191,24 @@ int pthread_mutexattr_setkind_np( pthread_mutexattr_t *attr, int kind );
...
@@ -206,7 +191,24 @@ int pthread_mutexattr_setkind_np( pthread_mutexattr_t *attr, int kind );
*****************************************************************************/
*****************************************************************************/
int
vlc_mutex_init
(
vlc_mutex_t
*
p_mutex
)
int
vlc_mutex_init
(
vlc_mutex_t
*
p_mutex
)
{
{
#if defined( UNDER_CE )
#if defined( LIBVLC_USE_PTHREAD )
pthread_mutexattr_t
attr
;
int
i_result
;
pthread_mutexattr_init
(
&
attr
);
# ifndef NDEBUG
/* Create error-checking mutex to detect problems more easily. */
# if defined(SYS_LINUX)
pthread_mutexattr_setkind_np
(
&
attr
,
PTHREAD_MUTEX_ERRORCHECK_NP
);
# else
pthread_mutexattr_settype
(
&
attr
,
PTHREAD_MUTEX_ERRORCHECK
);
# endif
# endif
i_result
=
pthread_mutex_init
(
p_mutex
,
&
attr
);
pthread_mutexattr_destroy
(
&
attr
);
return
i_result
;
#elif defined( UNDER_CE )
InitializeCriticalSection
(
&
p_mutex
->
csection
);
InitializeCriticalSection
(
&
p_mutex
->
csection
);
return
0
;
return
0
;
...
@@ -235,23 +237,6 @@ int vlc_mutex_init( vlc_mutex_t *p_mutex )
...
@@ -235,23 +237,6 @@ int vlc_mutex_init( vlc_mutex_t *p_mutex )
p_mutex
->
init
=
9999
;
p_mutex
->
init
=
9999
;
return
B_OK
;
return
B_OK
;
#elif defined( LIBVLC_USE_PTHREAD )
pthread_mutexattr_t
attr
;
int
i_result
;
pthread_mutexattr_init
(
&
attr
);
# ifndef NDEBUG
/* Create error-checking mutex to detect problems more easily. */
# if defined(SYS_LINUX)
pthread_mutexattr_setkind_np
(
&
attr
,
PTHREAD_MUTEX_ERRORCHECK_NP
);
# else
pthread_mutexattr_settype
(
&
attr
,
PTHREAD_MUTEX_ERRORCHECK
);
# endif
# endif
i_result
=
pthread_mutex_init
(
p_mutex
,
&
attr
);
pthread_mutexattr_destroy
(
&
attr
);
return
i_result
;
#endif
#endif
}
}
...
@@ -260,11 +245,7 @@ int vlc_mutex_init( vlc_mutex_t *p_mutex )
...
@@ -260,11 +245,7 @@ int vlc_mutex_init( vlc_mutex_t *p_mutex )
*****************************************************************************/
*****************************************************************************/
int
vlc_mutex_init_recursive
(
vlc_mutex_t
*
p_mutex
)
int
vlc_mutex_init_recursive
(
vlc_mutex_t
*
p_mutex
)
{
{
#if defined( WIN32 )
#if defined( LIBVLC_USE_PTHREAD )
/* Create mutex returns a recursive mutex */
*
p_mutex
=
CreateMutex
(
0
,
FALSE
,
0
);
return
(
*
p_mutex
!=
NULL
)
?
0
:
ENOMEM
;
#elif defined( LIBVLC_USE_PTHREAD )
pthread_mutexattr_t
attr
;
pthread_mutexattr_t
attr
;
int
i_result
;
int
i_result
;
...
@@ -273,6 +254,10 @@ int vlc_mutex_init_recursive( vlc_mutex_t *p_mutex )
...
@@ -273,6 +254,10 @@ int vlc_mutex_init_recursive( vlc_mutex_t *p_mutex )
i_result
=
pthread_mutex_init
(
p_mutex
,
&
attr
);
i_result
=
pthread_mutex_init
(
p_mutex
,
&
attr
);
pthread_mutexattr_destroy
(
&
attr
);
pthread_mutexattr_destroy
(
&
attr
);
return
(
i_result
);
return
(
i_result
);
#elif defined( WIN32 )
/* Create mutex returns a recursive mutex */
*
p_mutex
=
CreateMutex
(
0
,
FALSE
,
0
);
return
(
*
p_mutex
!=
NULL
)
?
0
:
ENOMEM
;
#else
#else
# error Unimplemented!
# error Unimplemented!
#endif
#endif
...
@@ -284,7 +269,11 @@ int vlc_mutex_init_recursive( vlc_mutex_t *p_mutex )
...
@@ -284,7 +269,11 @@ int vlc_mutex_init_recursive( vlc_mutex_t *p_mutex )
*****************************************************************************/
*****************************************************************************/
void
__vlc_mutex_destroy
(
const
char
*
psz_file
,
int
i_line
,
vlc_mutex_t
*
p_mutex
)
void
__vlc_mutex_destroy
(
const
char
*
psz_file
,
int
i_line
,
vlc_mutex_t
*
p_mutex
)
{
{
#if defined( UNDER_CE )
#if defined( LIBVLC_USE_PTHREAD )
int
val
=
pthread_mutex_destroy
(
p_mutex
);
VLC_THREAD_ASSERT
(
"destroying mutex"
);
#elif defined( UNDER_CE )
VLC_UNUSED
(
psz_file
);
VLC_UNUSED
(
i_line
);
VLC_UNUSED
(
psz_file
);
VLC_UNUSED
(
i_line
);
DeleteCriticalSection
(
&
p_mutex
->
csection
);
DeleteCriticalSection
(
&
p_mutex
->
csection
);
...
@@ -300,10 +289,6 @@ void __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mute
...
@@ -300,10 +289,6 @@ void __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mute
p_mutex
->
init
=
0
;
p_mutex
->
init
=
0
;
#elif defined( LIBVLC_USE_PTHREAD )
int
val
=
pthread_mutex_destroy
(
p_mutex
);
VLC_THREAD_ASSERT
(
"destroying mutex"
);
#endif
#endif
}
}
...
@@ -312,7 +297,28 @@ void __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mute
...
@@ -312,7 +297,28 @@ void __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mute
*****************************************************************************/
*****************************************************************************/
int
__vlc_cond_init
(
vlc_cond_t
*
p_condvar
)
int
__vlc_cond_init
(
vlc_cond_t
*
p_condvar
)
{
{
#if defined( UNDER_CE ) || defined( WIN32 )
#if defined( LIBVLC_USE_PTHREAD )
pthread_condattr_t
attr
;
int
ret
;
ret
=
pthread_condattr_init
(
&
attr
);
if
(
ret
)
return
ret
;
# if !defined (_POSIX_CLOCK_SELECTION)
/* Fairly outdated POSIX support (that was defined in 2001) */
# define _POSIX_CLOCK_SELECTION (-1)
# endif
# if (_POSIX_CLOCK_SELECTION >= 0)
/* NOTE: This must be the same clock as the one in mtime.c */
pthread_condattr_setclock
(
&
attr
,
CLOCK_MONOTONIC
);
# endif
ret
=
pthread_cond_init
(
p_condvar
,
&
attr
);
pthread_condattr_destroy
(
&
attr
);
return
ret
;
#elif defined( UNDER_CE ) || defined( WIN32 )
/* Initialize counter */
/* Initialize counter */
p_condvar
->
i_waiting_threads
=
0
;
p_condvar
->
i_waiting_threads
=
0
;
...
@@ -338,27 +344,6 @@ int __vlc_cond_init( vlc_cond_t *p_condvar )
...
@@ -338,27 +344,6 @@ int __vlc_cond_init( vlc_cond_t *p_condvar )
p_condvar
->
init
=
9999
;
p_condvar
->
init
=
9999
;
return
0
;
return
0
;
#elif defined( LIBVLC_USE_PTHREAD )
pthread_condattr_t
attr
;
int
ret
;
ret
=
pthread_condattr_init
(
&
attr
);
if
(
ret
)
return
ret
;
# if !defined (_POSIX_CLOCK_SELECTION)
/* Fairly outdated POSIX support (that was defined in 2001) */
# define _POSIX_CLOCK_SELECTION (-1)
# endif
# if (_POSIX_CLOCK_SELECTION >= 0)
/* NOTE: This must be the same clock as the one in mtime.c */
pthread_condattr_setclock
(
&
attr
,
CLOCK_MONOTONIC
);
# endif
ret
=
pthread_cond_init
(
p_condvar
,
&
attr
);
pthread_condattr_destroy
(
&
attr
);
return
ret
;
#endif
#endif
}
}
...
@@ -367,7 +352,11 @@ int __vlc_cond_init( vlc_cond_t *p_condvar )
...
@@ -367,7 +352,11 @@ int __vlc_cond_init( vlc_cond_t *p_condvar )
*****************************************************************************/
*****************************************************************************/
void
__vlc_cond_destroy
(
const
char
*
psz_file
,
int
i_line
,
vlc_cond_t
*
p_condvar
)
void
__vlc_cond_destroy
(
const
char
*
psz_file
,
int
i_line
,
vlc_cond_t
*
p_condvar
)
{
{
#if defined( UNDER_CE ) || defined( WIN32 )
#if defined( LIBVLC_USE_PTHREAD )
int
val
=
pthread_cond_destroy
(
p_condvar
);
VLC_THREAD_ASSERT
(
"destroying condition"
);
#elif defined( UNDER_CE ) || defined( WIN32 )
VLC_UNUSED
(
psz_file
);
VLC_UNUSED
(
i_line
);
VLC_UNUSED
(
psz_file
);
VLC_UNUSED
(
i_line
);
CloseHandle
(
p_condvar
->
event
);
CloseHandle
(
p_condvar
->
event
);
...
@@ -375,10 +364,6 @@ void __vlc_cond_destroy( const char * psz_file, int i_line, vlc_cond_t *p_condva
...
@@ -375,10 +364,6 @@ void __vlc_cond_destroy( const char * psz_file, int i_line, vlc_cond_t *p_condva
#elif defined( HAVE_KERNEL_SCHEDULER_H )
#elif defined( HAVE_KERNEL_SCHEDULER_H )
p_condvar
->
init
=
0
;
p_condvar
->
init
=
0
;
#elif defined( LIBVLC_USE_PTHREAD )
int
val
=
pthread_cond_destroy
(
p_condvar
);
VLC_THREAD_ASSERT
(
"destroying condition"
);
#endif
#endif
}
}
...
@@ -389,15 +374,14 @@ int __vlc_threadvar_create( vlc_threadvar_t *p_tls )
...
@@ -389,15 +374,14 @@ int __vlc_threadvar_create( vlc_threadvar_t *p_tls )
{
{
int
i_ret
=
-
1
;
int
i_ret
=
-
1
;
#if defined(
HAVE_KERNEL_SCHEDULER_H
)
#if defined(
LIBVLC_USE_PTHREAD
)
# error Unimplemented!
i_ret
=
pthread_key_create
(
p_tls
,
NULL
);
#elif defined( UNDER_CE )
#elif defined( UNDER_CE )
#elif defined( WIN32 )
#elif defined( WIN32 )
*
p_tls
=
TlsAlloc
();
*
p_tls
=
TlsAlloc
();
i_ret
=
(
*
p_tls
==
INVALID_HANDLE_VALUE
)
?
EAGAIN
:
0
;
i_ret
=
(
*
p_tls
==
INVALID_HANDLE_VALUE
)
?
EAGAIN
:
0
;
#else
#elif defined( LIBVLC_USE_PTHREAD )
# error Unimplemented!
i_ret
=
pthread_key_create
(
p_tls
,
NULL
);
#endif
#endif
return
i_ret
;
return
i_ret
;
}
}
...
@@ -418,7 +402,44 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
...
@@ -418,7 +402,44 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
vlc_mutex_lock
(
&
p_this
->
object_lock
);
vlc_mutex_lock
(
&
p_this
->
object_lock
);
#if defined( WIN32 ) || defined( UNDER_CE )
#if defined( LIBVLC_USE_PTHREAD )
i_ret
=
pthread_create
(
&
p_priv
->
thread_id
,
NULL
,
func
,
p_data
);
#ifndef __APPLE__
if
(
config_GetInt
(
p_this
,
"rt-priority"
)
>
0
)
#endif
{
int
i_error
,
i_policy
;
struct
sched_param
param
;
memset
(
&
param
,
0
,
sizeof
(
struct
sched_param
)
);
if
(
config_GetType
(
p_this
,
"rt-offset"
)
)
i_priority
+=
config_GetInt
(
p_this
,
"rt-offset"
);
if
(
i_priority
<=
0
)
{
param
.
sched_priority
=
(
-
1
)
*
i_priority
;
i_policy
=
SCHED_OTHER
;
}
else
{
param
.
sched_priority
=
i_priority
;
i_policy
=
SCHED_RR
;
}
if
(
(
i_error
=
pthread_setschedparam
(
p_priv
->
thread_id
,
i_policy
,
&
param
))
)
{
errno
=
i_error
;
msg_Warn
(
p_this
,
"couldn't set thread priority (%s:%d): %m"
,
psz_file
,
i_line
);
i_priority
=
0
;
}
}
#ifndef __APPLE__
else
i_priority
=
0
;
#endif
#elif defined( WIN32 ) || defined( UNDER_CE )
{
{
/* When using the MSVCRT C library you have to use the _beginthreadex
/* When using the MSVCRT C library you have to use the _beginthreadex
* function instead of CreateThread, otherwise you'll end up with
* function instead of CreateThread, otherwise you'll end up with
...
@@ -457,47 +478,6 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
...
@@ -457,47 +478,6 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
i_priority
,
p_data
);
i_priority
,
p_data
);
i_ret
=
resume_thread
(
p_priv
->
thread_id
);
i_ret
=
resume_thread
(
p_priv
->
thread_id
);
#elif defined( LIBVLC_USE_PTHREAD )
i_ret
=
pthread_create
(
&
p_priv
->
thread_id
,
NULL
,
func
,
p_data
);
#ifndef __APPLE__
if
(
config_GetInt
(
p_this
,
"rt-priority"
)
)
#endif
{
int
i_error
,
i_policy
;
struct
sched_param
param
;
memset
(
&
param
,
0
,
sizeof
(
struct
sched_param
)
);
if
(
config_GetType
(
p_this
,
"rt-offset"
)
)
{
i_priority
+=
config_GetInt
(
p_this
,
"rt-offset"
);
}
if
(
i_priority
<=
0
)
{
param
.
sched_priority
=
(
-
1
)
*
i_priority
;
i_policy
=
SCHED_OTHER
;
}
else
{
param
.
sched_priority
=
i_priority
;
i_policy
=
SCHED_RR
;
}
if
(
(
i_error
=
pthread_setschedparam
(
p_priv
->
thread_id
,
i_policy
,
&
param
))
)
{
errno
=
i_error
;
msg_Warn
(
p_this
,
"couldn't set thread priority (%s:%d): %m"
,
psz_file
,
i_line
);
i_priority
=
0
;
}
}
#ifndef __APPLE__
else
{
i_priority
=
0
;
}
#endif
#endif
#endif
if
(
i_ret
==
0
)
if
(
i_ret
==
0
)
...
@@ -512,25 +492,22 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
...
@@ -512,25 +492,22 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
#if defined( WIN32 ) || defined( UNDER_CE )
#if defined( WIN32 ) || defined( UNDER_CE )
msg_Dbg
(
p_this
,
"thread %u (%s) created at priority %d (%s:%d)"
,
msg_Dbg
(
p_this
,
"thread %u (%s) created at priority %d (%s:%d)"
,
(
unsigned
int
)
p_priv
->
thread_id
.
id
,
psz_name
,
(
unsigned
int
)
p_priv
->
thread_id
.
id
,
psz_name
,
i_priority
,
i_priority
,
psz_file
,
i_line
);
psz_file
,
i_line
);
#else
#else
msg_Dbg
(
p_this
,
"thread %u (%s) created at priority %d (%s:%d)"
,
msg_Dbg
(
p_this
,
"thread %u (%s) created at priority %d (%s:%d)"
,
(
unsigned
int
)
p_priv
->
thread_id
,
psz_name
,
i_priority
,
(
unsigned
int
)
p_priv
->
thread_id
,
psz_name
,
i_priority
,
psz_file
,
i_line
);
psz_file
,
i_line
);
#endif
#endif
vlc_mutex_unlock
(
&
p_this
->
object_lock
);
}
}
else
else
{
{
errno
=
i_ret
;
errno
=
i_ret
;
msg_Err
(
p_this
,
"%s thread could not be created at %s:%d (%m)"
,
msg_Err
(
p_this
,
"%s thread could not be created at %s:%d (%m)"
,
psz_name
,
psz_file
,
i_line
);
psz_name
,
psz_file
,
i_line
);
vlc_mutex_unlock
(
&
p_this
->
object_lock
);
}
}
vlc_mutex_unlock
(
&
p_this
->
object_lock
);
return
i_ret
;
return
i_ret
;
}
}
...
@@ -542,18 +519,8 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
...
@@ -542,18 +519,8 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
int
i_line
,
int
i_priority
)
int
i_line
,
int
i_priority
)
{
{
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
#if defined( WIN32 ) || defined( UNDER_CE )
VLC_UNUSED
(
psz_file
);
VLC_UNUSED
(
i_line
);
if
(
!
p_priv
->
thread_id
.
hThread
)
#if defined( LIBVLC_USE_PTHREAD )
p_priv
->
thread_id
.
hThread
=
GetCurrentThread
();
if
(
!
SetThreadPriority
(
p_priv
->
thread_id
.
hThread
,
i_priority
)
)
{
msg_Warn
(
p_this
,
"couldn't set a faster priority"
);
return
1
;
}
#elif defined( LIBVLC_USE_PTHREAD )
# ifndef __APPLE__
# ifndef __APPLE__
if
(
config_GetInt
(
p_this
,
"rt-priority"
)
>
0
)
if
(
config_GetInt
(
p_this
,
"rt-priority"
)
>
0
)
# endif
# endif
...
@@ -563,9 +530,7 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
...
@@ -563,9 +530,7 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
memset
(
&
param
,
0
,
sizeof
(
struct
sched_param
)
);
memset
(
&
param
,
0
,
sizeof
(
struct
sched_param
)
);
if
(
config_GetType
(
p_this
,
"rt-offset"
)
)
if
(
config_GetType
(
p_this
,
"rt-offset"
)
)
{
i_priority
+=
config_GetInt
(
p_this
,
"rt-offset"
);
i_priority
+=
config_GetInt
(
p_this
,
"rt-offset"
);
}
if
(
i_priority
<=
0
)
if
(
i_priority
<=
0
)
{
{
param
.
sched_priority
=
(
-
1
)
*
i_priority
;
param
.
sched_priority
=
(
-
1
)
*
i_priority
;
...
@@ -587,6 +552,18 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
...
@@ -587,6 +552,18 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
i_priority
=
0
;
i_priority
=
0
;
}
}
}
}
#elif defined( WIN32 ) || defined( UNDER_CE )
VLC_UNUSED
(
psz_file
);
VLC_UNUSED
(
i_line
);
if
(
!
p_priv
->
thread_id
.
hThread
)
p_priv
->
thread_id
.
hThread
=
GetCurrentThread
();
if
(
!
SetThreadPriority
(
p_priv
->
thread_id
.
hThread
,
i_priority
)
)
{
msg_Warn
(
p_this
,
"couldn't set a faster priority"
);
return
1
;
}
#endif
#endif
return
0
;
return
0
;
...
@@ -606,8 +583,17 @@ void __vlc_thread_ready( vlc_object_t *p_this )
...
@@ -606,8 +583,17 @@ void __vlc_thread_ready( vlc_object_t *p_this )
void
__vlc_thread_join
(
vlc_object_t
*
p_this
,
const
char
*
psz_file
,
int
i_line
)
void
__vlc_thread_join
(
vlc_object_t
*
p_this
,
const
char
*
psz_file
,
int
i_line
)
{
{
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
int
i_ret
=
0
;
#if defined( LIBVLC_USE_PTHREAD )
/* Make sure we do return if we are calling vlc_thread_join()
* from the joined thread */
if
(
pthread_equal
(
pthread_self
(),
p_priv
->
thread_id
))
i_ret
=
pthread_detach
(
p_priv
->
thread_id
);
else
i_ret
=
pthread_join
(
p_priv
->
thread_id
,
NULL
);
#if defined( UNDER_CE ) || defined( WIN32 )
#
el
if defined( UNDER_CE ) || defined( WIN32 )
HMODULE
hmodule
;
HMODULE
hmodule
;
BOOL
(
WINAPI
*
OurGetThreadTimes
)(
HANDLE
,
FILETIME
*
,
FILETIME
*
,
BOOL
(
WINAPI
*
OurGetThreadTimes
)(
HANDLE
,
FILETIME
*
,
FILETIME
*
,
FILETIME
*
,
FILETIME
*
);
FILETIME
*
,
FILETIME
*
);
...
@@ -676,21 +662,10 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line
...
@@ -676,21 +662,10 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line
}
}
CloseHandle
(
hThread
);
CloseHandle
(
hThread
);
#else
/* !defined(WIN32) */
#elif defined( HAVE_KERNEL_SCHEDULER_H )
int
i_ret
=
0
;
#if defined( HAVE_KERNEL_SCHEDULER_H )
int32_t
exit_value
;
int32_t
exit_value
;
i_ret
=
(
B_OK
==
wait_for_thread
(
p_priv
->
thread_id
,
&
exit_value
));
i_ret
=
(
B_OK
==
wait_for_thread
(
p_priv
->
thread_id
,
&
exit_value
));
#elif defined( LIBVLC_USE_PTHREAD )
/* Make sure we do return if we are calling vlc_thread_join()
* from the joined thread */
if
(
pthread_equal
(
pthread_self
(),
p_priv
->
thread_id
))
i_ret
=
pthread_detach
(
p_priv
->
thread_id
);
else
i_ret
=
pthread_join
(
p_priv
->
thread_id
,
NULL
);
#endif
#endif
if
(
i_ret
)
if
(
i_ret
)
...
@@ -700,13 +675,8 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line
...
@@ -700,13 +675,8 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line
(
unsigned
int
)
p_priv
->
thread_id
,
psz_file
,
i_line
);
(
unsigned
int
)
p_priv
->
thread_id
,
psz_file
,
i_line
);
}
}
else
else
{
msg_Dbg
(
p_this
,
"thread %u joined (%s:%d)"
,
msg_Dbg
(
p_this
,
"thread %u joined (%s:%d)"
,
(
unsigned
int
)
p_priv
->
thread_id
,
psz_file
,
i_line
);
(
unsigned
int
)
p_priv
->
thread_id
,
psz_file
,
i_line
);
}
#endif
p_priv
->
b_thread
=
false
;
p_priv
->
b_thread
=
false
;
}
}
Write
Preview
Markdown
is supported
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