]> git.sesse.net Git - vlc/blobdiff - src/misc/threads.c
Remove vlc_global()
[vlc] / src / misc / threads.c
index 6d2984547cf3e5cf056bff6edd23129ee13b6999..3a784a093e0ef11a7c906e10bfb203039a11670c 100644 (file)
 #endif
 #include <signal.h>
 
-#define VLC_THREADS_UNINITIALIZED  0
-#define VLC_THREADS_PENDING        1
-#define VLC_THREADS_ERROR          2
-#define VLC_THREADS_READY          3
-
 /*****************************************************************************
  * Global mutex for lazy initialization of the threads system
  *****************************************************************************/
@@ -59,15 +54,10 @@ static vlc_threadvar_t cancel_key;
 
 /**
  * Global process-wide VLC object.
- * Contains inter-instance data, such as the module cache and global mutexes.
+ * Contains the global named mutexes.
+ * TODO: remove it.
  */
-static libvlc_global_data_t *p_root;
-
-libvlc_global_data_t *vlc_global( void )
-{
-    assert( i_initializations > 0 );
-    return p_root;
-}
+static vlc_object_t *p_root;
 
 #ifdef HAVE_EXECINFO_H
 # include <execinfo.h>
@@ -124,7 +114,7 @@ vlc_thread_fatal (const char *action, int error,
 #ifdef __GLIBC__
     /* Avoid the strerror_r() prototype brain damage in glibc */
     errno = error;
-    fprintf (stderr, " Error message: %m at:\n");
+    fprintf (stderr, " Error message: %m\n");
 #elif !defined (WIN32)
     char buf[1000];
     const char *msg;
@@ -1114,3 +1104,21 @@ void vlc_control_cancel (int cmd, ...)
     va_end (ap);
 #endif
 }
+
+
+#undef var_AcquireMutex
+/**
+ * Finds a process-wide mutex, creates it if needed, and locks it.
+ * Unlock with vlc_mutex_unlock().
+ */
+vlc_mutex_t *var_AcquireMutex( const char *name )
+{
+    vlc_value_t val;
+
+    if( var_Create( p_root, name, VLC_VAR_MUTEX ) )
+        return NULL;
+
+    var_Get( p_root, name, &val );
+    vlc_mutex_lock( val.p_address );
+    return val.p_address;
+}