[847/906] mixer: unmap the video frames we map
authorMatthew Waters <ystreet00@gmail.com>
Wed, 13 Nov 2013 04:57:07 +0000 (15:57 +1100)
committerMatthew Waters <ystreet00@gmail.com>
Sat, 15 Mar 2014 17:37:04 +0000 (18:37 +0100)
plugs a memory leak

gst-libs/gst/gl/gstglmixer.c

index d02ee76..e5251e4 100644 (file)
@@ -1433,6 +1433,7 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
   guint out_tex;
   guint array_index = 0;
   guint i;
+  gboolean res;
 
   GST_TRACE ("Processing buffers");
 
@@ -1457,7 +1458,8 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
               GST_VIDEO_FRAME_HEIGHT (&out_frame))) {
         GST_ELEMENT_ERROR (mix, RESOURCE, NOT_FOUND,
             ("%s", "Failed to init upload format"), (NULL));
-        return FALSE;
+        res = FALSE;
+        goto out;
       }
     }
 
@@ -1498,8 +1500,10 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
       if (!gst_video_frame_map (in_frame, &pad->in_info, mixcol->buffer,
               GST_MAP_READ | GST_MAP_GL)) {
         ++array_index;
+        pad->mapped = FALSE;
         continue;
       }
+      pad->mapped = TRUE;
 
       if (gst_is_gl_memory (in_frame->map[0].memory)) {
         in_tex = *(guint *) in_frame->data[0];
@@ -1523,7 +1527,8 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
                   in_width, in_height, in_width, in_height)) {
             GST_ELEMENT_ERROR (mix, RESOURCE, NOT_FOUND,
                 ("%s", "Failed to init upload format"), (NULL));
-            return FALSE;
+            res = FALSE;
+            goto out;
           }
 
           if (!pad->in_tex_id)
@@ -1535,11 +1540,11 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
                 in_frame->data)) {
           GST_ELEMENT_ERROR (mix, RESOURCE, NOT_FOUND,
               ("%s", "Failed to upload video frame"), (NULL));
-          return FALSE;
+          res = FALSE;
+          goto out;
         }
 
         in_tex = pad->in_tex_id;
-        pad->mapped = TRUE;
       }
 
       frame->texture = in_tex;
@@ -1554,10 +1559,12 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
             out_frame.data)) {
       GST_ELEMENT_ERROR (mix, RESOURCE, NOT_FOUND, ("%s",
               "Failed to download video frame"), (NULL));
-      return FALSE;
+      res = FALSE;
+      goto out;
     }
   }
 
+out:
   i = 0;
   walk = mix->sinkpads;
   while (walk) {
@@ -1574,7 +1581,7 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
 
   gst_video_frame_unmap (&out_frame);
 
-  return TRUE;
+  return res;
 }
 
 static void