[vlc-devel] commit: WinCE: do an ugly thread cancellation without using QueueUserAPC ( Geoffroy Couprie )
Geoffroy Couprie
geo.couprie at gmail.com
Mon Oct 6 11:23:27 CEST 2008
On Mon, Oct 6, 2008 at 11:13 AM, git version control <git at videolan.org> wrote:
> vlc | branch: master | Geoffroy Couprie <geo.couprie at gmail.com> | Mon Oct 6 11:12:59 2008 +0200| [272308b2004fac7f4474a80764c20fd5ba5f13c7] | committer: Geoffroy Couprie
>
> WinCE: do an ugly thread cancellation without using QueueUserAPC
>
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=272308b2004fac7f4474a80764c20fd5ba5f13c7
> ---
>
> src/misc/mtime.c | 2 +-
> src/misc/threads.c | 17 +++++++++++++++++
> 2 files changed, 18 insertions(+), 1 deletions(-)
>
> diff --git a/src/misc/mtime.c b/src/misc/mtime.c
> index c9248ae..c5b1bc2 100644
> --- a/src/misc/mtime.c
> +++ b/src/misc/mtime.c
> @@ -53,7 +53,7 @@
> #endif
>
> #if defined( UNDER_CE )
> -# include <windows.h>
> +# define SleepEx(a,b) Sleep(a)
> #endif
>
> #if defined(HAVE_SYS_TIME_H)
> diff --git a/src/misc/threads.c b/src/misc/threads.c
> index 19f4ded..e1d6255 100644
> --- a/src/misc/threads.c
> +++ b/src/misc/threads.c
> @@ -49,6 +49,10 @@ static vlc_threadvar_t cancel_key;
> # include <execinfo.h>
> #endif
>
> +#ifdef UNDER_CE
> +# define WaitForSingleObjectEx(a,b,c) WaitForSingleObject(a,b)
> +#endif
> +
> /**
> * Print a backtrace to the standard error for debugging purpose.
> */
> @@ -689,6 +693,19 @@ void vlc_cancel (vlc_thread_t thread_id)
> {
> #if defined (LIBVLC_USE_PTHREAD_CANCEL)
> pthread_cancel (thread_id);
> +#elif defined (UNDER_CE)
> + /* HACK:There is no way to use something
> + * like QueueUserAPC on Windows CE, so I rely
> + * on some crappy arch specific code */
> + CONTEXT context;
> + context.ContextFlags = CONTEXT_CONTROL;
> + GetThreadContext (thread_id->handle, &context);
> + /* Setting the instruction pointer for the canceled thread */
> +#if defined(_ARM_) || defined(ARM)
> + context.Pc = (DWORD_PTR) vlc_cancel_self;
> +#endif
> + SetThreadContext (thread_id->handle, &context);
> +
> #elif defined (WIN32)
> QueueUserAPC (vlc_cancel_self, thread_id->handle, 0);
> #else
>
mmh, looks like it won't work. I'll change it later.
More information about the vlc-devel
mailing list