[xiph-commits] r10770 - in branches/oggdsf_new_demux/src/lib/core: directshow/dsfOggDemux2 ogg/libOOOgg

illiminable at svn.xiph.org illiminable at svn.xiph.org
Sun Jan 29 08:59:26 PST 2006


Author: illiminable
Date: 2006-01-29 08:59:15 -0800 (Sun, 29 Jan 2006)
New Revision: 10770

Modified:
   branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.cpp
   branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp
   branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp
   branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/CircularBuffer.h
   branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/IFIFOBuffer.h
   branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp
Log:
* Allow short reasds on the circular buffer so the last bit of data can get out
* Getting the last bit of data out allows the eof event to be triggered so the stream ends properly.
* Now it works!!

Modified: branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.cpp
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.cpp	2006-01-29 14:33:16 UTC (rev 10769)
+++ branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.cpp	2006-01-29 16:59:15 UTC (rev 10770)
@@ -529,11 +529,12 @@
 		} else {
 			//debugLog<<"Reading from buffer"<<endl;
 			
-			if (mMemoryBuffer->numBytesAvail() < inNumBytes) {
-				locNumRead = 0;
-			} else {
-				locNumRead = mMemoryBuffer->read((unsigned char*)outBuffer, inNumBytes);
-			}
+			//if (mMemoryBuffer->numBytesAvail() < inNumBytes) {
+			//	locNumRead = 0;
+			//} else {
+				//Allow short reads from buffer
+				locNumRead = mMemoryBuffer->read((unsigned char*)outBuffer, inNumBytes, true);
+			//}
 
 			if (locNumRead > 0) {
 				debugLog<<locNumRead<<" bytes read from buffer"<<endl;
@@ -546,7 +547,7 @@
 		}
 	} //END CRITICAL SECTION
 
-	if ((mMemoryBuffer->numBytesAvail() <= MEMORY_BUFFER_LOW_TIDE) && (!mIsBufferFilling)) {
+	if ((mMemoryBuffer->numBytesAvail() <= MEMORY_BUFFER_LOW_TIDE) && (!mIsBufferFilling) && (!mIsEOF)) {
 		CallWorker(THREAD_RUN);
 	}
 	return locNumRead;

Modified: branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp	2006-01-29 14:33:16 UTC (rev 10769)
+++ branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp	2006-01-29 16:59:15 UTC (rev 10770)
@@ -508,6 +508,7 @@
 		{
 			CAutoLock locSourceLock(mSourceFileLock);
 
+
 			locBytesRead = mDataSource->read(locBuff, 4096);
 			mJustReset = false;
 		}

Modified: branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp	2006-01-29 14:33:16 UTC (rev 10769)
+++ branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp	2006-01-29 16:59:15 UTC (rev 10770)
@@ -48,19 +48,30 @@
 	delete[] mBuffer;
 }
 
-unsigned long CircularBuffer::read(unsigned char* outData, unsigned long inBytesToRead) {
+unsigned long CircularBuffer::read(unsigned char* outData, unsigned long inBytesToRead, bool inAllowShortRead) {
 
-	//Returns early.
+	//Returns early. - why?
+	//TODO::: This is probably a bug?
 	if (inBytesToRead >  spaceLeft()) {
 		return 0;
 	}
     	
 	unsigned long locBytesToRead =	inBytesToRead;
 	
-	bufASSERT(locBytesToRead <= mBufferSize);
+	if (inAllowShortRead) {
+		locBytesToRead = (inBytesToRead <= numBytesAvail())		?	inBytesToRead
+																:	numBytesAvail();
+	}
+
+	if (locBytesToRead == 0) {
+		return 0;
+	}
+	
 		//	(inBytesToRead <= numBytesAvail())	?	inBytesToRead
 		//											:	numBytesAvail();
 	//locBytesToRead = the lower of numBytesAvail() and inBytesToRead
+
+	bufASSERT(locBytesToRead <= mBufferSize);
 	bufASSERT(locBytesToRead <= inBytesToRead);
 	bufASSERT(locBytesToRead <= numBytesAvail());
 	

Modified: branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/CircularBuffer.h
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/CircularBuffer.h	2006-01-29 14:33:16 UTC (rev 10769)
+++ branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/CircularBuffer.h	2006-01-29 16:59:15 UTC (rev 10770)
@@ -132,7 +132,7 @@
 	virtual ~CircularBuffer(void);
 
 	/// Read bytes from the internal buffer. Returns how many actually read.
-	virtual unsigned long read(unsigned char* outData, unsigned long inBytesToRead);
+	virtual unsigned long read(unsigned char* outData, unsigned long inBytesToRead, bool inAllowShortRead = false);
 
 	/// Write bytes into the internal buffer. Returns how many written.
 	virtual unsigned long write(const unsigned char* inData, unsigned long inBytesToWrite);

Modified: branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/IFIFOBuffer.h
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/IFIFOBuffer.h	2006-01-29 14:33:16 UTC (rev 10769)
+++ branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/IFIFOBuffer.h	2006-01-29 16:59:15 UTC (rev 10770)
@@ -37,7 +37,7 @@
 	virtual ~IFIFOBuffer(void)		{}
 
 	/// Read bytes from the internal buffer. Returns how many actually read.
-	virtual unsigned long read(unsigned char* outData, unsigned long inBytesToRead) = 0;
+	virtual unsigned long read(unsigned char* outData, unsigned long inBytesToRead, bool inAllowShortRead = false  ) = 0;
 
 	/// Write bytes into the internal buffer. Returns how many written.
 	virtual unsigned long write(const unsigned char* inData, unsigned long inBytesToWrite) = 0;

Modified: branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp	2006-01-29 14:33:16 UTC (rev 10769)
+++ branches/oggdsf_new_demux/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp	2006-01-29 16:59:15 UTC (rev 10770)
@@ -207,6 +207,8 @@
 		
 		if (locNumRead < OggPageHeader::OGG_BASE_HEADER_SIZE) {
 			//TODO::: Handle this case... we read less than we expected.
+			//The buffer handles it for us, it won't let us read less, and will return 0
+			//	This is fine for valid files, but still needs to be reviewed.
 
 			//debugLog<<"ProcessBaseHeader : ###### Read was short."<<endl;
 			//debugLog<<"ProcessBaseHeader : ** "<<mBuffer->numBytesAvail()<<" avail, "<<mBuffer->spaceLeft()<<" space left."<<endl;



More information about the commits mailing list