]> git.sesse.net Git - vlc/blobdiff - src/misc/variables.c
var_GetGlobalMutex() creates and gets a global mutex
[vlc] / src / misc / variables.c
index 8abba518c41d0c5ca026cd2a8f60b6e0aba0e11b..a20d3359e55a8f92267b7fadb1ec78a8bd6a557e 100644 (file)
@@ -828,6 +828,23 @@ int __var_Get( vlc_object_t *p_this, const char *psz_name, vlc_value_t *p_val )
     return VLC_SUCCESS;
 }
 
+
+/**
+ * Gets a process-wide mutex, creates it if needed.
+ */
+vlc_mutex_t *var_GetGlobalMutex( const char *name )
+{
+    libvlc_global_data_t *p_global = vlc_global_object();
+    vlc_value_t val;
+
+    if( var_Create( p_global, name, VLC_VAR_MUTEX ) )
+        return NULL;
+
+    var_Get( p_global, &val );
+    return val.p_lockval;
+}
+
+
 /**
  * Register a callback in a variable
  *