plugins: ensure display when getting raw caps

When running gst-discoverer-1.0, in certain media, vaapipostroc is stopped
meanwhile it is transforming caps. The problem is that stop() calls
gst_vaapi_plugin_base_close(), which nullifies the element's va display, but
the va display is used in tranform_caps() when it is extracting the possible
format conversions. This display disappearing generates warning messages.

This patch holds a local reference of va display at ensure_allowed_raw_caps()
hence it doesn't go away meanwhile it is used, even if the
gst_vaapi_plugin_base_close() is called in other thread.

https://bugzilla.gnome.org/show_bug.cgi?id=773593
This commit is contained in:
Víctor Manuel Jáquez Leal 2016-10-27 11:25:55 +02:00
parent 1e7d89e7fe
commit 9d5875df67

View file

@ -1117,6 +1117,7 @@ ensure_allowed_raw_caps (GstVaapiPluginBase * plugin)
{
GArray *formats, *out_formats;
GstVaapiSurface *surface;
GstVaapiDisplay *display;
guint i;
GstCaps *out_caps;
gboolean ret = FALSE;
@ -1127,7 +1128,8 @@ ensure_allowed_raw_caps (GstVaapiPluginBase * plugin)
out_formats = formats = NULL;
surface = NULL;
formats = gst_vaapi_display_get_image_formats (plugin->display);
display = gst_vaapi_display_ref (plugin->display);
formats = gst_vaapi_display_get_image_formats (display);
if (!formats)
goto bail;
@ -1137,8 +1139,7 @@ ensure_allowed_raw_caps (GstVaapiPluginBase * plugin)
goto bail;
surface =
gst_vaapi_surface_new (plugin->display, GST_VAAPI_CHROMA_TYPE_YUV420, 64,
64);
gst_vaapi_surface_new (display, GST_VAAPI_CHROMA_TYPE_YUV420, 64, 64);
if (!surface)
goto bail;
@ -1148,7 +1149,7 @@ ensure_allowed_raw_caps (GstVaapiPluginBase * plugin)
if (format == GST_VIDEO_FORMAT_UNKNOWN)
continue;
image = gst_vaapi_image_new (plugin->display, format, 64, 64);
image = gst_vaapi_image_new (display, format, 64, 64);
if (!image)
continue;
if (gst_vaapi_surface_put_image (surface, image))
@ -1171,6 +1172,7 @@ bail:
g_array_unref (out_formats);
if (surface)
gst_vaapi_object_unref (surface);
gst_vaapi_display_unref (display);
return ret;
}