[xiph-commits] r7364 - trunk/oggdsf/src/lib/core/ogg/libOOOgg

illiminable at dactyl.lonelymoon.com illiminable
Mon Jul 26 21:45:04 PDT 2004


Author: illiminable
Date: Mon Jul 26 21:45:04 2004
New Revision: 7364

Modified:
trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp
Log:
* Removed some bugs in the buffer returning wrong information in bytesavail.

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp	2004-07-27 04:42:08 UTC (rev 7363)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp	2004-07-27 04:45:03 UTC (rev 7364)
@@ -103,8 +103,11 @@
}

unsigned long CircularBuffer::spaceLeft() {
+	bufASSERT(mReadPtr <= mBufferSize);
+	bufASSERT(mWritePtr <= mBufferSize);
+
//The write pointer is always treated as being equal to or in front of the read pointer.
-	return mBufferSize - numBytesAvail() - 1;
+	//return mBufferSize - numBytesAvail() - 1;
if (mReadPtr > mWritePtr) {
//Read pointer is to the right of the Write pointer
// Since the write pointer is always in front, this means all the data from the read ptr
@@ -113,14 +116,17 @@
//
////

-
+		bufASSERT(mReadPtr > mWritePtr);
return  (mReadPtr - mWritePtr - 1);
} else {
-
+		bufASSERT(mReadPtr <= mWritePtr);
return mBufferSize + mReadPtr - mWritePtr ;
}
}
unsigned long CircularBuffer::numBytesAvail() {
+	bufASSERT(mReadPtr <= mBufferSize);
+	bufASSERT(mWritePtr <= mBufferSize);
+
if (mReadPtr > mWritePtr) {
//Read pointer is to the right of the Write pointer
// Since the write pointer is always in front, this means all the data from the read ptr
@@ -129,8 +135,10 @@
//
////

-
-		return  (mBufferSize - 1 - mWritePtr - mReadPtr);
+		bufASSERT(mReadPtr > mWritePtr);
+
+		//Here
+		return  (mBufferSize + 1 + mWritePtr - mReadPtr);
} else {
//if (mReadPtr <= mWritePtr)
return mWritePtr - mReadPtr;



More information about the commits mailing list