mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:06:17 +00:00
display: use a recursive mutex for the display cache.
Use a recursive mutex for the display cache so that a 3rdparty display object could be initialized during the initialization of the parent display.
This commit is contained in:
parent
93418ed5ee
commit
2fb20e9906
3 changed files with 60 additions and 14 deletions
|
@ -862,10 +862,11 @@ gst_vaapi_display_destroy (GstVaapiDisplay * display)
|
||||||
|
|
||||||
gst_vaapi_display_replace_internal (&priv->parent, NULL);
|
gst_vaapi_display_replace_internal (&priv->parent, NULL);
|
||||||
|
|
||||||
g_mutex_lock (&g_display_cache_lock);
|
if (priv->cache) {
|
||||||
if (priv->cache)
|
gst_vaapi_display_cache_lock (priv->cache);
|
||||||
gst_vaapi_display_cache_remove (priv->cache, display);
|
gst_vaapi_display_cache_remove (priv->cache, display);
|
||||||
g_mutex_unlock (&g_display_cache_lock);
|
gst_vaapi_display_cache_unlock (priv->cache);
|
||||||
|
}
|
||||||
gst_vaapi_display_cache_replace (&priv->cache, NULL);
|
gst_vaapi_display_cache_replace (&priv->cache, NULL);
|
||||||
free_display_cache ();
|
free_display_cache ();
|
||||||
}
|
}
|
||||||
|
@ -953,9 +954,9 @@ gst_vaapi_display_create (GstVaapiDisplay * display,
|
||||||
gst_vaapi_display_cache_replace (&priv->cache, cache);
|
gst_vaapi_display_cache_replace (&priv->cache, cache);
|
||||||
gst_vaapi_display_cache_unref (cache);
|
gst_vaapi_display_cache_unref (cache);
|
||||||
|
|
||||||
g_mutex_lock (&g_display_cache_lock);
|
gst_vaapi_display_cache_lock (cache);
|
||||||
success = gst_vaapi_display_create_unlocked (display, init_type, init_value);
|
success = gst_vaapi_display_create_unlocked (display, init_type, init_value);
|
||||||
g_mutex_unlock (&g_display_cache_lock);
|
gst_vaapi_display_cache_unlock (cache);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ struct _CacheEntry
|
||||||
struct _GstVaapiDisplayCache
|
struct _GstVaapiDisplayCache
|
||||||
{
|
{
|
||||||
GstVaapiMiniObject parent_instance;
|
GstVaapiMiniObject parent_instance;
|
||||||
|
GRecMutex mutex;
|
||||||
GList *list;
|
GList *list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -164,13 +165,13 @@ gst_vaapi_display_cache_finalize (GstVaapiDisplayCache * cache)
|
||||||
{
|
{
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
if (!cache->list)
|
if (cache->list) {
|
||||||
return;
|
for (l = cache->list; l != NULL; l = l->next)
|
||||||
|
cache_entry_free (l->data);
|
||||||
for (l = cache->list; l != NULL; l = l->next)
|
g_list_free (cache->list);
|
||||||
cache_entry_free (l->data);
|
cache->list = NULL;
|
||||||
g_list_free (cache->list);
|
}
|
||||||
cache->list = NULL;
|
g_rec_mutex_clear (&cache->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const GstVaapiMiniObjectClass *
|
static const GstVaapiMiniObjectClass *
|
||||||
|
@ -193,8 +194,44 @@ gst_vaapi_display_cache_class (void)
|
||||||
GstVaapiDisplayCache *
|
GstVaapiDisplayCache *
|
||||||
gst_vaapi_display_cache_new (void)
|
gst_vaapi_display_cache_new (void)
|
||||||
{
|
{
|
||||||
return (GstVaapiDisplayCache *)
|
GstVaapiDisplayCache *cache;
|
||||||
gst_vaapi_mini_object_new0 (gst_vaapi_display_cache_class ());
|
|
||||||
|
cache = (GstVaapiDisplayCache *)
|
||||||
|
gst_vaapi_mini_object_new (gst_vaapi_display_cache_class ());
|
||||||
|
if (!cache)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
g_rec_mutex_init (&cache->mutex);
|
||||||
|
cache->list = NULL;
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_display_cache_lock:
|
||||||
|
* @cache: the #GstVaapiDisplayCache
|
||||||
|
*
|
||||||
|
* Locks the display cache @cache.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_vaapi_display_cache_lock (GstVaapiDisplayCache * cache)
|
||||||
|
{
|
||||||
|
g_return_if_fail (cache != NULL);
|
||||||
|
|
||||||
|
g_rec_mutex_lock (&cache->mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_display_cache_unlock:
|
||||||
|
* @cache: the #GstVaapiDisplayCache
|
||||||
|
*
|
||||||
|
* Unlocks the display cache @cache.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_vaapi_display_cache_unlock (GstVaapiDisplayCache * cache)
|
||||||
|
{
|
||||||
|
g_return_if_fail (cache != NULL);
|
||||||
|
|
||||||
|
g_rec_mutex_unlock (&cache->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,6 +42,14 @@ gst_vaapi_display_cache_new (void);
|
||||||
gst_vaapi_mini_object_replace ((GstVaapiMiniObject **) (old_cache_ptr), \
|
gst_vaapi_mini_object_replace ((GstVaapiMiniObject **) (old_cache_ptr), \
|
||||||
GST_VAAPI_MINI_OBJECT (new_cache))
|
GST_VAAPI_MINI_OBJECT (new_cache))
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
void
|
||||||
|
gst_vaapi_display_cache_lock (GstVaapiDisplayCache * cache);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
void
|
||||||
|
gst_vaapi_display_cache_unlock (GstVaapiDisplayCache * cache);
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_display_cache_is_empty (GstVaapiDisplayCache * cache);
|
gst_vaapi_display_cache_is_empty (GstVaapiDisplayCache * cache);
|
||||||
|
|
Loading…
Reference in a new issue