From: Mark Nauwelaerts Date: Thu, 4 Nov 2010 09:06:30 +0000 (+0100) Subject: qtdemux: refactor stream freeing X-Git-Tag: RELEASE-0.10.27~268 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=73bbd8e7d3ef5cc8a3dd77c15dcfbba3605835c5;p=platform%2Fupstream%2Fgst-plugins-good.git qtdemux: refactor stream freeing --- diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index eee7361..46d016e 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c @@ -1683,6 +1683,27 @@ gst_qtdemux_stbl_free (QtDemuxStream * stream) stream->ctts.data = NULL; } +static void +gst_qtdemux_stream_free (GstQTDemux * qtdemux, QtDemuxStream * stream) +{ + while (stream->buffers) { + gst_buffer_unref (GST_BUFFER_CAST (stream->buffers->data)); + stream->buffers = g_slist_delete_link (stream->buffers, stream->buffers); + } + if (stream->pad) + gst_element_remove_pad (GST_ELEMENT_CAST (qtdemux), stream->pad); + g_free (stream->samples); + if (stream->caps) + gst_caps_unref (stream->caps); + g_free (stream->segments); + if (stream->pending_tags) + gst_tag_list_free (stream->pending_tags); + g_free (stream->redirect_uri); + /* free stbl sub-atoms */ + gst_qtdemux_stbl_free (stream); + g_free (stream); +} + static GstStateChangeReturn gst_qtdemux_change_state (GstElement * element, GstStateChange transition) { @@ -1725,25 +1746,8 @@ gst_qtdemux_change_state (GstElement * element, GstStateChange transition) qtdemux->element_index = NULL; gst_adapter_clear (qtdemux->adapter); for (n = 0; n < qtdemux->n_streams; n++) { - QtDemuxStream *stream = qtdemux->streams[n]; - - while (stream->buffers) { - gst_buffer_unref (GST_BUFFER_CAST (stream->buffers->data)); - stream->buffers = - g_slist_delete_link (stream->buffers, stream->buffers); - } - if (stream->pad) - gst_element_remove_pad (element, stream->pad); - g_free (stream->samples); - if (stream->caps) - gst_caps_unref (stream->caps); - g_free (stream->segments); - if (stream->pending_tags) - gst_tag_list_free (stream->pending_tags); - g_free (stream->redirect_uri); - /* free stbl sub-atoms */ - gst_qtdemux_stbl_free (stream); - g_free (stream); + gst_qtdemux_stream_free (qtdemux, qtdemux->streams[n]); + qtdemux->streams[n] = NULL; } qtdemux->major_brand = 0; qtdemux->n_streams = 0;