From 1f0b2fb9529934a79842f94222995401ad9417db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Thu, 30 Aug 2018 18:56:40 +0200 Subject: [PATCH] libs: display: lock at extracting available image formates When running several vaapi elements at the concurrently, at initialization, there is a race condition when extractin the avaible formats for images and subpictures. This patch add a lock when the those arrays are filled. https://bugzilla.gnome.org/show_bug.cgi?id=797039 --- gst-libs/gst/vaapi/gstvaapidisplay.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.c b/gst-libs/gst/vaapi/gstvaapidisplay.c index 7c6588afb7..ad6ebcbe22 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay.c +++ b/gst-libs/gst/vaapi/gstvaapidisplay.c @@ -649,8 +649,11 @@ ensure_image_formats (GstVaapiDisplay * display) gint i, n; gboolean success = FALSE; - if (priv->image_formats) + GST_VAAPI_DISPLAY_LOCK (display); + if (priv->image_formats) { + GST_VAAPI_DISPLAY_UNLOCK (display); return TRUE; + } priv->image_formats = g_array_new (FALSE, FALSE, sizeof (GstVaapiFormatInfo)); if (!priv->image_formats) @@ -676,6 +679,7 @@ ensure_image_formats (GstVaapiDisplay * display) cleanup: g_free (formats); + GST_VAAPI_DISPLAY_UNLOCK (display); return success; } @@ -690,8 +694,11 @@ ensure_subpicture_formats (GstVaapiDisplay * display) guint i, n; gboolean success = FALSE; - if (priv->subpicture_formats) + GST_VAAPI_DISPLAY_LOCK (display); + if (priv->subpicture_formats) { + GST_VAAPI_DISPLAY_UNLOCK (display); return TRUE; + } priv->subpicture_formats = g_array_new (FALSE, FALSE, sizeof (GstVaapiFormatInfo)); @@ -725,6 +732,7 @@ ensure_subpicture_formats (GstVaapiDisplay * display) cleanup: g_free (formats); g_free (flags); + GST_VAAPI_DISPLAY_UNLOCK (display); return success; }