[gst-cvs] CVS: gstreamer/libs/bytestream gstbytestream.c,1.1.2.12,1.1.2.13 gstbytestream.h,1.1.2.7,1.1.2.8
Joshua Pritikin
jpritikin at users.sourceforge.net
Fri Sep 28 15:59:02 PDT 2001
Update of /cvsroot/gstreamer/gstreamer/libs/bytestream
In directory usw-pr-cvs1:/tmp/cvs-serv32269
Modified Files:
Tag: BRANCH-EVENTS1
gstbytestream.c gstbytestream.h
Log Message:
1 Handle events.
2 Add gst_bytestream_flush_fast.
Index: gstbytestream.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/libs/bytestream/Attic/gstbytestream.c,v
retrieving revision 1.1.2.12
retrieving revision 1.1.2.13
diff -u -d -r1.1.2.12 -r1.1.2.13
--- gstbytestream.c 2001/09/25 22:09:45 1.1.2.12
+++ gstbytestream.c 2001/09/28 22:58:38 1.1.2.13
@@ -120,9 +120,37 @@
bs_print ("get_next_buf: pulling buffer\n");
nextbuf = gst_pad_pull (bs->pad);
+ // g_assert (nextbuf); ??
if (!nextbuf)
return FALSE;
+ if (GST_IS_EVENT (nextbuf)) {
+ GstEvent *ev = GST_EVENT (nextbuf);
+ gint ret=0;
+ gboolean result = FALSE;
+
+ switch (ev->type) {
+ case GST_EVENT_EOS:
+ // do something
+ ret = TRUE;
+ break;
+
+ case GST_EVENT_DISCONTINUOUS:
+ gst_bytestream_flush_fast (bs, bs->listavail);
+ ret = TRUE;
+ break;
+
+ default:
+ g_warning ("Ignoring unknown event %d", ev->type);
+ break;
+ }
+
+ gst_event_free (ev);
+
+ if (ret)
+ return result;
+ }
+
bs_print ("get_next_buf: got buffer of %d bytes\n", GST_BUFFER_SIZE (nextbuf));
// first see if there are any buffers in the list at all
@@ -315,19 +343,32 @@
gboolean
gst_bytestream_flush (GstByteStream * bs, guint32 len)
{
- GstBuffer *headbuf;
-
bs_print ("flush: flushing %d bytes\n", len);
// make sure we have enough
bs_print ("flush: there are %d bytes in the list\n", bs->listavail);
if (len > bs->listavail) {
if (!gst_bytestream_fill_bytes (bs, len))
- return FALSE;
+ {
+ gst_bytestream_flush_fast (bs, bs->listavail);
+ return FALSE;
+ }
bs_print ("flush: there are now %d bytes in the list\n", bs->listavail);
}
- // repeat until we've flushed enough data
+ gst_bytestream_flush_fast (bs, len);
+
+ return TRUE;
+}
+
+void
+gst_bytestream_flush_fast (GstByteStream * bs, guint32 len)
+{
+ GstBuffer *headbuf;
+
+ g_return_if_fail (bs);
+ g_assert (len <= bs->listavail);
+
while (len > 0) {
headbuf = GST_BUFFER (bs->buflist->data);
@@ -367,15 +408,14 @@
bs_print ("flush: bottom of while(), len is now %d\n", len);
}
-
- return TRUE;
}
GstBuffer *
gst_bytestream_read_loc (GST_WHERE_ARGS_ GstByteStream * bs, guint32 len)
{
GstBuffer *buf = gst_bytestream_peek_loc (GST_WHERE_VARS_ bs, len);
- gst_bytestream_flush (bs, len);
+ if (buf)
+ gst_bytestream_flush_fast (bs, len);
return buf;
}
Index: gstbytestream.h
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/libs/bytestream/Attic/gstbytestream.h,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -u -d -r1.1.2.7 -r1.1.2.8
--- gstbytestream.h 2001/09/23 06:03:20 1.1.2.7
+++ gstbytestream.h 2001/09/28 22:58:38 1.1.2.8
@@ -43,6 +43,7 @@
GstBuffer* gst_bytestream_peek_loc (GST_WHERE_ARGS_ GstByteStream *bs, guint32 len);
guint8* gst_bytestream_peek_bytes (GstByteStream *bs, guint32 len);
gboolean gst_bytestream_flush (GstByteStream *bs, guint32 len);
+void gst_bytestream_flush_fast (GstByteStream * bs, guint32 len);
void gst_bytestream_print_status (GstByteStream *bs);
More information about the Gstreamer-commits
mailing list