summaryrefslogtreecommitdiffstats
path: root/gst-libs/gst/riff
diff options
context:
space:
mode:
Diffstat (limited to 'gst-libs/gst/riff')
-rw-r--r--gst-libs/gst/riff/riff-read.c24
-rw-r--r--gst-libs/gst/riff/riff-read.h3
2 files changed, 22 insertions, 5 deletions
diff --git a/gst-libs/gst/riff/riff-read.c b/gst-libs/gst/riff/riff-read.c
index 4d379a7b..fbbbae26 100644
--- a/gst-libs/gst/riff/riff-read.c
+++ b/gst-libs/gst/riff/riff-read.c
@@ -260,7 +260,7 @@ gst_riff_peek_head (GstRiffRead * riff,
*/
GstBuffer *
-gst_riff_read_element_data (GstRiffRead * riff, guint length, guint * got_bytes)
+gst_riff_peek_element_data (GstRiffRead * riff, guint length, guint * got_bytes)
{
GstBuffer *buf = NULL;
guint32 got;
@@ -272,14 +272,28 @@ gst_riff_read_element_data (GstRiffRead * riff, guint length, guint * got_bytes)
return NULL;
}
+ if (got_bytes)
+ *got_bytes = got;
+
+ return buf;
+}
+
+GstBuffer *
+gst_riff_read_element_data (GstRiffRead * riff, guint length, guint * got_bytes)
+{
+ GstBuffer *buf;
+
+ if (!(buf = gst_riff_peek_element_data (riff, length, got_bytes)))
+ return NULL;
+
/* we need 16-bit alignment */
if (length & 1)
length++;
- gst_bytestream_flush (riff->bs, length);
-
- if (got_bytes)
- *got_bytes = got;
+ if (!gst_bytestream_flush (riff->bs, length)) {
+ gst_buffer_unref (buf);
+ return NULL;
+ }
return buf;
}
diff --git a/gst-libs/gst/riff/riff-read.h b/gst-libs/gst/riff/riff-read.h
index d44c4ed7..a0c12606 100644
--- a/gst-libs/gst/riff/riff-read.h
+++ b/gst-libs/gst/riff/riff-read.h
@@ -85,6 +85,9 @@ gboolean gst_riff_read_header (GstRiffRead *read,
GstBuffer *gst_riff_read_element_data (GstRiffRead *riff,
guint length,
guint *got_bytes);
+GstBuffer *gst_riff_peek_element_data (GstRiffRead *riff,
+ guint length,
+ guint *got_bytes);
/*
* Utility functions (including byteswapping).
*/