[xiph-commits] r7626 - trunk/oggdsf/src/lib/core/directshow/dsfOggDemux

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Tue Aug 24 11:18:26 PDT 2004


Author: illiminable
Date: 2004-08-24 11:18:25 -0700 (Tue, 24 Aug 2004)
New Revision: 7626

Modified:
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.h
Log:
* cache kind of working.

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.cpp	2004-08-24 15:35:23 UTC (rev 7625)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.cpp	2004-08-24 18:18:25 UTC (rev 7626)
@@ -60,8 +60,9 @@
 	const unsigned long RECV_BUFF_SIZE = 1024;
 	locBuff = new char[RECV_BUFF_SIZE];
 	while(true) {
-
+		debugLog<<"About to call recv"<<endl;
 		locNumRead = recv(mSocket, locBuff, RECV_BUFF_SIZE, 0);
+		debugLog<<"recv complete"<<endl;
 		if (locNumRead == SOCKET_ERROR) {
 			int locErr = WSAGetLastError();
 			debugLog<<"Socket error receiving - Err No = "<<locErr<<endl;
@@ -195,8 +196,9 @@
 		//mStreamBuffer.seekp(0, ios_base::beg);
 
 		//TODO::: Get rid of this path.
-		if(mFileCache.open("g:\\logs\\filecache.dat")) {
-			debugLog<<"OPEN : Can't open file cache"<<endl;
+		string locCacheFileName = "g:\\logs\\filecache.dat";
+		if(mFileCache.open(locCacheFileName)) {
+			debugLog<<"OPEN : Cach file opened"<<endl;
 		}
 	} //END CRITICAL SECTION
 

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.cpp	2004-08-24 15:35:23 UTC (rev 7625)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.cpp	2004-08-24 18:18:25 UTC (rev 7626)
@@ -4,15 +4,26 @@
 SingleMediaFileCache::SingleMediaFileCache(void)
 	:	mBytesWritten(0)
 	,	mIsComplete(false)
+	,	mReadPtr(0)
 {
+	debugLog.open("G:\\logs\\mediacache.log", ios_base::out);
 }
 
 SingleMediaFileCache::~SingleMediaFileCache(void)
 {
+	debugLog.close();
 }
 
 bool SingleMediaFileCache::open(string inFileName) {
-	mLocalFile.open(inFileName.c_str(), ios_base::in|ios_base::out|ios_base::binary);
+	mBytesWritten = 0;
+	debugLog<<"Opening "<<inFileName<<endl;
+	mLocalFile.open(inFileName.c_str(), ios_base::in|ios_base::out|ios_base::binary|ios_base::trunc);
+
+	if (mLocalFile.is_open()) {
+		debugLog<<"File open...."<<endl;
+	} else {
+		debugLog<<"File open FAILED"<<endl;
+	}
 	return mLocalFile.is_open();
 }
 void SingleMediaFileCache::close() {
@@ -20,20 +31,46 @@
 	
 }
 bool SingleMediaFileCache::write(const unsigned char* inBuff, unsigned long inBuffSize) {
+	debugLog<<"Writeing "<<inBuffSize<<endl;
+	debugLog<<"Read Ptr = "<<mLocalFile.tellg();
+	debugLog<<"Write Ptr = "<<mLocalFile.tellp();
+	mLocalFile.seekp(0, ios_base::end);
 	if (inBuffSize != 0) {
 		mLocalFile.write((const char*)inBuff, inBuffSize);
 		mBytesWritten += inBuffSize;
 	}
 
-	return mLocalFile.fail();
+	if (mLocalFile.fail()) {
+		debugLog<<"*** Write put into FAIL"<<endl;
+	}
+	return !(mLocalFile.fail());
 }
 unsigned long SingleMediaFileCache::read(unsigned char* outBuff, unsigned long inBuffSize) {
-	mLocalFile.read((char*)outBuff, inBuffSize);
-	return mLocalFile.gcount();
+	debugLog<<"Read request for "<<inBuffSize<<"  got ";
+	debugLog<<"Read Ptr = "<<mLocalFile.tellg();
+	debugLog<<"Write Ptr = "<<mLocalFile.tellp();
+	mLocalFile.seekg(mReadPtr);
+	unsigned long locBytesAvail = bytesAvail();
+	if (locBytesAvail >= inBuffSize) {
+        mLocalFile.read((char*)outBuff, inBuffSize);
+        debugLog<<mLocalFile.gcount()<<endl;
+		mReadPtr+=mLocalFile.gcount();
+		return mLocalFile.gcount();
+	} else if (locBytesAvail > 0) {
+		mLocalFile.read((char*)outBuff, locBytesAvail);
+		debugLog<<locBytesAvail<<endl;
+		mReadPtr += locBytesAvail;
+		return locBytesAvail;
+	} else {
+		debugLog << "NOTHING"<<endl;
+		return 0;
+	}
+	
 }
 bool SingleMediaFileCache::readSeek(unsigned long inSeekPos) {
 	if (inSeekPos < mBytesWritten) {
-		mLocalFile.seekg(inSeekPos);
+		debugLog<<"Seeking to "<<inSeekPos<<endl;
+		mReadPtr = inSeekPos;
 		return true;
 	} else {
 		return false;
@@ -44,8 +81,14 @@
 	return mBytesWritten;
 }
 unsigned long SingleMediaFileCache::bytesAvail() {
-	if (!mLocalFile.fail() && mBytesWritten > 0) {
-		return mBytesWritten - mLocalFile.tellg();
+	if (mLocalFile.fail()) {
+		debugLog<<"bytesAvail : File is in fail state"<<endl;
+	}
+	debugLog<<"bytesAvail : Byteswritten = "<<mBytesWritten<<endl;
+	//if ((!mLocalFile.fail()) && (mBytesWritten > 0)) {
+	if (mBytesWritten > 0) {
+		debugLog<<"bytes Avail = "<<mBytesWritten - mReadPtr<<endl;
+		return mBytesWritten - mReadPtr;
 	} else {
 		return 0;
 	}

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.h	2004-08-24 15:35:23 UTC (rev 7625)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/SingleMediaFileCache.h	2004-08-24 18:18:25 UTC (rev 7626)
@@ -30,6 +30,8 @@
 	fstream mLocalFile;
 
 	unsigned long mBytesWritten;
+	unsigned long mReadPtr;
 	
+	fstream debugLog;
 	bool mIsComplete;
 };



More information about the commits mailing list