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
This commit is contained in:
Víctor Manuel Jáquez Leal 2018-08-30 18:56:40 +02:00
parent f6d827f6ff
commit 1f0b2fb952

View file

@ -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;
}