[xiph-commits] r7339 - in trunk/oggdsf/src: lib/core/ogg/libOOOgg

illiminable at dactyl.lonelymoon.com illiminable
Sun Jul 25 15:57:36 PDT 2004


tests/testCircleBuffer
Message-ID: <20040725225736.8DF789AAAB at dactyl.lonelymoon.com>

Author: illiminable
Date: Sun Jul 25 15:57:36 2004
New Revision: 7339

Modified:
trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp
trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.h
trunk/oggdsf/src/lib/core/ogg/libOOOgg/INotifyArrival.h
trunk/oggdsf/src/lib/core/ogg/libOOOgg/INotifyComplete.h
trunk/oggdsf/src/lib/core/ogg/libOOOgg/IOggCallback.h
trunk/oggdsf/src/lib/core/ogg/libOOOgg/IOggPackSource.h
trunk/oggdsf/src/lib/core/ogg/libOOOgg/IStampedOggPacketSink.h
trunk/oggdsf/src/lib/core/ogg/libOOOgg/libOOOgg.vcproj
trunk/oggdsf/src/tests/testCircleBuffer/testCircleBuffer.cpp
Log:
* Removed some redundant files from project
* Tidied interfaces a bit

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp	2004-07-25 22:16:47 UTC (rev 7338)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp	2004-07-25 22:57:34 UTC (rev 7339)
@@ -18,29 +18,35 @@

unsigned long CircularBuffer::read(unsigned char* outData, unsigned long inBytesToRead) {

-	unsigned long locBytesToRead =			(inBytesToRead > numBytesAvail())	?	numBytesAvail()
-																				:	inBytesToRead;
+	//If requested less or equal to what we have, read that amount, otherwise read as much as we've got.
+	unsigned long locBytesToRead =			(inBytesToRead <= numBytesAvail())	?	inBytesToRead
+																				:	numBytesAvail();
+	//locBytesToRead = the lower of numBytesAvail() and inBytesToRead
+	bufASSERT(locBytesToRead <= inBytesToRead);
+	bufASSERT(locBytesToRead <= numBytesAvail());
+
+	unsigned long locEndDistance = mBufferSize - mReadPtr;
+	bufASSERT(locEndDistance <= mBufferSize);

-	unsigned long locEndDistance = mBufferSize - mReadPtr;
//Where we will be if in relation to the end of the raw buffer if we wrote the bufferout from here.
//Negative values indicate bytes past the end ofthe buffer.
+	//Positive values indicate bytes before the end of buffer.
signed long locEndOffset = locEndDistance - locBytesToRead;
-
+
if (locEndOffset >= 0) {
//Within the buffer
+		bufASSERT(mReadPtr < mBufferSize);
+
memcpy((void*)outData, (const void*)(mBuffer + mReadPtr), locBytesToRead);
-		mReadPtr += locBytesToRead;
} else {
//Copy from the end of the raw buffer as much as we can into outdtata
memcpy((void*)outData, (const void*)(mBuffer + mReadPtr), locEndDistance);

//Copy from the start of the raw buffer whatever is left
-		memcpy((void*)(outData + locEndDistance), (const void*)(mBuffer + mReadPtr + locEndDistance), locBytesToRead - locEndDistance);
-		mReadPtr = (mReadPtr + locBytesToRead) % mBufferSize;
+		memcpy((void*)(outData + locEndDistance), (const void*)(mBuffer), locBytesToRead - locEndDistance);
}
+	mReadPtr = (mReadPtr + locBytesToRead) % mBufferSize;

-
-
return locBytesToRead;
}

@@ -87,18 +93,19 @@
//Within the buffer
memcpy((void*)(mBuffer + mWritePtr), ((const void*)inData), locBytesToWrite);

-		mWritePtr += locBytesToWrite;
+
} else {

//Copy from the end of the raw buffer as much as we can into outdtata
memcpy((void*)(mBuffer + mWritePtr), (const void*)inData, locEndDistance);

//Copy from the start of the raw buffer whatever is left
-		memcpy((void*)(mBuffer + mWritePtr + locEndDistance), (const void*)(inData + locEndDistance), locBytesToWrite - locEndDistance);
+		memcpy((void*)(mBuffer), (const void*)(inData + locEndDistance), locBytesToWrite - locEndDistance);

//Advance the write pointer wrapping voer the end.
-		mWritePtr = (mWritePtr + locBytesToWrite) % mBufferSize;
+
}
+	mWritePtr = (mWritePtr + locBytesToWrite) % mBufferSize;

return locBytesToWrite;


Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.h	2004-07-25 22:16:47 UTC (rev 7338)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.h	2004-07-25 22:57:34 UTC (rev 7339)
@@ -18,5 +18,6 @@
unsigned long mReadPtr;
unsigned long mWritePtr;

+	void bufASSERT(bool inBool) {	if (!inBool) throw 0; };
unsigned char* mBuffer;
};

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/INotifyArrival.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/INotifyArrival.h	2004-07-25 22:16:47 UTC (rev 7338)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/INotifyArrival.h	2004-07-25 22:57:34 UTC (rev 7339)
@@ -33,8 +33,5 @@
class LIBOOOGG_API INotifyArrival
{
public:
-	INotifyArrival(void);
-	virtual ~INotifyArrival(void);
-
virtual void notifyArrival() = 0;
};

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/INotifyComplete.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/INotifyComplete.h	2004-07-25 22:16:47 UTC (rev 7338)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/INotifyComplete.h	2004-07-25 22:57:34 UTC (rev 7339)
@@ -33,7 +33,5 @@
class LIBOOOGG_API INotifyComplete
{
public:
-	INotifyComplete(void);
-	virtual ~INotifyComplete(void);
virtual void NotifyComplete() = 0;
};

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/IOggCallback.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/IOggCallback.h	2004-07-25 22:16:47 UTC (rev 7338)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/IOggCallback.h	2004-07-25 22:57:34 UTC (rev 7339)
@@ -35,8 +35,5 @@
class LIBOOOGG_API IOggCallback
{
public:
-	IOggCallback(void);
-	virtual ~IOggCallback(void);
-
virtual bool acceptOggPage(OggPage* inOggPage) = 0;
};

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/IOggPackSource.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/IOggPackSource.h	2004-07-25 22:16:47 UTC (rev 7338)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/IOggPackSource.h	2004-07-25 22:57:34 UTC (rev 7339)
@@ -36,6 +36,5 @@
{
public:
virtual OggPacket* getPacket(unsigned long inPacketNo) = 0;
-
virtual unsigned long numPackets() = 0;
};

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/IStampedOggPacketSink.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/IStampedOggPacketSink.h	2004-07-25 22:16:47 UTC (rev 7338)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/IStampedOggPacketSink.h	2004-07-25 22:57:34 UTC (rev 7339)
@@ -36,8 +36,5 @@
class LIBOOOGG_API IStampedOggPacketSink
{
public:
-	IStampedOggPacketSink(void);
-	virtual ~IStampedOggPacketSink(void);
-
virtual bool acceptStampedOggPacket(StampedOggPacket* inPacket) = 0;
};

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/libOOOgg.vcproj
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/libOOOgg.vcproj	2004-07-25 22:16:47 UTC (rev 7338)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/libOOOgg.vcproj	2004-07-25 22:57:34 UTC (rev 7339)
@@ -137,21 +137,6 @@
RelativePath="FLACMath.cpp">
</File>
<File
-				RelativePath="INotifyArrival.cpp">
-			</File>
-			<File
-				RelativePath="INotifyComplete.cpp">
-			</File>
-			<File
-				RelativePath="IOggCallback.cpp">
-			</File>
-			<File
-				RelativePath="IOggPackSource.cpp">
-			</File>
-			<File
-				RelativePath="IStampedOggPacketSink.cpp">
-			</File>
-			<File
RelativePath="libOOOgg.cpp">
</File>
<File

Modified: trunk/oggdsf/src/tests/testCircleBuffer/testCircleBuffer.cpp
===================================================================
--- trunk/oggdsf/src/tests/testCircleBuffer/testCircleBuffer.cpp	2004-07-25 22:16:47 UTC (rev 7338)
+++ trunk/oggdsf/src/tests/testCircleBuffer/testCircleBuffer.cpp	2004-07-25 22:57:34 UTC (rev 7339)
@@ -13,9 +13,10 @@
int x;
cin>>x;
const int CIRC_BUFF_SIZE = 4000;
-	const int LOC_BUFF_SIZE = 421;
-	const int LOC_READ_BUFF_BIG_SIZE = 811;
-	const int LOC_READ_BUFF_SMALL_SIZE = 379;
+	const int LOC_BUFF_SIZE = 300;
+
+	const int LOC_READ_BUFF_BIG_SIZE = 1000;
+	const int LOC_READ_BUFF_SMALL_SIZE = 50;
const int TIMES_TO_LOOP = 300;
CircularBuffer* locCircBuf = new CircularBuffer(CIRC_BUFF_SIZE);

@@ -42,27 +43,47 @@
unsigned char* locReadBuf = new unsigned char[LOC_READ_BUFF_BIG_SIZE];
unsigned long locNumRead = 0;
locNumWritten = 0;
+	//Assert buffersize > LOC_BUFF_SIZE
+	//Assert buffersize > LOC_READ_BUFF_SMALL_SIZE
+	//Assert buffersize > LOC_READ_BUFF_BIG_SIZE

+	//buffersize = 0;
for (int i = 0; i < TIMES_TO_LOOP; i++) {
+
+		cout<<"Round : "<<i<<endl;
locNumWritten = locCircBuf->write(locBuf, LOC_BUFF_SIZE);
cout<<"Write attempted "<<LOC_BUFF_SIZE<<" got "<<locNumWritten<<endl;
+		cout<<"Avail : "<<locCircBuf->numBytesAvail()<<"  --  Space Left : "<<locCircBuf->spaceLeft()<<endl<<endl;
+		//buffersize = LOC_BUFF_SIZE

cout<<"** Short read test"<<endl;
locNumRead = locCircBuf->read(locReadBuf, LOC_READ_BUFF_SMALL_SIZE);
cout<<"Read attempted "<<LOC_READ_BUFF_SMALL_SIZE<<" got "<<locNumRead<<endl;
+		cout<<"Avail : "<<locCircBuf->numBytesAvail()<<"  --  Space Left : "<<locCircBuf->spaceLeft()<<endl<<endl;
+		//buffersize = LOC_BUFF_SIZE - LOC_READ_BUFF_SMALL_SIZE

locNumWritten = locCircBuf->write(locBuf, LOC_BUFF_SIZE);
cout<<"Write attempted "<<LOC_BUFF_SIZE<<" got "<<locNumWritten<<endl;
+		cout<<"Avail : "<<locCircBuf->numBytesAvail()<<"  --  Space Left : "<<locCircBuf->spaceLeft()<<endl<<endl;
+		//buffersize = (2 * LOC_BUFF_SIZE) - LOC_READ_BUFF_SMALL_SIZE

-		cout<<"** Long read test"<<endl;
+		cout<<"** Long read / Empty Buffer test"<<endl;
locNumRead = locCircBuf->read(locReadBuf, LOC_READ_BUFF_BIG_SIZE);
cout<<"Read attempted "<<LOC_READ_BUFF_BIG_SIZE<<" got "<<locNumRead<<endl;
+		cout<<"Avail : "<<locCircBuf->numBytesAvail()<<"  --  Space Left : "<<locCircBuf->spaceLeft()<<endl<<endl;
+		//buffersize = (2 * LOC_BUFF_SIZE) - LOC_READ_BUFF_SMALL_SIZE - LOC_READ_BUFF_BIG_SIZE

-		cout<<"** Long read again to empty test"<<endl;
+		cout<<"** Read while empty test"<<endl;
locNumRead = locCircBuf->read(locReadBuf, LOC_READ_BUFF_BIG_SIZE);
cout<<"Read attempted "<<LOC_READ_BUFF_BIG_SIZE<<" got "<<locNumRead<<endl;
+		cout<<"Avail : "<<locCircBuf->numBytesAvail()<<"  --  Space Left : "<<locCircBuf->spaceLeft()<<endl<<endl;
+		//buffersize = (2 * LOC_BUFF_SIZE) - LOC_READ_BUFF_SMALL_SIZE - (2 * LOC_READ_BUFF_BIG_SIZE)

}
+
+	delete locCircBuf;
+	delete locBuf;
+	delete locReadBuf;
return 0;
}




More information about the commits mailing list