]> git.sesse.net Git - vlc/commitdiff
WinCE: do an ugly thread cancellation without using QueueUserAPC
authorGeoffroy Couprie <geo.couprie@gmail.com>
Mon, 6 Oct 2008 09:12:59 +0000 (11:12 +0200)
committerGeoffroy Couprie <geo.couprie@gmail.com>
Mon, 6 Oct 2008 09:13:17 +0000 (11:13 +0200)
src/misc/mtime.c
src/misc/threads.c

index c9248ae8f585b9fe26a92ae345387cdb6be26df0..c5b1bc22346a92d9117c76469b2aedc1d7381860 100644 (file)
@@ -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)
index 19f4ded3e0a38c5bef1019f513c31d9b746a030d..e1d6255b880316e464619defce6d61ccd3ebf7a4 100644 (file)
@@ -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