From d4e1ff012d285d055598a4b66570c6a33c08dcaa Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 23 Dec 2009 15:46:25 +0100 Subject: [PATCH] uridecodebin: avoid leaking queue and typefind Don't leak the queue and typefind elements that we might link after the source element. --- gst/playback/gsturidecodebin.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gst/playback/gsturidecodebin.c b/gst/playback/gsturidecodebin.c index d9f7115..28b9850 100644 --- a/gst/playback/gsturidecodebin.c +++ b/gst/playback/gsturidecodebin.c @@ -86,6 +86,7 @@ struct _GstURIDecodeBin gboolean use_buffering; GstElement *source; + GstElement *queue; GstElement *typefind; guint have_type_id; /* have-type signal id from typefind */ GSList *decodebins; @@ -1084,6 +1085,9 @@ analyse_source (GstURIDecodeBin * decoder, gboolean * is_raw, gst_object_unref (sinkpad); gst_object_unref (pad); + /* save queue pointer so we can remove it later */ + decoder->queue = outelem; + /* get the new raw srcpad */ pad = gst_element_get_static_pad (outelem, "src"); } else { @@ -1482,10 +1486,12 @@ could_not_link: { GST_ELEMENT_ERROR (decoder, CORE, NEGOTIATION, (NULL), ("Can't link source to typefind element")); + gst_bin_remove (GST_BIN_CAST (decoder), typefind); return FALSE; } } +/* remove source and all related elements */ static void remove_source (GstURIDecodeBin * bin) { @@ -1506,6 +1512,18 @@ remove_source (GstURIDecodeBin * bin) } bin->source = NULL; } + if (bin->queue) { + GST_DEBUG_OBJECT (bin, "removing old queue element"); + gst_element_set_state (bin->queue, GST_STATE_NULL); + gst_bin_remove (GST_BIN_CAST (bin), bin->queue); + bin->queue = NULL; + } + if (bin->typefind) { + GST_DEBUG_OBJECT (bin, "removing old typefind element"); + gst_element_set_state (bin->typefind, GST_STATE_NULL); + gst_bin_remove (GST_BIN_CAST (bin), bin->typefind); + bin->typefind = NULL; + } } /* is called when a dynamic source element created a new pad. */ -- 2.7.4