From 25d29c4f099fff57881fb5ff7a532455d2734d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 19 May 2006 15:00:43 +0000 Subject: [PATCH] gst-libs/gst/riff/riff-read.c: On second thought, just skip JUNK chunks automatically, so the caller doesn't have to ... Original commit message from CVS: * gst-libs/gst/riff/riff-read.c: (gst_riff_read_chunk): On second thought, just skip JUNK chunks automatically, so the caller doesn't have to handle this. Fixes #342345. Also, return GST_FLOW_UNEXPECTED if we get a short read, not GST_FLOW_ERROR. --- ChangeLog | 8 ++++++++ gst-libs/gst/riff/riff-read.c | 35 +++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 26a1a7cac7..614c021c95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-05-19 Tim-Philipp Müller + + * gst-libs/gst/riff/riff-read.c: (gst_riff_read_chunk): + On second thought, just skip JUNK chunks automatically, so + the caller doesn't have to handle this. Fixes #342345. + Also, return GST_FLOW_UNEXPECTED if we get a short read, + not GST_FLOW_ERROR. + 2006-05-19 Tim-Philipp Müller * gst-libs/gst/riff/riff-read.c: (gst_riff_read_chunk): diff --git a/gst-libs/gst/riff/riff-read.c b/gst-libs/gst/riff/riff-read.c index 9072195d88..0c1fb78df2 100644 --- a/gst-libs/gst/riff/riff-read.c +++ b/gst-libs/gst/riff/riff-read.c @@ -39,7 +39,8 @@ GST_DEBUG_CATEGORY_EXTERN (riff_debug); * @tag: fourcc of the chunk (returned by this function). * @chunk_data: buffer (returned by this function). * - * Reads a single chunk of data. + * Reads a single chunk of data. Since 0.10.8 'JUNK' chunks + * are skipped automatically. * * Returns: flow status. */ @@ -54,6 +55,8 @@ gst_riff_read_chunk (GstElement * element, guint64 offset = *_offset; gchar dbg[5] = { 0, }; +skip_junk: + if ((res = gst_pad_pull_range (pad, offset, 8, &buf)) != GST_FLOW_OK) return res; else if (!buf || GST_BUFFER_SIZE (buf) < 8) { @@ -69,18 +72,22 @@ gst_riff_read_chunk (GstElement * element, memcpy (dbg, tag, 4); GST_DEBUG_OBJECT (element, "tag=%s, size=%u", dbg, size); - if (*tag == GST_RIFF_TAG_JUNK && size == 0) { - buf = gst_buffer_new (); - } else { - if ((res = gst_pad_pull_range (pad, offset + 8, size, &buf)) != GST_FLOW_OK) - return res; - if (!buf || GST_BUFFER_SIZE (buf) < size) { - GST_DEBUG_OBJECT (element, "not enough data (available=%u, needed=%u)", - (buf) ? GST_BUFFER_SIZE (buf) : 0, size); - if (buf) - gst_buffer_unref (buf); - return GST_FLOW_ERROR; - } + /* skip 'JUNK' chunks */ + if (*tag == GST_RIFF_TAG_JUNK) { + *_offset += 8 + GST_ROUND_UP_2 (size); + offset += 8 + GST_ROUND_UP_2 (size); + GST_DEBUG_OBJECT (element, "skipping JUNK chunk"); + goto skip_junk; + } + + if ((res = gst_pad_pull_range (pad, offset + 8, size, &buf)) != GST_FLOW_OK) + return res; + else if (!buf || GST_BUFFER_SIZE (buf) < size) { + GST_DEBUG_OBJECT (element, "not enough data (available=%u, needed=%u)", + (buf) ? GST_BUFFER_SIZE (buf) : 0, size); + if (buf) + gst_buffer_unref (buf); + return GST_FLOW_UNEXPECTED; } *_chunk_data = buf; @@ -101,7 +108,7 @@ gst_riff_read_chunk (GstElement * element, * * Reads a single chunk. * - * Returns: the fourcc tag of this chunk, or 0 on error. + * Returns: the fourcc tag of this chunk, or FALSE on error */ gboolean