summaryrefslogtreecommitdiffstats
path: root/gst-libs/gst/riff/riff-read.c
diff options
context:
space:
mode:
authorIain Holmes <iain@prettypeople.org>2004-05-08 00:33:39 +0000
committerIain Holmes <iain@prettypeople.org>2004-05-08 00:33:39 +0000
commit3a1737c07699370279eae64a71dded925c8be1d4 (patch)
tree842183888e6662ae265779778b6c9cdfa7c02984 /gst-libs/gst/riff/riff-read.c
parent5093ae66b9fb4b124a28976a9a4cb58c12ab8f75 (diff)
downloadgst-plugins-bad-3a1737c07699370279eae64a71dded925c8be1d4.tar.gz
gst-plugins-bad-3a1737c07699370279eae64a71dded925c8be1d4.tar.bz2
gst-plugins-bad-3a1737c07699370279eae64a71dded925c8be1d4.zip
Rewrote wavparse to use riff-read instead of doing bytestream stuff by hand.
Original commit message from CVS: Rewrote wavparse to use riff-read instead of doing bytestream stuff by hand. Made some useful functions in riff-read non-static.
Diffstat (limited to 'gst-libs/gst/riff/riff-read.c')
-rw-r--r--gst-libs/gst/riff/riff-read.c47
1 files changed, 37 insertions, 10 deletions
diff --git a/gst-libs/gst/riff/riff-read.c b/gst-libs/gst/riff/riff-read.c
index fa153e68..388ea753 100644
--- a/gst-libs/gst/riff/riff-read.c
+++ b/gst-libs/gst/riff/riff-read.c
@@ -150,7 +150,7 @@ gst_riff_read_element_level_up (GstRiffRead * riff)
* TRUE on success or FALSE on failure.
*/
-static gboolean
+gboolean
gst_riff_peek_head (GstRiffRead * riff,
guint32 * tag, guint32 * length, guint * level_up)
{
@@ -190,16 +190,40 @@ gst_riff_peek_head (GstRiffRead * riff,
* Return: the data, as a GstBuffer.
*/
-static GstBuffer *
-gst_riff_read_element_data (GstRiffRead * riff, guint length)
+GstBuffer *
+gst_riff_read_element_data (GstRiffRead * riff, guint length, guint * got_bytes)
{
GstBuffer *buf = NULL;
+ guint32 got;
- if (gst_bytestream_peek (riff->bs, &buf, length) != length) {
- GST_ELEMENT_ERROR (riff, RESOURCE, READ, (NULL), (NULL));
- if (buf)
- gst_buffer_unref (buf);
- return NULL;
+ while ((got = gst_bytestream_peek (riff->bs, &buf, length)) != length) {
+ /*GST_ELEMENT_ERROR (riff, RESOURCE, READ, (NULL), (NULL)); */
+ GstEvent *event = NULL;
+ guint32 remaining;
+
+ gst_bytestream_get_status (riff->bs, &remaining, &event);
+ if (GST_IS_EVENT (event)) {
+ gst_pad_event_default (riff->sinkpad, event);
+ if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
+
+ if (buf)
+ gst_buffer_unref (buf);
+
+ if (got_bytes)
+ *got_bytes = got;
+
+ return NULL;
+ }
+ } else {
+ GST_ELEMENT_ERROR (riff, RESOURCE, READ, (NULL), (NULL));
+ if (buf)
+ gst_buffer_unref (buf);
+
+ if (got_bytes)
+ *got_bytes = got;
+
+ return NULL;
+ }
}
/* we need 16-bit alignment */
@@ -208,6 +232,9 @@ gst_riff_read_element_data (GstRiffRead * riff, guint length)
gst_bytestream_flush (riff->bs, length);
+ if (got_bytes)
+ *got_bytes = got;
+
return buf;
}
@@ -363,7 +390,7 @@ gst_riff_read_data (GstRiffRead * riff, guint32 * tag, GstBuffer ** buf)
return FALSE;
gst_bytestream_flush_fast (riff->bs, 8);
- return ((*buf = gst_riff_read_element_data (riff, length)) != NULL);
+ return ((*buf = gst_riff_read_element_data (riff, length, NULL)) != NULL);
}
/*
@@ -559,7 +586,7 @@ gst_riff_read_strf_auds (GstRiffRead * riff, gst_riff_strf_auds ** header)
if (!gst_riff_read_data (riff, &tag, &buf))
return FALSE;
- if (tag != GST_RIFF_TAG_strf) {
+ if (tag != GST_RIFF_TAG_strf && tag != GST_RIFF_TAG_fmt) {
g_warning ("Not a strf chunk");
gst_buffer_unref (buf);
return FALSE;