diff options
author | Steve Baker <steve@stevebaker.org> | 2002-05-15 19:08:49 +0000 |
---|---|---|
committer | Steve Baker <steve@stevebaker.org> | 2002-05-15 19:08:49 +0000 |
commit | 9275ce0e157d95064ab6d5ea47f88c16df6598ec (patch) | |
tree | 4267d8b2597a0227fe8a60dbb6315c46fcf2183e /ext | |
parent | 012aaa2cb0675d8c65e5d4f38f5b7e3f1975ac8a (diff) | |
download | gst-plugins-bad-9275ce0e157d95064ab6d5ea47f88c16df6598ec.tar.gz gst-plugins-bad-9275ce0e157d95064ab6d5ea47f88c16df6598ec.tar.bz2 gst-plugins-bad-9275ce0e157d95064ab6d5ea47f88c16df6598ec.zip |
use new bytestream api
Original commit message from CVS:
use new bytestream api
Diffstat (limited to 'ext')
-rw-r--r-- | ext/audiofile/gstafparse.c | 61 | ||||
-rw-r--r-- | ext/jack/gstjack.c | 2 | ||||
-rw-r--r-- | ext/ladspa/gstladspa.c | 5 |
3 files changed, 50 insertions, 18 deletions
diff --git a/ext/audiofile/gstafparse.c b/ext/audiofile/gstafparse.c index 0e4876dd..32a12dce 100644 --- a/ext/audiofile/gstafparse.c +++ b/ext/audiofile/gstafparse.c @@ -224,10 +224,12 @@ gst_afparse_loop(GstElement *element) if (bypass_afread){ GstEvent *event = NULL; guint32 waiting; + guint32 got_bytes; + do { - buf = gst_bytestream_read (bs, bytes_per_read); - if (buf == NULL) { + got_bytes = gst_bytestream_read (bs, &buf, bytes_per_read); + if (got_bytes == 0) { /* we need to check for an event. */ gst_bytestream_get_status (bs, &waiting, &event); if (event && GST_EVENT_TYPE(event) == GST_EVENT_EOS) { @@ -237,8 +239,16 @@ gst_afparse_loop(GstElement *element) } } else { + GST_BUFFER_TIMESTAMP(buf) = afparse->timestamp; gst_pad_push (afparse->srcpad, buf); - afparse->timestamp += numframes * 1E9 / afparse->rate; + if (got_bytes != bytes_per_read){ + /* this shouldn't happen very often */ + /* FIXME calculate the timestamps based on the fewer bytes received */ + + } + else { + afparse->timestamp += frames_per_read * 1E9 / afparse->rate; + } } } while (TRUE); @@ -424,29 +434,49 @@ static ssize_t gst_afparse_vf_read (AFvirtualfile *vfile, void *data, size_t nbytes) { GstByteStream *bs = (GstByteStream*)vfile->closure; - guint8 *bytes; + guint8 *bytes = NULL; GstEvent *event = NULL; guint32 waiting; + guint32 got_bytes; + /*gchar *debug_str;*/ - while (!(bytes = gst_bytestream_peek_bytes(bs, nbytes))){ + got_bytes = gst_bytestream_peek_bytes(bs, &bytes, nbytes); + + while (got_bytes != nbytes){ /* handle events */ gst_bytestream_get_status (bs, &waiting, &event); - if (!event) return 0; + /* FIXME this event handling isn't right yet */ + if (!event){ + /*g_print("no event found with %u bytes\n", got_bytes);*/ + return 0; + } if (event){ - if (GST_EVENT_TYPE(event) == GST_EVENT_EOS) return 0; - if (GST_EVENT_TYPE(event) == GST_EVENT_DISCONTINUOUS){ + g_print("got event\n"); + if (GST_EVENT_TYPE(event) == GST_EVENT_EOS){ + return 0; + } + else if (GST_EVENT_TYPE(event) == GST_EVENT_FLUSH){ + g_print("flush\n"); + } + else if (GST_EVENT_TYPE(event) == GST_EVENT_DISCONTINUOUS){ g_print("seek done\n"); + got_bytes = gst_bytestream_peek_bytes(bs, &bytes, nbytes); + } + else { + g_print("unknown event %d", GST_EVENT_TYPE(event)); + got_bytes = gst_bytestream_peek_bytes(bs, &bytes, nbytes); } } } - memcpy(data, bytes, nbytes); - gst_bytestream_flush_fast(bs, nbytes); - - /*g_print("read %d bytes\n", nbytes);*/ + memcpy(data, bytes, got_bytes); + gst_bytestream_flush_fast(bs, got_bytes); - return nbytes; + /* debug_str = g_strndup((gchar*)bytes, got_bytes); + g_print("read %u bytes: %s\n", got_bytes, debug_str); + */ + return got_bytes; } static long @@ -468,9 +498,10 @@ gst_afparse_vf_seek (AFvirtualfile *vfile, long offset, int is_relative) if (offset == 0) return current_offset; type = GST_SEEK_BYTEOFFSET_CUR; } - + + g_print("doing seek to %d, current offset %lld\n", (gint)offset, current_offset); if (gst_bytestream_seek(bs, type, (gint64)offset)){ - g_print("doing seek to %d\n", (gint)offset); + return offset; } return 0; diff --git a/ext/jack/gstjack.c b/ext/jack/gstjack.c index ab0e4a3c..4cf4df58 100644 --- a/ext/jack/gstjack.c +++ b/ext/jack/gstjack.c @@ -421,7 +421,7 @@ gst_jack_loop (GstElement *element) if (!pad->bs) pad->bs = gst_bytestream_new (pad->pad); - if (!(peeked = gst_bytestream_peek_bytes (pad->bs, len))) { + if (gst_bytestream_peek_bytes (pad->bs, (guint8**)&peeked, len) < len) { gst_bytestream_get_status(pad->bs, &avail, &event); if (event) { g_warning("got an event on jacksink"); diff --git a/ext/ladspa/gstladspa.c b/ext/ladspa/gstladspa.c index 4ad7d3fd..0e75c41d 100644 --- a/ext/ladspa/gstladspa.c +++ b/ext/ladspa/gstladspa.c @@ -716,6 +716,7 @@ gst_ladspa_loop(GstElement *element) guint num_processed, num_to_process; GstEvent *event = NULL; guint32 waiting; + guint32 got_bytes; LADSPA_Data **data_in, **data_out; GstBuffer **buffers_in, **buffers_out; GstBufferPool *bufpool; @@ -750,9 +751,9 @@ gst_ladspa_loop(GstElement *element) /* first get all the necessary data from the input ports */ for (i=0 ; i<numsinkpads ; i++){ GST_DEBUG (0, "pulling %u bytes through channel %d'sbytestream", bufferbytesize, i); - buffers_in[i] = gst_bytestream_read (bytestreams[i], bufferbytesize); + got_bytes = gst_bytestream_read (bytestreams[i], buffers_in + i, bufferbytesize); - if (buffers_in[i] == NULL) { + if (got_bytes != bufferbytesize) { /* we need to check for an event. */ gst_bytestream_get_status (bytestreams[i], &waiting, &event); |