]> git.sesse.net Git - vlc/blobdiff - modules/control/signals.c
Plugins: include vlc_common.h directly instead of vlc/vlc.h
[vlc] / modules / control / signals.c
index c9fd67e492c19095fcbaf8f3d801049572444500..6d9c87e3ff72a0986f10901b41387968abbfe7cc 100644 (file)
@@ -26,7 +26,7 @@
 #include <signal.h>
 #include <time.h>
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_interface.h>
 
@@ -78,6 +78,12 @@ static void Close (vlc_object_t *obj)
     intf_sys_t *p_sys = intf->p_sys;
 
     pthread_cancel (p_sys->thread);
+#ifdef __APPLE__
+   /* In Mac OS X up to 10.5 sigwait (among others) is not a pthread
+    * cancellation point, so we throw a dummy quit signal to end
+    * sigwait() in the sigth thread */
+    pthread_kill (p_sys->thread, SIGQUIT);
+# endif
     pthread_join (p_sys->thread, NULL);
     free (p_sys);
 }
@@ -102,6 +108,12 @@ static void *SigThread (void *data)
 
         sigwait (&set, &signum);
 
+#ifdef __APPLE__
+        /* In Mac OS X up to 10.5 sigwait (among others) is not a pthread
+         * cancellation point */
+        pthread_testcancel();
+#endif
+
         vlc_object_lock (obj);
         p_sys->signum = signum;
         vlc_object_signal_unlocked (obj);
@@ -114,7 +126,7 @@ static void Run (intf_thread_t *obj)
     intf_sys_t *p_sys = obj->p_sys;
 
     vlc_object_lock (obj);
-    do
+    while (vlc_object_alive (obj))
     {
         switch (p_sys->signum)
         {
@@ -126,8 +138,8 @@ static void Run (intf_thread_t *obj)
                          strsignal (p_sys->signum));
                 goto out;
         }
+        vlc_object_wait (obj);
     }
-    while (!vlc_object_wait (obj));
 
 out:
     vlc_object_unlock (obj);