]> git.sesse.net Git - vlc/blobdiff - include/vlc_threads.h
Revert "dejidjei:"
[vlc] / include / vlc_threads.h
index 9cd09408b581ec0f14a7d34fb2dbdf4d3833a00f..2ce2302b7211a0b5ef38ef8a7955cc3de375606c 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#if !defined( __LIBVLC__ )
-  #error You are not libvlc or one of its plugins. You cannot include this file
-#endif
-
 #ifndef _VLC_THREADS_H_
 #define _VLC_THREADS_H_
 
 
 /* Thread priorities */
 #ifdef __APPLE__
-#   define VLC_THREAD_PRIORITY_LOW (-47)
-#   define VLC_THREAD_PRIORITY_INPUT 37
-#   define VLC_THREAD_PRIORITY_AUDIO 37
-#   define VLC_THREAD_PRIORITY_VIDEO (-47)
-#   define VLC_THREAD_PRIORITY_OUTPUT 37
-#   define VLC_THREAD_PRIORITY_HIGHEST 37
+#   define VLC_THREAD_PRIORITY_LOW      0
+#   define VLC_THREAD_PRIORITY_INPUT   22
+#   define VLC_THREAD_PRIORITY_AUDIO   22
+#   define VLC_THREAD_PRIORITY_VIDEO    0
+#   define VLC_THREAD_PRIORITY_OUTPUT  22
+#   define VLC_THREAD_PRIORITY_HIGHEST 22
 
 #elif defined(SYS_BEOS)
 #   define VLC_THREAD_PRIORITY_LOW 5
@@ -563,6 +559,31 @@ static inline int vlc_spin_init (vlc_spinlock_t *spin)
 # define vlc_spin_destroy vlc_mutex_destroy
 #endif
 
+/**
+ * Issues a full memory barrier.
+ */
+#if defined (__APPLE__)
+# include <libkern/OSAtomic.h> /* OSMemoryBarrier() */
+#endif
+static inline void barrier (void)
+{
+#if defined (__GNUC__) && (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
+    __sync_synchronize ();
+#elif defined(__APPLE__)
+    OSMemoryBarrier ();
+#elif defined(__powerpc__)
+    asm volatile ("sync":::"memory");
+#elif defined(__i386__)
+    asm volatile ("mfence":::"memory");
+#elif defined (LIBVLC_USE_PTHREAD)
+    static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+    pthread_mutex_lock (&lock);
+    pthread_mutex_unlock (&lock);
+#else
+# error barrier not implemented!
+#endif
+}
+
 /*****************************************************************************
  * vlc_thread_create: create a thread
  *****************************************************************************/