From db9cdcef0f3d49fa337a31cbd5b260fdb8037af6 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 18 May 2004 11:36:40 +0000 Subject: [PATCH] ext/ogg/gstoggmux.c: Fix an ugly memleak where the muxer didn't flush enough ogg pages. This also resulted in badly m... Original commit message from CVS: * ext/ogg/gstoggmux.c: (gst_ogg_mux_get_type), (gst_ogg_mux_init), (gst_ogg_mux_sinkconnect), (gst_ogg_mux_request_new_pad), (gst_ogg_mux_next_buffer), (gst_ogg_mux_push_page), (gst_ogg_mux_compare_pads), (gst_ogg_mux_queue_pads), (gst_ogg_mux_loop): Fix an ugly memleak where the muxer didn't flush enough ogg pages. This also resulted in badly muxed ogg files. --- ChangeLog | 10 ++++++++++ ext/ogg/gstoggmux.c | 15 ++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 55027ad9f3..ea1a917002 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-05-18 Wim Taymans + + * ext/ogg/gstoggmux.c: (gst_ogg_mux_get_type), (gst_ogg_mux_init), + (gst_ogg_mux_sinkconnect), (gst_ogg_mux_request_new_pad), + (gst_ogg_mux_next_buffer), (gst_ogg_mux_push_page), + (gst_ogg_mux_compare_pads), (gst_ogg_mux_queue_pads), + (gst_ogg_mux_loop): + Fix an ugly memleak where the muxer didn't flush enough ogg + pages. This also resulted in badly muxed ogg files. + 2004-05-18 Stephane Loeuillet * gst/asfdemux/asfheaders.c : diff --git a/ext/ogg/gstoggmux.c b/ext/ogg/gstoggmux.c index 88d5e231b7..f0d3a7f6c6 100644 --- a/ext/ogg/gstoggmux.c +++ b/ext/ogg/gstoggmux.c @@ -384,6 +384,7 @@ gst_ogg_mux_next_buffer (GstOggPad * pad) switch (type) { case GST_EVENT_EOS: + gst_event_unref (event); return NULL; default: gst_pad_event_default (pad->pad, event); @@ -415,8 +416,9 @@ gst_ogg_mux_push_page (GstOggMux * mux, ogg_page * page) if (GST_PAD_IS_USABLE (mux->srcpad)) gst_pad_push (mux->srcpad, GST_DATA (buffer)); - else + else { gst_buffer_unref (buffer); + } } /* @@ -543,14 +545,13 @@ gst_ogg_mux_loop (GstElement * element) ogg_page page; GstBuffer *buf, *tmpbuf; GstOggPad *pad = ogg_mux->pulling; - gint ret; GstOggPadState newstate; /* now see if we have a buffer */ buf = pad->buffer; if (buf == NULL) { - /* no buffer, get one */ - buf = gst_ogg_mux_next_buffer (pad); + /* no buffer, get one, and store in the pad so we free it later on */ + buf = pad->buffer = gst_ogg_mux_next_buffer (pad); /* data exhausted on this pad (EOS) */ if (buf == NULL) { /* stop pulling from the pad */ @@ -601,9 +602,9 @@ gst_ogg_mux_loop (GstElement * element) /* store new readahead buffer */ pad->buffer = tmpbuf; - /* create a page */ - ret = ogg_stream_pageout (&pad->stream, &page); - if (ret > 0) { + /* flush out the pages now. The packet we got could end up in + * more than one page so we need to flush them all */ + while (ogg_stream_pageout (&pad->stream, &page) > 0) { /* we have a complete page now, we can push the page * and make sure to pull on a new pad the next time around */ gst_ogg_mux_push_page (ogg_mux, &page);