[gst-cvs] CVS: gstreamer/libs/bytestream gstbytestream.c,1.2,1.3 gstbytestream.h,1.2,1.3
Wim Taymans
wtay at users.sourceforge.net
Sun Oct 21 12:15:14 PDT 2001
- Previous message: [gst-cvs] CVS: gstreamer/gst cothreads.c,1.43,1.44 gst.c,1.44,1.45 gstautoplug.c,1.24,1.25 gstbin.c,1.93,1.94 gstbin.h,1.24,1.25 gstbuffer.c,1.39,1.40 gstbuffer.h,1.28,1.29 gstbufferpool.c,1.20,1.21 gstbufferpool.h,1.12,1.13 gstclock.c,1.13,1.14 gstelement.c,1.78,1.79 gstelement.h,1.62,1.63 gstelementfactory.c,1.50,1.51 gstevent.c,1.2,1.3 gstinfo.c,1.27,1.28 gstobject.c,1.27,1.28 gstpad.c,1.117,1.118 gstpad.h,1.65,1.66 gstpipeline.h,1.12,1.13 gstplugin.c,1.66,1.67 gstplugin.h,1.21,1.22 gstpluginfeature.c,1.3,1.4 gstpluginfeature.h,1.1,1.2 gstscheduler.c,1.33,1.34 gstscheduler.h,1.8,1.9 gsttimecache.c,1.1,1.2 gsttimecache.h,1.1,1.2 gsttype.c,1.31,1.32 gstutils.c,1.19,1.20 gstutils.h,1.10,1.11
- Next message: [gst-cvs] CVS: gstreamer configure.base,1.93,1.94
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/gstreamer/gstreamer/libs/bytestream
In directory usw-pr-cvs1:/tmp/cvs-serv11956
Modified Files:
gstbytestream.c gstbytestream.h
Log Message:
Applied vishnus patch:
* Check all return codes and reliably return NULL if no more data is
available.
* Split _flush into _flush/_flush_fast. This is partly to make the code
self-documenting -- the flush in gst_bytestream_read cannot fail. Also,
this is a slight optimization.[A
Index: gstbytestream.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/libs/bytestream/gstbytestream.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- gstbytestream.c 2001/10/17 10:21:25 1.2
+++ gstbytestream.c 2001/10/21 19:14:48 1.3
@@ -118,6 +118,10 @@
bs_print ("get_next_buf: pulling buffer\n");
nextbuf = gst_pad_pull (bs->pad);
+
+ if (!nextbuf)
+ return FALSE;
+
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
@@ -175,7 +179,8 @@
// as long as we don't have enough, we get more buffers
while (bs->listavail < len) {
bs_print ("fill_bytes: there are %d bytes in the list, we need %d\n", bs->listavail, len);
- gst_bytestream_get_next_buf (bs);
+ if (!gst_bytestream_get_next_buf (bs))
+ return FALSE;
}
return TRUE;
@@ -195,7 +200,8 @@
// make sure we have enough
bs_print ("peek: there are %d bytes in the list\n", bs->listavail);
if (len > bs->listavail) {
- gst_bytestream_fill_bytes (bs, len);
+ if (!gst_bytestream_fill_bytes (bs, len))
+ return NULL;
bs_print ("peek: there are now %d bytes in the list\n", bs->listavail);
}
bs_status (bs);
@@ -243,7 +249,8 @@
// make sure we have enough
bs_print ("peek_bytes: there are %d bytes in the list\n", bs->listavail);
if (len > bs->listavail) {
- gst_bytestream_fill_bytes (bs, len);
+ if (!gst_bytestream_fill_bytes (bs, len))
+ return NULL;
bs_print ("peek_bytes: there are now %d bytes in the list\n", bs->listavail);
}
bs_status (bs);
@@ -309,21 +316,33 @@
gboolean
gst_bytestream_flush (GstByteStream * bs, guint32 len)
{
- GstBuffer *headbuf;
-
bs_print ("flush: flushing %d bytes\n", len);
- if (bs->assembled) {
- g_free (bs->assembled);
- bs->assembled = NULL;
- }
// make sure we have enough
bs_print ("flush: there are %d bytes in the list\n", bs->listavail);
if (len > bs->listavail) {
- gst_bytestream_fill_bytes (bs, len);
+ if (!gst_bytestream_fill_bytes (bs, len))
+ return FALSE;
bs_print ("flush: there are now %d bytes in the list\n", bs->listavail);
}
+ gst_bytestream_flush_fast (bs, len);
+
+ return TRUE;
+}
+
+void
+gst_bytestream_flush_fast (GstByteStream * bs, guint32 len)
+{
+ GstBuffer *headbuf;
+
+ g_assert (len <= bs->listavail);
+
+ if (bs->assembled) {
+ g_free (bs->assembled);
+ bs->assembled = NULL;
+ }
+
// repeat until we've flushed enough data
while (len > 0) {
headbuf = GST_BUFFER (bs->buflist->data);
@@ -364,15 +383,17 @@
bs_print ("flush: bottom of while(), len is now %d\n", len);
}
-
- return TRUE;
}
GstBuffer *
gst_bytestream_read (GstByteStream * bs, guint32 len)
{
GstBuffer *buf = gst_bytestream_peek (bs, len);
- gst_bytestream_flush (bs, len);
+ if (!buf)
+ return NULL;
+
+ gst_bytestream_flush_fast (bs, len);
+
return buf;
}
Index: gstbytestream.h
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/libs/bytestream/gstbytestream.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- gstbytestream.h 2001/10/17 10:21:25 1.2
+++ gstbytestream.h 2001/10/21 19:14:48 1.3
@@ -47,6 +47,7 @@
GstBuffer* gst_bytestream_peek (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);
- Previous message: [gst-cvs] CVS: gstreamer/gst cothreads.c,1.43,1.44 gst.c,1.44,1.45 gstautoplug.c,1.24,1.25 gstbin.c,1.93,1.94 gstbin.h,1.24,1.25 gstbuffer.c,1.39,1.40 gstbuffer.h,1.28,1.29 gstbufferpool.c,1.20,1.21 gstbufferpool.h,1.12,1.13 gstclock.c,1.13,1.14 gstelement.c,1.78,1.79 gstelement.h,1.62,1.63 gstelementfactory.c,1.50,1.51 gstevent.c,1.2,1.3 gstinfo.c,1.27,1.28 gstobject.c,1.27,1.28 gstpad.c,1.117,1.118 gstpad.h,1.65,1.66 gstpipeline.h,1.12,1.13 gstplugin.c,1.66,1.67 gstplugin.h,1.21,1.22 gstpluginfeature.c,1.3,1.4 gstpluginfeature.h,1.1,1.2 gstscheduler.c,1.33,1.34 gstscheduler.h,1.8,1.9 gsttimecache.c,1.1,1.2 gsttimecache.h,1.1,1.2 gsttype.c,1.31,1.32 gstutils.c,1.19,1.20 gstutils.h,1.10,1.11
- Next message: [gst-cvs] CVS: gstreamer configure.base,1.93,1.94
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Gstreamer-commits
mailing list