Commit 4a742a33 authored by Rafaël Carré's avatar Rafaël Carré

android: threads support

parent 314fd505
...@@ -42,6 +42,15 @@ ...@@ -42,6 +42,15 @@
# define pthread_sigmask sigprocmask # define pthread_sigmask sigprocmask
#elif defined( __ANDROID__ ) /* pthreads subset without pthread_cancel() */
# define LIBVLC_NEED_SEMAPHORE
# define LIBVLC_NEED_RWLOCK
# include <unistd.h> /* _POSIX_SPIN_LOCKS */
# include <pthread.h>
# include <poll.h>
#else /* pthreads (like Linux & BSD) */ #else /* pthreads (like Linux & BSD) */
# define LIBVLC_USE_PTHREAD 1 # define LIBVLC_USE_PTHREAD 1
# define LIBVLC_USE_PTHREAD_CANCEL 1 # define LIBVLC_USE_PTHREAD_CANCEL 1
...@@ -73,7 +82,7 @@ ...@@ -73,7 +82,7 @@
# define VLC_THREAD_PRIORITY_OUTPUT 22 # define VLC_THREAD_PRIORITY_OUTPUT 22
# define VLC_THREAD_PRIORITY_HIGHEST 22 # define VLC_THREAD_PRIORITY_HIGHEST 22
#elif defined(LIBVLC_USE_PTHREAD) #elif defined(LIBVLC_USE_PTHREAD) || defined(__ANDROID__)
# define VLC_THREAD_PRIORITY_LOW 0 # define VLC_THREAD_PRIORITY_LOW 0
# define VLC_THREAD_PRIORITY_INPUT 10 # define VLC_THREAD_PRIORITY_INPUT 10
# define VLC_THREAD_PRIORITY_AUDIO 5 # define VLC_THREAD_PRIORITY_AUDIO 5
...@@ -116,7 +125,17 @@ ...@@ -116,7 +125,17 @@
* Type definitions * Type definitions
*****************************************************************************/ *****************************************************************************/
#if defined (LIBVLC_USE_PTHREAD) #if defined (__ANDROID__)
typedef struct vlc_thread *vlc_thread_t;
typedef pthread_mutex_t vlc_mutex_t;
#define VLC_STATIC_MUTEX PTHREAD_MUTEX_INITIALIZER
typedef pthread_cond_t vlc_cond_t;
#define VLC_STATIC_COND PTHREAD_COND_INITIALIZER
typedef pthread_key_t vlc_threadvar_t;
typedef struct vlc_timer *vlc_timer_t;
#elif defined (LIBVLC_USE_PTHREAD)
typedef pthread_t vlc_thread_t; typedef pthread_t vlc_thread_t;
typedef pthread_mutex_t vlc_mutex_t; typedef pthread_mutex_t vlc_mutex_t;
#define VLC_STATIC_MUTEX PTHREAD_MUTEX_INITIALIZER #define VLC_STATIC_MUTEX PTHREAD_MUTEX_INITIALIZER
...@@ -332,7 +351,7 @@ VLC_API int vlc_savecancel(void); ...@@ -332,7 +351,7 @@ VLC_API int vlc_savecancel(void);
VLC_API void vlc_restorecancel(int state); VLC_API void vlc_restorecancel(int state);
VLC_API void vlc_testcancel(void); VLC_API void vlc_testcancel(void);
#if defined (LIBVLC_USE_PTHREAD_CANCEL) #if defined (LIBVLC_USE_PTHREAD_CANCEL) || defined(__ANDROID__)
/** /**
* Registers a new procedure to run if the thread is cancelled (or otherwise * Registers a new procedure to run if the thread is cancelled (or otherwise
* exits prematurely). Any call to vlc_cleanup_push() <b>must</b> paired with a * exits prematurely). Any call to vlc_cleanup_push() <b>must</b> paired with a
...@@ -383,7 +402,9 @@ struct vlc_cleanup_t ...@@ -383,7 +402,9 @@ struct vlc_cleanup_t
vlc_control_cancel (VLC_CLEANUP_POP); \ vlc_control_cancel (VLC_CLEANUP_POP); \
vlc_cleanup_data.proc (vlc_cleanup_data.data); \ vlc_cleanup_data.proc (vlc_cleanup_data.data); \
} while (0) } while (0)
#endif /* LIBVLC_USE_PTHREAD_CANCEL || __ANDROID__ */
#if !defined (LIBVLC_USE_PTHREAD_CANCEL)
/* poll() with cancellation */ /* poll() with cancellation */
static inline int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout) static inline int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
{ {
......
...@@ -259,9 +259,9 @@ SOURCES_libvlc_darwin = \ ...@@ -259,9 +259,9 @@ SOURCES_libvlc_darwin = \
SOURCES_libvlc_android = \ SOURCES_libvlc_android = \
android/dirs.c \ android/dirs.c \
android/thread.c \
posix/filesystem.c \ posix/filesystem.c \
posix/plugin.c \ posix/plugin.c \
posix/thread.c \
posix/timer.c \ posix/timer.c \
posix/linux_cpu.c \ posix/linux_cpu.c \
posix/linux_specific.c \ posix/linux_specific.c \
......
This diff is collapsed.
...@@ -66,7 +66,7 @@ void vlc_threads_setup (libvlc_int_t *); ...@@ -66,7 +66,7 @@ void vlc_threads_setup (libvlc_int_t *);
void vlc_trace (const char *fn, const char *file, unsigned line); void vlc_trace (const char *fn, const char *file, unsigned line);
#define vlc_backtrace() vlc_trace(__func__, __FILE__, __LINE__) #define vlc_backtrace() vlc_trace(__func__, __FILE__, __LINE__)
#if defined (LIBVLC_USE_PTHREAD) && !defined (NDEBUG) #if (defined (LIBVLC_USE_PTHREAD) || defined(__ANDROID__)) && !defined (NDEBUG)
void vlc_assert_locked (vlc_mutex_t *); void vlc_assert_locked (vlc_mutex_t *);
#else #else
# define vlc_assert_locked( m ) (void)m # define vlc_assert_locked( m ) (void)m
......
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