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 | |
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
-rw-r--r-- | ext/audiofile/gstafparse.c | 61 | ||||
-rw-r--r-- | ext/jack/gstjack.c | 2 | ||||
-rw-r--r-- | ext/ladspa/gstladspa.c | 5 | ||||
-rw-r--r-- | gst/flx/gstflxdec.c | 5 | ||||
-rw-r--r-- | gst/qtdemux/qtdemux.c | 9 |
5 files changed, 58 insertions, 24 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); diff --git a/gst/flx/gstflxdec.c b/gst/flx/gstflxdec.c index 66079ab3..1354139d 100644 --- a/gst/flx/gstflxdec.c +++ b/gst/flx/gstflxdec.c @@ -435,11 +435,12 @@ static GstBuffer* flx_get_data(GstFlxDec *flxdec, gulong size) { GstBuffer *retbuf; + guint32 got_bytes; g_return_val_if_fail (flxdec != NULL, NULL); - retbuf = gst_bytestream_read (flxdec->bs, size); - if (!retbuf) { + got_bytes = gst_bytestream_read (flxdec->bs, &retbuf, size); + if (got_bytes < size) { GstEvent *event; guint32 remaining; diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index 31c3f2da..968ed1ab 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c @@ -362,7 +362,7 @@ gst_qtp_read_bytes_atom_head(GstQTDemux * qtdemux,GstQtpAtom * atom) /* FIXME this can't be right, rewrite with _read */ do { /* do ... while (event()) is necessary for bytestream events */ if (!amh) { - if ((amh = (GstQtpAtomMinHeader*) gst_bytestream_peek_bytes (bs, 8))) { + if (gst_bytestream_peek_bytes (bs, (guint8**)&amh, 8) == 8) { atom->size = GUINT32_FROM_BE(amh->size); atom->type = amh->type; /* don't need to turn this around magicly FIXME this can depend on endiannes */ atom->start = qtdemux->bs_pos; @@ -372,7 +372,7 @@ gst_qtp_read_bytes_atom_head(GstQTDemux * qtdemux,GstQtpAtom * atom) } if (amh) { if (atom->size == 1) { /* need to peek extended size field */ - if ((esize = (guint64*) gst_bytestream_peek_bytes (bs, 8))) { + if (gst_bytestream_peek_bytes (bs, (guint8**)&esize, 8) == 8) { atom->size = GUINT64_FROM_BE(*esize); gst_bytestream_flush (bs, 8); qtdemux->bs_pos += 8; @@ -391,8 +391,9 @@ gst_qtp_read_bytes(GstQTDemux * qtdemux, void * buffer, size_t size) { void * data; GstByteStream * bs = qtdemux->bs; + do { - if ((data = gst_bytestream_peek_bytes (bs,size))) { + if (gst_bytestream_peek_bytes (bs, (guint8**)&data, size) == size) { memcpy(buffer,data,size); gst_bytestream_flush(bs,size); qtdemux->bs_pos += size; @@ -407,7 +408,7 @@ gst_qtp_read(GstQTDemux * qtdemux, size_t size) GstBuffer * buf; GstByteStream * bs = qtdemux->bs; do { - if ((buf = gst_bytestream_read (bs,size))) { + if (gst_bytestream_read (bs, &buf, size) == size) { qtdemux->bs_pos += size; return buf; } |