Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
9a719ad0
Commit
9a719ad0
authored
May 08, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Win32 compile fixes
parent
707279b4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
60 deletions
+36
-60
include/vlc_common.h
include/vlc_common.h
+1
-1
include/vlc_threads.h
include/vlc_threads.h
+12
-21
src/misc/threads.c
src/misc/threads.c
+23
-38
No files found.
include/vlc_common.h
View file @
9a719ad0
...
...
@@ -443,6 +443,7 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *, /* variable's object */
# endif
#endif
#include "vlc_mtime.h"
#include "vlc_threads.h"
typedef
struct
vlc_object_internals_t
vlc_object_internals_t
;
...
...
@@ -929,7 +930,6 @@ VLC_EXPORT( const char *, VLC_Changeset, ( void ) );
#include "vlc_messages.h"
#include "vlc_variables.h"
#include "vlc_objects.h"
#include "vlc_mtime.h"
#include "vlc_modules.h"
#include "vlc_main.h"
#include "vlc_configuration.h"
...
...
include/vlc_threads.h
View file @
9a719ad0
...
...
@@ -119,16 +119,7 @@ typedef pthread_cond_t vlc_cond_t;
typedef
pthread_key_t
vlc_threadvar_t
;
#elif defined( WIN32 ) || defined( UNDER_CE )
typedef
struct
{
/* thread id */
DWORD
id
;
/*
** handle to created thread, needs be closed to dispose of it
** even after thread has exited
*/
HANDLE
hThread
;
}
vlc_thread_t
;
typedef
HANDLE
vlc_thread_t
;
typedef
BOOL
(
WINAPI
*
SIGNALOBJECTANDWAIT
)
(
HANDLE
,
HANDLE
,
DWORD
,
BOOL
);
...
...
@@ -211,12 +202,12 @@ static inline void __vlc_mutex_lock( const char * psz_file, int i_line,
VLC_THREAD_ASSERT
(
"locking mutex"
);
#elif defined( UNDER_CE )
VLC_UNUSED
(
psz_file
);
VLC_UNUSED
(
i_line
)
;
(
void
)
psz_file
;
(
void
)
i_line
;
EnterCriticalSection
(
&
p_mutex
->
csection
);
#elif defined( WIN32 )
VLC_UNUSED
(
psz_file
);
VLC_UNUSED
(
i_line
)
;
(
void
)
psz_file
;
(
void
)
i_line
;
WaitForSingleObject
(
*
p_mutex
,
INFINITE
);
...
...
@@ -244,12 +235,12 @@ static inline void __vlc_mutex_unlock( const char * psz_file, int i_line,
VLC_THREAD_ASSERT
(
"unlocking mutex"
);
#elif defined( UNDER_CE )
VLC_UNUSED
(
psz_file
);
VLC_UNUSED
(
i_line
)
;
(
void
)
psz_file
);
(
void
)
i_line
;
LeaveCriticalSection
(
&
p_mutex
->
csection
);
#elif defined( WIN32 )
VLC_UNUSED
(
psz_file
);
VLC_UNUSED
(
i_line
)
;
(
void
)
psz_file
;
(
void
)
i_line
;
ReleaseMutex
(
*
p_mutex
);
...
...
@@ -285,7 +276,7 @@ static inline void __vlc_cond_signal( const char * psz_file, int i_line,
VLC_THREAD_ASSERT
(
"signaling condition variable"
);
#elif defined( UNDER_CE ) || defined( WIN32 )
VLC_UNUSED
(
psz_file
);
VLC_UNUSED
(
i_line
)
;
(
void
)
psz_file
;
(
void
)
i_line
;
/* Release one waiting thread if one is available. */
/* For this trick to work properly, the vlc_cond_signal must be surrounded
...
...
@@ -343,7 +334,7 @@ static inline void __vlc_cond_wait( const char * psz_file, int i_line,
vlc_mutex_lock
(
p_mutex
);
#elif defined( WIN32 )
VLC_UNUSED
(
psz_file
);
VLC_UNUSED
(
i_line
)
;
(
void
)
psz_file
;
(
void
)
i_line
;
/* Increase our wait count */
p_condvar
->
i_waiting_threads
++
;
...
...
@@ -392,7 +383,6 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
#elif defined( UNDER_CE )
mtime_t
delay_ms
=
(
deadline
-
mdate
())
/
1000
;
DWORD
result
;
if
(
delay_ms
<
0
)
delay_ms
=
0
;
...
...
@@ -408,12 +398,11 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
if
(
result
==
WAIT_TIMEOUT
)
return
ETIMEDOUT
;
/* this error is perfectly normal */
#elif defined( WIN32 )
VLC_UNUSED
(
psz_file
);
VLC_UNUSED
(
i_line
);
DWORD
result
;
(
void
)
psz_file
;
(
void
)
i_line
;
#elif defined( WIN32 )
mtime_t
delay_ms
=
(
deadline
-
mdate
())
/
1000
;
DWORD
result
;
if
(
delay_ms
<
0
)
delay_ms
=
0
;
...
...
@@ -428,6 +417,8 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
if
(
result
==
WAIT_TIMEOUT
)
return
ETIMEDOUT
;
/* this error is perfectly normal */
(
void
)
psz_file
;
(
void
)
i_line
;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
# error Unimplemented
...
...
src/misc/threads.c
View file @
9a719ad0
...
...
@@ -383,7 +383,7 @@ int __vlc_threadvar_create( vlc_threadvar_t *p_tls )
#elif defined( UNDER_CE )
#elif defined( WIN32 )
*
p_tls
=
TlsAlloc
();
i_ret
=
(
*
p_tls
==
INVALID_HANDLE_VALUE
)
?
EAGAIN
:
0
;
i_ret
=
(
*
p_tls
==
TLS_OUT_OF_INDEXES
)
?
EAGAIN
:
0
;
#else
# error Unimplemented!
#endif
...
...
@@ -450,27 +450,23 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
* memory leaks and the signal functions not working (see Microsoft
* Knowledge Base, article 104641) */
#if defined( UNDER_CE )
DWORD
threadId
;
HANDLE
hThread
=
CreateThread
(
NULL
,
0
,
(
LPTHREAD_START_ROUTINE
)
func
,
(
LPVOID
)
p_data
,
CREATE_SUSPENDED
,
&
threadId
);
(
LPVOID
)
p_data
,
CREATE_SUSPENDED
,
NULL
);
#else
unsigned
threadId
;
uintptr_t
hThread
=
_beginthreadex
(
NULL
,
0
,
(
LPTHREAD_START_ROUTINE
)
func
,
(
void
*
)
p_data
,
CREATE_SUSPENDED
,
&
threadId
);
HANDLE
hThread
=
(
HANDLE
)(
uintptr_t
)
_beginthreadex
(
NULL
,
0
,
(
LPTHREAD_START_ROUTINE
)
func
,
(
void
*
)
p_data
,
CREATE_SUSPENDED
,
NULL
);
#endif
p_priv
->
thread_id
.
id
=
(
DWORD
)
threadId
;
p_priv
->
thread_id
.
hThread
=
(
HANDLE
)
hThread
;
ResumeThread
((
HANDLE
)
hThread
);
p_priv
->
thread_id
=
hThread
;
ResumeThread
(
hThread
);
}
i_ret
=
(
p_priv
->
thread_id
.
hThread
?
0
:
1
);
i_ret
=
(
p_priv
->
thread_id
?
0
:
errno
);
if
(
!
i_ret
&&
i_priority
)
{
if
(
!
SetThreadPriority
(
p_priv
->
thread_id
.
hThread
,
i_priority
)
)
if
(
!
SetThreadPriority
(
p_priv
->
thread_id
,
i_priority
)
)
{
msg_Warn
(
p_this
,
"couldn't set a faster priority"
);
i_priority
=
0
;
...
...
@@ -493,16 +489,9 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
}
p_priv
->
b_thread
=
true
;
#if defined( WIN32 ) || defined( UNDER_CE )
msg_Dbg
(
p_this
,
"thread %u (%s) created at priority %d (%s:%d)"
,
(
unsigned
int
)
p_priv
->
thread_id
.
id
,
psz_name
,
i_priority
,
psz_file
,
i_line
);
#else
msg_Dbg
(
p_this
,
"thread %u (%s) created at priority %d (%s:%d)"
,
(
unsigned
int
)
p_priv
->
thread_id
,
psz_name
,
i_priority
,
msg_Dbg
(
p_this
,
"thread %lu (%s) created at priority %d (%s:%d)"
,
(
unsigned
long
)
p_priv
->
thread_id
,
psz_name
,
i_priority
,
psz_file
,
i_line
);
#endif
}
else
{
...
...
@@ -560,9 +549,9 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
#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
)
)
if
(
!
p_priv
->
thread_id
)
p_priv
->
thread_id
=
GetCurrentThread
();
if
(
!
SetThreadPriority
(
p_priv
->
thread_id
,
i_priority
)
)
{
msg_Warn
(
p_this
,
"couldn't set a faster priority"
);
return
1
;
...
...
@@ -610,25 +599,20 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line
** to be on the safe side
*/
if
(
!
DuplicateHandle
(
GetCurrentProcess
(),
p_priv
->
thread_id
.
hThread
,
p_priv
->
thread_id
,
GetCurrentProcess
(),
&
hThread
,
0
,
FALSE
,
DUPLICATE_SAME_ACCESS
)
)
{
msg_Err
(
p_this
,
"thread_join(%u) failed at %s:%d (%u)"
,
(
unsigned
int
)
p_priv
->
thread_id
.
id
,
psz_file
,
i_line
,
(
unsigned
int
)
GetLastError
()
);
p_priv
->
b_thread
=
false
;
return
;
i_ret
=
GetLastError
();
goto
error
;
}
WaitForSingleObject
(
hThread
,
INFINITE
);
msg_Dbg
(
p_this
,
"thread %u joined (%s:%d)"
,
(
unsigned
int
)
p_priv
->
thread_id
.
id
,
psz_file
,
i_line
);
#if defined( UNDER_CE )
hmodule
=
GetModuleHandle
(
_T
(
"COREDLL"
)
);
#else
...
...
@@ -665,6 +649,7 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line
(
double
)((
user_time
%
(
60
*
1000000
))
/
1000000
.
0
)
);
}
CloseHandle
(
hThread
);
error:
#elif defined( HAVE_KERNEL_SCHEDULER_H )
int32_t
exit_value
;
...
...
@@ -675,12 +660,12 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line
if
(
i_ret
)
{
errno
=
i_ret
;
msg_Err
(
p_this
,
"thread_join(%u) failed at %s:%d (%m)"
,
(
unsigned
int
)
p_priv
->
thread_id
,
psz_file
,
i_line
);
msg_Err
(
p_this
,
"thread_join(%
l
u) failed at %s:%d (%m)"
,
(
unsigned
long
)
p_priv
->
thread_id
,
psz_file
,
i_line
);
}
else
msg_Dbg
(
p_this
,
"thread %u joined (%s:%d)"
,
(
unsigned
int
)
p_priv
->
thread_id
,
psz_file
,
i_line
);
msg_Dbg
(
p_this
,
"thread %
l
u joined (%s:%d)"
,
(
unsigned
long
)
p_priv
->
thread_id
,
psz_file
,
i_line
);
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