plugin: don't lose previous context at query
authorVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Wed, 4 Nov 2015 19:37:05 +0000 (20:37 +0100)
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Mon, 9 Nov 2015 15:18:19 +0000 (16:18 +0100)
When processing the GST_CONTEXT_QUERY we should not lose the previous
context in the query, we should only add our display structure.

This patch copies the old context, if it is there, and stamp our display on
it. Otherwise, a new context is created.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
https://bugzilla.gnome.org/show_bug.cgi?id=757598

gst/vaapi/gstvaapipluginutil.c

index 135d109..00babbe 100644 (file)
@@ -258,7 +258,7 @@ gboolean
 gst_vaapi_reply_to_query (GstQuery * query, GstVaapiDisplay * display)
 {
   const gchar *type = NULL;
-  GstContext *context;
+  GstContext *context, *old_context;
 
   if (GST_QUERY_TYPE (query) != GST_QUERY_CONTEXT)
     return FALSE;
@@ -272,7 +272,14 @@ gst_vaapi_reply_to_query (GstQuery * query, GstVaapiDisplay * display)
   if (g_strcmp0 (type, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME))
     return FALSE;
 
-  context = gst_vaapi_video_context_new_with_display (display, FALSE);
+  gst_query_parse_context (query, &old_context);
+  if (old_context) {
+    context = gst_context_copy (old_context);
+    gst_vaapi_video_context_set_display (context, display);
+  } else {
+    context = gst_vaapi_video_context_new_with_display (display, FALSE);
+  }
+
   gst_query_set_context (query, context);
   gst_context_unref (context);