Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC
Manage
Activity
Members
Labels
Plan
Issues
4k
Issue boards
Milestones
Code
Merge requests
455
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC
Commits
59f77831
Commit
59f77831
authored
9 years ago
by
Rémi Denis-Courmont
Browse files
Options
Downloads
Patches
Plain Diff
threads: reorder code
(No functional changes)
parent
74337dd2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/vlc_threads.h
+63
-51
63 additions, 51 deletions
include/vlc_threads.h
with
63 additions
and
51 deletions
include/vlc_threads.h
+
63
−
51
View file @
59f77831
...
...
@@ -34,6 +34,10 @@
*
*/
VLC_API
int
vlc_savecancel
(
void
);
VLC_API
void
vlc_restorecancel
(
int
state
);
VLC_API
void
vlc_testcancel
(
void
);
#if defined (_WIN32)
# include <process.h>
# ifndef ETIMEDOUT
...
...
@@ -73,6 +77,25 @@ typedef struct vlc_timer *vlc_timer_t;
# define VLC_THREAD_PRIORITY_OUTPUT THREAD_PRIORITY_ABOVE_NORMAL
# define VLC_THREAD_PRIORITY_HIGHEST THREAD_PRIORITY_TIME_CRITICAL
static
inline
int
vlc_poll
(
struct
pollfd
*
fds
,
unsigned
nfds
,
int
timeout
)
{
int
val
;
do
{
int
ugly_timeout
=
((
unsigned
)
timeout
>=
50
)
?
50
:
timeout
;
if
(
timeout
>=
0
)
timeout
-=
ugly_timeout
;
vlc_testcancel
();
val
=
poll
(
fds
,
nfds
,
ugly_timeout
);
}
while
(
val
==
0
&&
timeout
!=
0
);
return
val
;
}
# define poll(u,n,t) vlc_poll(u, n, t)
#elif defined (__OS2__)
# include <errno.h>
...
...
@@ -113,6 +136,26 @@ typedef struct vlc_timer *vlc_timer_t;
# define pthread_sigmask sigprocmask
static
inline
int
vlc_poll
(
struct
pollfd
*
fds
,
unsigned
nfds
,
int
timeout
)
{
static
int
(
*
vlc_poll_os2
)(
struct
pollfd
*
,
unsigned
,
int
)
=
NULL
;
if
(
!
vlc_poll_os2
)
{
HMODULE
hmod
;
CHAR
szFailed
[
CCHMAXPATH
];
if
(
DosLoadModule
(
szFailed
,
sizeof
(
szFailed
),
"vlccore"
,
&
hmod
))
return
-
1
;
if
(
DosQueryProcAddr
(
hmod
,
0
,
"_vlc_poll_os2"
,
(
PFN
*
)
&
vlc_poll_os2
))
return
-
1
;
}
return
(
*
vlc_poll_os2
)(
fds
,
nfds
,
timeout
);
}
# define poll(u,n,t) vlc_poll(u, n, t)
#elif defined (__ANDROID__)
/* pthreads subset without pthread_cancel() */
# include <unistd.h>
# include <pthread.h>
...
...
@@ -141,6 +184,26 @@ typedef struct vlc_timer *vlc_timer_t;
# define VLC_THREAD_PRIORITY_OUTPUT 0
# define VLC_THREAD_PRIORITY_HIGHEST 0
static
inline
int
vlc_poll
(
struct
pollfd
*
fds
,
unsigned
nfds
,
int
timeout
)
{
int
val
;
do
{
int
ugly_timeout
=
((
unsigned
)
timeout
>=
50
)
?
50
:
timeout
;
if
(
timeout
>=
0
)
timeout
-=
ugly_timeout
;
vlc_testcancel
();
val
=
poll
(
fds
,
nfds
,
ugly_timeout
);
}
while
(
val
==
0
&&
timeout
!=
0
);
return
val
;
}
# define poll(u,n,t) vlc_poll(u, n, t)
#elif defined (__APPLE__)
# define _APPLE_C_SOURCE 1
/* Proper pthread semantics on OSX */
# include <unistd.h>
...
...
@@ -150,7 +213,6 @@ typedef struct vlc_timer *vlc_timer_t;
# include <mach/task.h>
# define LIBVLC_USE_PTHREAD 1
# define LIBVLC_USE_PTHREAD_CLEANUP 1
# define LIBVLC_USE_PTHREAD_CANCEL 1
typedef
pthread_t
vlc_thread_t
;
typedef
pthread_mutex_t
vlc_mutex_t
;
...
...
@@ -180,7 +242,6 @@ typedef struct vlc_timer *vlc_timer_t;
# include <semaphore.h>
# define LIBVLC_USE_PTHREAD 1
# define LIBVLC_USE_PTHREAD_CLEANUP 1
# define LIBVLC_USE_PTHREAD_CANCEL 1
typedef
pthread_t
vlc_thread_t
;
typedef
pthread_mutex_t
vlc_mutex_t
;
...
...
@@ -324,10 +385,6 @@ VLC_API unsigned vlc_timer_getoverrun(vlc_timer_t) VLC_USED;
VLC_API
unsigned
vlc_GetCPUCount
(
void
);
VLC_API
int
vlc_savecancel
(
void
);
VLC_API
void
vlc_restorecancel
(
int
state
);
VLC_API
void
vlc_testcancel
(
void
);
#if defined (LIBVLC_USE_PTHREAD_CLEANUP)
/**
* Registers a new procedure to run if the thread is cancelled (or otherwise
...
...
@@ -388,51 +445,6 @@ struct vlc_cleanup_t
#endif
/* !LIBVLC_USE_PTHREAD_CLEANUP */
#ifndef LIBVLC_USE_PTHREAD_CANCEL
/* poll() with cancellation */
# ifdef __OS2__
static
inline
int
vlc_poll
(
struct
pollfd
*
fds
,
unsigned
nfds
,
int
timeout
)
{
static
int
(
*
vlc_poll_os2
)(
struct
pollfd
*
,
unsigned
,
int
)
=
NULL
;
if
(
!
vlc_poll_os2
)
{
HMODULE
hmod
;
CHAR
szFailed
[
CCHMAXPATH
];
if
(
DosLoadModule
(
szFailed
,
sizeof
(
szFailed
),
"vlccore"
,
&
hmod
))
return
-
1
;
if
(
DosQueryProcAddr
(
hmod
,
0
,
"_vlc_poll_os2"
,
(
PFN
*
)
&
vlc_poll_os2
))
return
-
1
;
}
return
(
*
vlc_poll_os2
)(
fds
,
nfds
,
timeout
);
}
# else
static
inline
int
vlc_poll
(
struct
pollfd
*
fds
,
unsigned
nfds
,
int
timeout
)
{
int
val
;
do
{
int
ugly_timeout
=
((
unsigned
)
timeout
>=
50
)
?
50
:
timeout
;
if
(
timeout
>=
0
)
timeout
-=
ugly_timeout
;
vlc_testcancel
();
val
=
poll
(
fds
,
nfds
,
ugly_timeout
);
}
while
(
val
==
0
&&
timeout
!=
0
);
return
val
;
}
# endif
# define poll(u,n,t) vlc_poll(u, n, t)
#endif
/* LIBVLC_USE_PTHREAD_CANCEL */
static
inline
void
vlc_cleanup_lock
(
void
*
lock
)
{
vlc_mutex_unlock
((
vlc_mutex_t
*
)
lock
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment