glmixer: do not leak pool in error cases
authorOgnyan Tonchev <ognyan@axis.com>
Tue, 16 Sep 2014 09:41:16 +0000 (11:41 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 16 Sep 2014 09:48:01 +0000 (12:48 +0300)
https://bugzilla.gnome.org/show_bug.cgi?id=736729

ext/gl/gstglmixer.c

index 62bb4d4..5aa1bea 100644 (file)
@@ -600,22 +600,6 @@ gst_gl_mixer_decide_allocation (GstGLMixer * mix, GstQuery * query)
   GstGLContext *other_context = NULL;
   GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (mix);
 
-  gst_query_parse_allocation (query, &caps, NULL);
-
-  if (gst_query_get_n_allocation_pools (query) > 0) {
-    gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
-
-    update_pool = TRUE;
-  } else {
-    GstVideoInfo vinfo;
-
-    gst_video_info_init (&vinfo);
-    gst_video_info_from_caps (&vinfo, caps);
-    size = vinfo.size;
-    min = max = 0;
-    update_pool = FALSE;
-  }
-
   if (!gst_gl_ensure_display (mix, &mix->display))
     return FALSE;
 
@@ -686,6 +670,8 @@ gst_gl_mixer_decide_allocation (GstGLMixer * mix, GstQuery * query)
   gst_gl_context_gen_texture (mix->context, &mix->out_tex_id,
       GST_VIDEO_FORMAT_RGBA, out_width, out_height);
 
+  gst_query_parse_allocation (query, &caps, NULL);
+
   if (mixer_class->set_caps)
     mixer_class->set_caps (mix, caps);
 
@@ -693,6 +679,20 @@ gst_gl_mixer_decide_allocation (GstGLMixer * mix, GstQuery * query)
   g_cond_signal (&mix->priv->gl_resource_cond);
   g_mutex_unlock (&mix->priv->gl_resource_lock);
 
+  if (gst_query_get_n_allocation_pools (query) > 0) {
+    gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
+
+    update_pool = TRUE;
+  } else {
+    GstVideoInfo vinfo;
+
+    gst_video_info_init (&vinfo);
+    gst_video_info_from_caps (&vinfo, caps);
+    size = vinfo.size;
+    min = max = 0;
+    update_pool = FALSE;
+  }
+
   if (!pool)
     pool = gst_gl_buffer_pool_new (mix->context);