[xiph-commits] r10768 - branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2

illiminable at svn.xiph.org illiminable at svn.xiph.org
Sun Jan 29 05:18:07 PST 2006


Author: illiminable
Date: 2006-01-29 05:18:03 -0800 (Sun, 29 Jan 2006)
New Revision: 10768

Modified:
   branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.cpp
   branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.h
Log:
* Very simple low tide switch on the download thread, so it sleeps while it has enough data.

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 12:46:13 UTC (rev 10767)
+++ branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.cpp	2006-01-29 13:18:03 UTC (rev 10768)
@@ -182,11 +182,32 @@
 	locBuff = new char[RECV_BUFF_SIZE];
 
 	while(true) {
-		if(CheckRequest(&locCommand) == TRUE) {
-			debugLog<<"Thread Data Process loop received breakout signal..."<<endl;
-			delete[] locBuff;
-			return;
+		if (mMemoryBuffer->numBytesAvail() <= MEMORY_BUFFER_LOW_TIDE) {
+			//Need to keep reading
+			if(CheckRequest(&locCommand) == TRUE) {
+				if (GetRequest() == THREAD_EXIT) {
+					debugLog<<"Thread Data Process loop received breakout signal..."<<endl;
+					delete[] locBuff;
+					return;
+				} else {
+					Reply(S_OK);
+				}
+			}
+		} else {
+			//Got enough data, wait for a new job
+			if (GetRequest() == THREAD_EXIT) {	//Block until we have a new job
+				debugLog<<"Thread Data Process loop received breakout signal..."<<endl;
+				delete[] locBuff;
+				return;
+			} else {
+				Reply(S_OK);
+			}
 		}
+		//if(CheckRequest(&locCommand) == TRUE) {
+		//	debugLog<<"Thread Data Process loop received breakout signal..."<<endl;
+		//	delete[] locBuff;
+		//	return;
+		//}
 		//debugLog<<"About to call recv"<<endl;
 		locNumRead = recv(mSocket, locBuff, RECV_BUFF_SIZE, 0);
 		//debugLog<<"recv complete"<<endl;
@@ -504,6 +525,10 @@
 			if (locNumRead > 0) {
 				debugLog<<locNumRead<<" bytes read from buffer"<<endl;
 			}
+
+			if (mMemoryBuffer->numBytesAvail() <= MEMORY_BUFFER_LOW_TIDE) {
+				CallWorker(THREAD_RUN);
+			}
 			return locNumRead;
 		}
 	} //END CRITICAL SECTION

Modified: branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.h
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.h	2006-01-29 12:46:13 UTC (rev 10767)
+++ branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.h	2006-01-29 13:18:03 UTC (rev 10768)
@@ -50,7 +50,8 @@
 	virtual ~HTTPStreamingFileSource(void);
 
 	//Consts
-	static const unsigned long MEMORY_BUFFER_SIZE = 1024 * 1024 * 2;
+	static const unsigned long MEMORY_BUFFER_SIZE = 1024 * 1024 * 2;	//2 megs
+	static const unsigned long MEMORY_BUFFER_LOW_TIDE = 1024 * 512 * 3; //1.5 megs
 	//Thread commands
 	static const int THREAD_RUN = 0;
 	static const int THREAD_EXIT = 1;



More information about the commits mailing list