From 4ca530f2fefa0ed7ba3e2576541d189b9cc5214d Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Mon, 18 Feb 2013 14:02:48 -0300 Subject: [PATCH] dashdemux: plug some leaks Add some missing free/unrefs spotted by valgrind --- ext/dash/gstdashdemux.c | 26 +++++++++++++++++++++++--- ext/dash/gstmpdparser.c | 2 +- ext/dash/gstmpdparser.h | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ext/dash/gstdashdemux.c b/ext/dash/gstdashdemux.c index db0d809..4bcd989 100644 --- a/ext/dash/gstdashdemux.c +++ b/ext/dash/gstdashdemux.c @@ -282,6 +282,8 @@ gst_dash_demux_dispose (GObject * obj) demux->downloader = NULL; } + g_static_mutex_free (&demux->streams_lock); + G_OBJECT_CLASS (parent_class)->dispose (obj); } @@ -1225,6 +1227,12 @@ gst_dash_demux_reset (GstDashDemux * demux, gboolean dispose) if (demux->downloader) gst_uri_downloader_reset (demux->downloader); + if (demux->next_periods) { + g_assert (demux->next_periods == demux->streams); + demux->next_periods = + g_slist_delete_link (demux->next_periods, demux->next_periods); + } + for (iter = demux->streams; iter; iter = g_slist_next (iter)) { GstDashDemuxStream *stream = iter->data; if (stream->pad) { @@ -1237,6 +1245,13 @@ gst_dash_demux_reset (GstDashDemux * demux, gboolean dispose) g_slist_free (demux->streams); demux->streams = NULL; + for (iter = demux->next_periods; iter; iter = g_slist_next (iter)) { + GSList *streams = iter->data; + g_slist_free_full (streams, (GDestroyNotify) gst_dash_demux_stream_free); + } + g_slist_free (demux->next_periods); + demux->next_periods = NULL; + if (demux->manifest) { gst_buffer_unref (demux->manifest); demux->manifest = NULL; @@ -1571,7 +1586,7 @@ gst_dash_demux_select_representations (GstDashDemux * demux) static GstFragment * gst_dash_demux_get_next_header (GstDashDemux * demux, guint stream_idx) { - const gchar *initializationURL; + gchar *initializationURL; gchar *next_header_uri; GstFragment *fragment; @@ -1583,8 +1598,9 @@ gst_dash_demux_get_next_header (GstDashDemux * demux, guint stream_idx) next_header_uri = g_strconcat (gst_mpdparser_get_baseURL (demux->client, stream_idx), initializationURL, NULL); + g_free (initializationURL); } else { - next_header_uri = g_strdup (initializationURL); + next_header_uri = initializationURL; } GST_INFO_OBJECT (demux, "Fetching header %s", next_header_uri); @@ -1781,10 +1797,13 @@ gst_dash_demux_get_next_fragment (GstDashDemux * demux) active_stream = gst_mpdparser_get_active_stream_by_index (demux->client, stream_idx); - if (active_stream == NULL) /* TODO unref fragments */ + if (active_stream == NULL) { + g_object_unref (download); return FALSE; + } buffer = gst_fragment_get_buffer (download); + g_object_unref (download); if (selected_stream->need_header) { /* We need to fetch a new header */ @@ -1797,6 +1816,7 @@ gst_dash_demux_get_next_fragment (GstDashDemux * demux) header_buffer = gst_fragment_get_buffer (header); buffer = gst_buffer_join (header_buffer, buffer); + g_object_unref (header); } selected_stream->need_header = FALSE; } diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c index c8f133d..08fa1d1 100644 --- a/ext/dash/gstmpdparser.c +++ b/ext/dash/gstmpdparser.c @@ -3236,7 +3236,7 @@ gst_mpd_client_get_next_fragment (GstMpdClient * client, } gboolean -gst_mpd_client_get_next_header (GstMpdClient * client, const gchar ** uri, +gst_mpd_client_get_next_header (GstMpdClient * client, gchar ** uri, guint stream_idx) { GstActiveStream *stream; diff --git a/ext/dash/gstmpdparser.h b/ext/dash/gstmpdparser.h index a2b8718..e640a17 100644 --- a/ext/dash/gstmpdparser.h +++ b/ext/dash/gstmpdparser.h @@ -473,7 +473,7 @@ GstClockTime gst_mpd_client_get_next_fragment_duration (GstMpdClient * client); GstClockTime gst_mpd_client_get_media_presentation_duration (GstMpdClient *client); gboolean gst_mpd_client_get_next_fragment_timestamp (GstMpdClient * client, guint stream_idx, GstClockTime * ts); gboolean gst_mpd_client_get_next_fragment (GstMpdClient *client, guint indexStream, gboolean *discontinuity, gchar **uri, GstClockTime *duration, GstClockTime *timestamp); -gboolean gst_mpd_client_get_next_header (GstMpdClient *client, const gchar **uri, guint stream_idx); +gboolean gst_mpd_client_get_next_header (GstMpdClient *client, gchar **uri, guint stream_idx); gboolean gst_mpd_client_is_live (GstMpdClient * client); /* Period selection */ -- 2.7.4