From 5aa02968c9593f1144a801ffb52aef9f8fa688a0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 26 Mar 2011 19:36:50 +0000 Subject: [PATCH] oggparse: fix list iteration code Not that it really matters, but let's fix it before someone notices and makes fun of us. --- ext/ogg/gstoggparse.c | 54 +++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/ext/ogg/gstoggparse.c b/ext/ogg/gstoggparse.c index 7945d38..eae0acd 100644 --- a/ext/ogg/gstoggparse.c +++ b/ext/ogg/gstoggparse.c @@ -572,12 +572,11 @@ gst_ogg_parse_chain (GstPad * pad, GstBuffer * buffer) for (l = ogg->oggstreams; l != NULL; l = l->next) { GstOggStream *stream = (GstOggStream *) l->data; - int j; + GList *j; - /* FIXME: list iteration */ - for (j = 1; j < g_list_length (stream->headers); j++) { - gst_ogg_parse_append_header (&array, - GST_BUFFER (g_list_nth_data (stream->headers, j))); + /* already appended the first header, now do headers 2-N */ + for (j = stream->headers->next; j != NULL; j = j->next) { + gst_ogg_parse_append_header (&array, GST_BUFFER (j->data)); count++; } } @@ -613,12 +612,11 @@ gst_ogg_parse_chain (GstPad * pad, GstBuffer * buffer) } for (l = ogg->oggstreams; l != NULL; l = l->next) { GstOggStream *stream = (GstOggStream *) l->data; - int j; + GList *j; - /* FIXME: list iteration */ - for (j = 1; j < g_list_length (stream->headers); j++) { - GstBuffer *buf = - GST_BUFFER (g_list_nth_data (stream->headers, j)); + /* pushed the first one for each stream already, now do 2-N */ + for (j = stream->headers->next; j != NULL; j = j->next) { + GstBuffer *buf = GST_BUFFER (j->data); buf = gst_buffer_make_metadata_writable (buf); gst_buffer_set_caps (buf, caps); @@ -668,29 +666,25 @@ gst_ogg_parse_chain (GstPad * pad, GstBuffer * buffer) stream->stored_buffers = g_list_append (stream->stored_buffers, pagebuffer); } else { - if (stream->stored_buffers) { - int j; + while (stream->stored_buffers) { + GstBuffer *buf = stream->stored_buffers->data; - /* FIXME: list iteration */ - for (j = 0; j < g_list_length (stream->stored_buffers); j++) { - GstBuffer *buf = - GST_BUFFER (g_list_nth_data (stream->stored_buffers, j)); + buf = gst_buffer_make_metadata_writable (buf); + gst_buffer_set_caps (buf, ogg->caps); + GST_BUFFER_TIMESTAMP (buf) = buffertimestamp; + if (!keyframe) { + GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT); + } else { + keyframe = FALSE; + } - buf = gst_buffer_make_metadata_writable (buf); - gst_buffer_set_caps (buf, ogg->caps); - GST_BUFFER_TIMESTAMP (buf) = buffertimestamp; - if (!keyframe) { - GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT); - } else { - keyframe = FALSE; - } + result = gst_pad_push (ogg->srcpad, buf); + if (result != GST_FLOW_OK) + return result; - result = gst_pad_push (ogg->srcpad, buf); - if (result != GST_FLOW_OK) - return result; - } - g_list_free (stream->stored_buffers); - stream->stored_buffers = NULL; + stream->stored_buffers = + g_list_delete_link (stream->stored_buffers, + stream->stored_buffers); } pagebuffer = gst_buffer_make_metadata_writable (pagebuffer); -- 2.7.4