[longomatch] Fix some leaks



commit e2d14e0b4fbc4d288d000b337cdcc18fc71920bf
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sun Dec 29 20:50:04 2013 +0100

    Fix some leaks

 libcesarplayer/gst-nle-source.c   |    5 +++++
 libcesarplayer/gst-video-editor.c |   24 ++++++++----------------
 2 files changed, 13 insertions(+), 16 deletions(-)
---
diff --git a/libcesarplayer/gst-nle-source.c b/libcesarplayer/gst-nle-source.c
index 9ee1984..0c1bbf7 100644
--- a/libcesarplayer/gst-nle-source.c
+++ b/libcesarplayer/gst-nle-source.c
@@ -160,6 +160,10 @@ gst_nle_source_dispose (GObject * object)
     g_list_free_full (nlesrc->queue, (GDestroyNotify) gst_nle_source_item_free);
     nlesrc->queue = NULL;
   }
+  if (nlesrc->decoder != NULL) {
+    gst_element_set_state (nlesrc->decoder, GST_STATE_NULL);
+    nlesrc->decoder = NULL;
+  }
 
   G_OBJECT_CLASS (parent_class)->dispose (object);
 }
@@ -653,6 +657,7 @@ gst_nle_source_change_state (GstElement * element, GstStateChange transition)
       if (nlesrc->decoder) {
         gst_element_set_state (nlesrc->decoder, GST_STATE_NULL);
         gst_object_unref (nlesrc->decoder);
+        nlesrc->decoder = NULL;
       }
     default:
       break;
diff --git a/libcesarplayer/gst-video-editor.c b/libcesarplayer/gst-video-editor.c
index e312dd0..c258de1 100644
--- a/libcesarplayer/gst-video-editor.c
+++ b/libcesarplayer/gst-video-editor.c
@@ -79,15 +79,11 @@ struct GstVideoEditorPrivate
   /* Video */
   GstElement *identity;
   GstElement *ffmpegcolorspace;
-  GstElement *capsfilter;
   GstElement *queue;
   GstElement *video_encoder;
 
   /* Audio */
   GstElement *audioidentity;
-  GstElement *audioconvert;
-  GstElement *audioresample;
-  GstElement *audiocapsfilter;
   GstElement *audioqueue;
   GstElement *audioencoder;
 
@@ -271,8 +267,8 @@ gve_create_video_encode_bin (GstVideoEditor * gve)
   gst_element_add_pad (GST_ELEMENT (gve->priv->vencode_bin),
       gst_ghost_pad_new ("src", srcpad));
 
-  g_object_unref (srcpad);
-  g_object_unref (sinkpad);
+  gst_object_unref (srcpad);
+  gst_object_unref (sinkpad);
 }
 
 static void
@@ -323,8 +319,8 @@ gve_create_audio_encode_bin (GstVideoEditor * gve)
   gst_element_add_pad (GST_ELEMENT (gve->priv->aencode_bin),
       gst_ghost_pad_new ("src", srcpad));
 
-  g_object_unref (srcpad);
-  g_object_unref (sinkpad);
+  gst_object_unref (srcpad);
+  gst_object_unref (sinkpad);
 }
 
 /* =========================================== */
@@ -353,14 +349,13 @@ new_decoded_pad_cb (GstElement * object, GstPad * pad, gpointer user_data)
     videopad = gst_element_get_static_pad (gve->priv->vencode_bin, "sink");
     /* only link once */
     if (GST_PAD_IS_LINKED (videopad)) {
-      g_object_unref (videopad);
-      gst_caps_unref (caps);
+      gst_object_unref (videopad);
       return;
     }
     /* link 'n play */
     GST_INFO ("Found video stream...%" GST_PTR_FORMAT, caps);
     gst_pad_link (pad, videopad);
-    g_object_unref (videopad);
+    gst_object_unref (videopad);
   }
 
   else if (g_strrstr (gst_structure_get_name (str), "audio")
@@ -368,17 +363,14 @@ new_decoded_pad_cb (GstElement * object, GstPad * pad, gpointer user_data)
     audiopad = gst_element_get_static_pad (gve->priv->aencode_bin, "sink");
     /* only link once */
     if (GST_PAD_IS_LINKED (audiopad)) {
-      g_object_unref (audiopad);
-      gst_caps_unref (caps);
+      gst_object_unref (audiopad);
       return;
     }
     /* link 'n play */
     GST_INFO ("Found audio stream...%" GST_PTR_FORMAT, caps);
     gst_pad_link (pad, audiopad);
-    g_object_unref (audiopad);
+    gst_object_unref (audiopad);
   }
-
-  gst_caps_unref (caps);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]