mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
libs: use glib >= 2.32 semantics for mutexes.
Use glib >= 2.32 semantics for GMutex and GRecMutex wrt. initialization and termination. Basically, the new mutex objects can be used as static mutex objects from the deprecated APIs, e.g. GStaticMutex and GStaticRecMutex.
This commit is contained in:
parent
1d669a3e12
commit
97c3b2ddff
4 changed files with 20 additions and 23 deletions
|
@ -725,7 +725,7 @@ gst_vaapi_display_lock_default(GstVaapiDisplay *display)
|
|||
|
||||
if (priv->parent)
|
||||
priv = priv->parent->priv;
|
||||
g_static_rec_mutex_lock(&priv->mutex);
|
||||
g_rec_mutex_lock(&priv->mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -735,7 +735,7 @@ gst_vaapi_display_unlock_default(GstVaapiDisplay *display)
|
|||
|
||||
if (priv->parent)
|
||||
priv = priv->parent->priv;
|
||||
g_static_rec_mutex_unlock(&priv->mutex);
|
||||
g_rec_mutex_unlock(&priv->mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -745,7 +745,7 @@ gst_vaapi_display_finalize(GObject *object)
|
|||
|
||||
gst_vaapi_display_destroy(display);
|
||||
|
||||
g_static_rec_mutex_free(&display->priv->mutex);
|
||||
g_rec_mutex_clear(&display->priv->mutex);
|
||||
|
||||
G_OBJECT_CLASS(gst_vaapi_display_parent_class)->finalize(object);
|
||||
}
|
||||
|
@ -998,7 +998,7 @@ gst_vaapi_display_init(GstVaapiDisplay *display)
|
|||
priv->properties = NULL;
|
||||
priv->create_display = TRUE;
|
||||
|
||||
g_static_rec_mutex_init(&priv->mutex);
|
||||
g_rec_mutex_init(&priv->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -73,7 +73,7 @@ G_BEGIN_DECLS
|
|||
*/
|
||||
struct _GstVaapiDisplayPrivate {
|
||||
GstVaapiDisplay *parent;
|
||||
GStaticRecMutex mutex;
|
||||
GRecMutex mutex;
|
||||
GstVaapiDisplayType display_type;
|
||||
VADisplay display;
|
||||
guint width;
|
||||
|
|
|
@ -33,7 +33,7 @@ struct _CacheEntry {
|
|||
};
|
||||
|
||||
struct _GstVaapiDisplayCache {
|
||||
GStaticMutex mutex;
|
||||
GMutex mutex;
|
||||
GList *list;
|
||||
};
|
||||
|
||||
|
@ -86,14 +86,14 @@ error:
|
|||
#define CACHE_LOOKUP(cache, res, prop, comp_func, comp_data, user_data) do { \
|
||||
GList *l; \
|
||||
\
|
||||
g_static_mutex_lock(&(cache)->mutex); \
|
||||
g_mutex_lock(&(cache)->mutex); \
|
||||
for (l = (cache)->list; l != NULL; l = l->next) { \
|
||||
GstVaapiDisplayInfo * const info = \
|
||||
&((CacheEntry *)l->data)->info; \
|
||||
if (comp_func(info->prop, comp_data, user_data)) \
|
||||
break; \
|
||||
} \
|
||||
g_static_mutex_unlock(&(cache)->mutex); \
|
||||
g_mutex_unlock(&(cache)->mutex); \
|
||||
res = l; \
|
||||
} while (0)
|
||||
|
||||
|
@ -146,7 +146,7 @@ gst_vaapi_display_cache_new(void)
|
|||
if (!cache)
|
||||
return NULL;
|
||||
|
||||
g_static_mutex_init(&cache->mutex);
|
||||
g_mutex_init(&cache->mutex);
|
||||
return cache;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ gst_vaapi_display_cache_free(GstVaapiDisplayCache *cache)
|
|||
g_list_free(cache->list);
|
||||
cache->list = NULL;
|
||||
}
|
||||
g_static_mutex_free(&cache->mutex);
|
||||
g_mutex_clear(&cache->mutex);
|
||||
g_slice_free(GstVaapiDisplayCache, cache);
|
||||
}
|
||||
|
||||
|
@ -189,9 +189,9 @@ gst_vaapi_display_cache_get_size(GstVaapiDisplayCache *cache)
|
|||
|
||||
g_return_val_if_fail(cache != NULL, 0);
|
||||
|
||||
g_static_mutex_lock(&cache->mutex);
|
||||
g_mutex_lock(&cache->mutex);
|
||||
size = g_list_length(cache->list);
|
||||
g_static_mutex_unlock(&cache->mutex);
|
||||
g_mutex_unlock(&cache->mutex);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
@ -220,9 +220,9 @@ gst_vaapi_display_cache_add(
|
|||
if (!entry)
|
||||
return FALSE;
|
||||
|
||||
g_static_mutex_lock(&cache->mutex);
|
||||
g_mutex_lock(&cache->mutex);
|
||||
cache->list = g_list_prepend(cache->list, entry);
|
||||
g_static_mutex_unlock(&cache->mutex);
|
||||
g_mutex_unlock(&cache->mutex);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -246,9 +246,9 @@ gst_vaapi_display_cache_remove(
|
|||
return;
|
||||
|
||||
cache_entry_free(m->data);
|
||||
g_static_mutex_lock(&cache->mutex);
|
||||
g_mutex_lock(&cache->mutex);
|
||||
cache->list = g_list_delete_link(cache->list, m);
|
||||
g_static_mutex_unlock(&cache->mutex);
|
||||
g_mutex_unlock(&cache->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -741,16 +741,13 @@ gl_init_vtable(void)
|
|||
GLVTable *
|
||||
gl_get_vtable(void)
|
||||
{
|
||||
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
|
||||
static gboolean gl_vtable_init = TRUE;
|
||||
static gsize gl_vtable_init = FALSE;
|
||||
static GLVTable *gl_vtable = NULL;
|
||||
|
||||
g_static_mutex_lock(&mutex);
|
||||
if (gl_vtable_init) {
|
||||
gl_vtable_init = FALSE;
|
||||
gl_vtable = gl_init_vtable();
|
||||
if (g_once_init_enter(&gl_vtable_init)) {
|
||||
gl_vtable = gl_init_vtable();
|
||||
g_once_init_leave(&gl_vtable_init, TRUE);
|
||||
}
|
||||
g_static_mutex_unlock(&mutex);
|
||||
return gl_vtable;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue