From 9d5875df67f27a8e2cc55e38fe87aea3928e6a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Thu, 27 Oct 2016 11:25:55 +0200 Subject: [PATCH] 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 --- gst/vaapi/gstvaapipluginbase.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c index a08815dbe2..d6ec91ddcc 100644 --- a/gst/vaapi/gstvaapipluginbase.c +++ b/gst/vaapi/gstvaapipluginbase.c @@ -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; }