gst/qtdemux/qtdemux.c: Memleak fixes.

Original commit message from CVS:
* gst/qtdemux/qtdemux.c: (gst_qtdemux_loop_header),
(gst_qtdemux_add_stream):
Memleak fixes.
Send out EOS for valid reasons (couldn't pull_range() from upstream
for example).
This commit is contained in:
Edward Hervey 2005-12-07 11:46:15 +00:00
parent 8a2d8148e4
commit 82d3a26a56

View file

@ -493,7 +493,7 @@ gst_qtdemux_loop_header (GstPad * pad)
guint8 *data; guint8 *data;
guint32 length; guint32 length;
guint32 fourcc; guint32 fourcc;
GstBuffer *buf; GstBuffer *buf = NULL;
int offset; int offset;
guint64 cur_offset; guint64 cur_offset;
int size; int size;
@ -507,13 +507,15 @@ gst_qtdemux_loop_header (GstPad * pad)
case QTDEMUX_STATE_HEADER:{ case QTDEMUX_STATE_HEADER:{
if (gst_pad_pull_range (qtdemux->sinkpad, if (gst_pad_pull_range (qtdemux->sinkpad,
cur_offset, 16, &buf) != GST_FLOW_OK) cur_offset, 16, &buf) != GST_FLOW_OK)
goto pause; goto error;
data = GST_BUFFER_DATA (buf); data = GST_BUFFER_DATA (buf);
length = GST_READ_UINT32_BE (data); length = GST_READ_UINT32_BE (data);
GST_DEBUG ("length %08x", length); GST_DEBUG ("length %08x", length);
fourcc = GST_READ_UINT32_LE (data + 4); fourcc = GST_READ_UINT32_LE (data + 4);
GST_DEBUG ("atom type %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc)); GST_DEBUG ("atom type %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
gst_buffer_unref (buf);
if (length == 0) { if (length == 0) {
length = G_MAXUINT32; //gst_bytestream_length (qtdemux->bs) - cur_offset; length = G_MAXUINT32; //gst_bytestream_length (qtdemux->bs) - cur_offset;
} }
@ -543,7 +545,7 @@ gst_qtdemux_loop_header (GstPad * pad)
if (gst_pad_pull_range (qtdemux->sinkpad, cur_offset, length, if (gst_pad_pull_range (qtdemux->sinkpad, cur_offset, length,
&moov) != GST_FLOW_OK) &moov) != GST_FLOW_OK)
goto pause; goto error;
cur_offset += length; cur_offset += length;
qtdemux->offset += length; qtdemux->offset += length;
@ -621,7 +623,7 @@ gst_qtdemux_loop_header (GstPad * pad)
buf = NULL; buf = NULL;
if (gst_pad_pull_range (qtdemux->sinkpad, offset, if (gst_pad_pull_range (qtdemux->sinkpad, offset,
size, &buf) != GST_FLOW_OK) size, &buf) != GST_FLOW_OK)
goto pause; goto error;
if (buf) { if (buf) {
/* hum... FIXME changing framerate breaks horribly, better set /* hum... FIXME changing framerate breaks horribly, better set
@ -672,7 +674,7 @@ gst_qtdemux_loop_header (GstPad * pad)
gst_buffer_set_caps (buf, stream->caps); gst_buffer_set_caps (buf, stream->caps);
ret = gst_pad_push (stream->pad, buf); ret = gst_pad_push (stream->pad, buf);
if (ret != GST_FLOW_OK && ret != GST_FLOW_NOT_LINKED) if (ret != GST_FLOW_OK && ret != GST_FLOW_NOT_LINKED)
goto pause; goto error;
GST_INFO ("pushing buffer on %" GST_PTR_FORMAT, stream->pad); GST_INFO ("pushing buffer on %" GST_PTR_FORMAT, stream->pad);
} }
@ -686,9 +688,10 @@ gst_qtdemux_loop_header (GstPad * pad)
return; return;
pause: error:
GST_LOG_OBJECT (qtdemux, "pausing task"); GST_LOG_OBJECT (qtdemux, "pausing task and sending EOS");
gst_pad_pause_task (qtdemux->sinkpad); gst_pad_pause_task (qtdemux->sinkpad);
gst_pad_event_default (qtdemux->sinkpad, gst_event_new_eos ());
return; return;
} }
@ -722,11 +725,12 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux,
gchar *caps; gchar *caps;
if (stream->subtype == GST_MAKE_FOURCC ('v', 'i', 'd', 'e')) { if (stream->subtype == GST_MAKE_FOURCC ('v', 'i', 'd', 'e')) {
GstPadTemplate *templ;
gchar *name = g_strdup_printf ("video_%02d", qtdemux->n_video_streams); gchar *name = g_strdup_printf ("video_%02d", qtdemux->n_video_streams);
stream->pad = templ = gst_static_pad_template_get (&gst_qtdemux_videosrc_template);
gst_pad_new_from_template (gst_static_pad_template_get stream->pad = gst_pad_new_from_template (templ, name);
(&gst_qtdemux_videosrc_template), name); gst_object_unref (templ);
g_free (name); g_free (name);
stream->fps_n = stream->timescale; stream->fps_n = stream->timescale;
stream->fps_d = stream->samples[0].duration; stream->fps_d = stream->samples[0].duration;
@ -771,7 +775,7 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux,
gst_pad_set_caps (stream->pad, stream->caps); gst_pad_set_caps (stream->pad, stream->caps);
GST_DEBUG ("adding pad %s %p to qtdemux %p", GST_DEBUG ("adding pad %s %p to qtdemux %p",
gst_pad_get_name (stream->pad), stream->pad, qtdemux); GST_OBJECT_NAME (stream->pad), stream->pad, qtdemux);
gst_element_add_pad (GST_ELEMENT (qtdemux), stream->pad); gst_element_add_pad (GST_ELEMENT (qtdemux), stream->pad);
if (list) { if (list) {
gst_element_found_tags_for_pad (GST_ELEMENT (qtdemux), stream->pad, list); gst_element_found_tags_for_pad (GST_ELEMENT (qtdemux), stream->pad, list);