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

illiminable at svn.xiph.org illiminable at svn.xiph.org
Sun Oct 23 04:39:25 PDT 2005


Author: illiminable
Date: 2005-10-23 04:39:20 -0700 (Sun, 23 Oct 2005)
New Revision: 10269

Modified:
   branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp
   branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.h
Log:
* Implement threadproc and dataprocessloop in demux filter

Modified: branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp	2005-10-23 11:31:02 UTC (rev 10268)
+++ branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp	2005-10-23 11:39:20 UTC (rev 10269)
@@ -389,28 +389,90 @@
 //CAMThread Stuff
 DWORD OggDemuxPacketSourceFilter::ThreadProc(void) {
 	
-	//while(true) {
-	//	DWORD locThreadCommand = GetRequest();
-	//
-	//	switch(locThreadCommand) {
-	//		case THREAD_EXIT:
-	//
-	//			Reply(S_OK);
-	//			return S_OK;
+	while(true) {
+		DWORD locThreadCommand = GetRequest();
+	
+		switch(locThreadCommand) {
+			case THREAD_EXIT:
+	
+				Reply(S_OK);
+				return S_OK;
 
-	//		case THREAD_RUN:
-	//
-	//			Reply(S_OK);
-	//			DataProcessLoop();
-	//			break;
-	//	}
-	//}
+			case THREAD_RUN:
+	
+				Reply(S_OK);
+				DataProcessLoop();
+				break;
+		}
+	}
 	return S_OK;
 }
+HRESULT OggDemuxPacketSourceFilter::DataProcessLoop() 
+{
+	//Mess with the locking mechanisms at your own risk.
 
+	//debugLog<<"Starting DataProcessLoop :"<<endl;
+	DWORD locCommand = 0;
+	char* locBuff = new  char[4096];			//Deleted before function returns...
+	//TODO::: Make this a member variable ^^^^^
+	bool locKeepGoing = true;
+	unsigned long locBytesRead = 0;
+	bool locIsEOF = true;
+	{
+		CAutoLock locSourceLock(mSourceFileLock);
+		locIsEOF = mDataSource->isEOF();
+	}
 
+	while(true) {
+		if(CheckRequest(&locCommand) == TRUE) {
+			//debugLog<<"DataProcessLoop : Thread Command issued... leaving loop."<<endl;
+			delete[] locBuff;
+			return S_OK;
+		}
+		//debugLog<<"Looping..."<<endl;
+		{
+			CAutoLock locSourceLock(mSourceFileLock);
 
+			locBytesRead = mDataSource->read(locBuff, 4096);
+			mJustReset = false;
+		}
+		//debugLog <<"DataProcessLoop : gcount = "<<locBytesRead<<endl;
+		{
+			CAutoLock locDemuxLock(mDemuxLock);
+			//CAutoLock locStreamLock(mStreamLock);
+			if (mJustReset) {		//To avoid blocking problems... restart the loop if it was just reset while waiting for lock.
+				continue;
+			}
+			locKeepGoing = ((mOggBuffer.feed((const unsigned char*)locBuff, locBytesRead)) == (OggDataBuffer::FEED_OK));;
+		}
+		if (!locKeepGoing) {
+			//debugLog << "DataProcessLoop : Feed in data buffer said stop"<<endl;
+			//debugLog<<"DataProcessLoop : Exiting. Deliver EOS"<<endl;
+			DeliverEOS();
+		}
+		{
+			CAutoLock locSourceLock(mSourceFileLock);
+			locIsEOF = mDataSource->isEOF();
+		}
+		if (locIsEOF) {
+			//debugLog << "DataProcessLoop : EOF"<<endl;
+			//debugLog<<"DataProcessLoop : Exiting. Deliver EOS"<<endl;
+			DeliverEOS();
+		}
+	}
 
+	//debugLog<<"DataProcessLoop : Exiting. Deliver EOS"<<endl;
+
+	//Shuold we flush ehre ?
+	delete[] locBuff;
+	
+	//return value ??
+	return S_OK;
+}
+
+
+
+
 STDMETHODIMP OggDemuxPacketSourceFilter::GetCapabilities(DWORD* inCapabilities) 
 {
 	//if (mSeekTable->enabled())  {

Modified: branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.h
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.h	2005-10-23 11:31:02 UTC (rev 10268)
+++ branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.h	2005-10-23 11:39:20 UTC (rev 10269)
@@ -113,6 +113,7 @@
 	virtual HRESULT SetUpPins();
 
 	void resetStream();
+	HRESULT DataProcessLoop();
 
 	void DeliverEOS();
 	void DeliverBeginFlush();



More information about the commits mailing list