[xiph-commits] r8031 - in trunk/oggdsf: sln/oggdsf_all src/lib/codecs/flac/filters/dsfFLACDecoder

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Sat Oct 16 09:51:51 PDT 2004


Author: illiminable
Date: 2004-10-16 09:51:51 -0700 (Sat, 16 Oct 2004)
New Revision: 8031

Modified:
   trunk/oggdsf/sln/oggdsf_all/oggdsf_all.sln
   trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp
   trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.h
   trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/dsfFLACDecoder.vcproj
Log:
* Fixed FLAC threading/crash bug.

Modified: trunk/oggdsf/sln/oggdsf_all/oggdsf_all.sln
===================================================================
--- trunk/oggdsf/sln/oggdsf_all/oggdsf_all.sln	2004-10-16 16:19:09 UTC (rev 8030)
+++ trunk/oggdsf/sln/oggdsf_all/oggdsf_all.sln	2004-10-16 16:51:51 UTC (rev 8031)
@@ -74,6 +74,7 @@
 	ProjectSection(ProjectDependencies) = postProject
 		{223ACC19-608E-4E1B-A054-067F0CACB272} = {223ACC19-608E-4E1B-A054-067F0CACB272}
 		{6B548F29-04A2-4F61-946F-72B86B4845DA} = {6B548F29-04A2-4F61-946F-72B86B4845DA}
+		{7F213248-16F2-4AAE-B941-C402670082BC} = {7F213248-16F2-4AAE-B941-C402670082BC}
 		{A882A968-3013-4A27-B653-E18CF5C791FE} = {A882A968-3013-4A27-B653-E18CF5C791FE}
 		{4CBC0173-27E6-4218-AE06-5EFDCA7B2547} = {4CBC0173-27E6-4218-AE06-5EFDCA7B2547}
 		{BE48BAC3-F0DE-47AA-8192-C2A52798E0E5} = {BE48BAC3-F0DE-47AA-8192-C2A52798E0E5}

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp	2004-10-16 16:19:09 UTC (rev 8030)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp	2004-10-16 16:51:51 UTC (rev 8031)
@@ -64,7 +64,7 @@
 bool FLACDecodeInputPin::ConstructCodec() 
 {
 	//mFLACDecoder = new FLAC__StreamDecoder;
-	init();
+	mFLACDecoder.initCodec();
 
 	return true;
 }
@@ -77,230 +77,344 @@
 
 
 
-//FLAC Callbacks
-::FLAC__StreamDecoderReadStatus FLACDecodeInputPin::read_callback(FLAC__byte outBuffer[], unsigned* outNumBytes) 
-{
-	//Put some data into the buffer.
-	//ASSERT(mPendingPackets.size() == 1);
-	unsigned long locNumPacks = mPendingPackets.size();
-
-	//debugLog<<"Read_Callback : numpacks = "<<locNumPacks<<endl;
-	//First packet
-	if (locNumPacks != 1) {
-		//throw 0;
-		//debugLog<<"Read_Callback : Bailing out with abort code."<<endl;
-		return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
-	}
-	OggPacket* locPacket = mPendingPackets.front()->clone();
-	
-	delete mPendingPackets.front();
-	mPendingPackets.pop();
-	ASSERT(mPendingPackets.size() == 0);
-	//mNumPacksBuffered++;
-
-	//for (int i = 0; i < locNumPacks; i++) {
-	//	//mNumPacksBuffered++;
-	//	//Any more than one packet merge them
-	//	locPacket->merge(mPendingPackets.front());
-	//	delete mPendingPackets.front();
-	//	mPendingPackets.pop();
-	//}
-
-    memcpy((void*)outBuffer, (const void*)locPacket->packetData(), locPacket->packetSize());
-
-	*outNumBytes = locPacket->packetSize();
-	delete locPacket;
-	locPacket = NULL;
-	
-	//debugLog<<"Read_callback : Buffer filled returning sucess"<<endl;
-		//What return value ??
-		return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
-}
-::FLAC__StreamDecoderWriteStatus FLACDecodeInputPin::write_callback(const ::FLAC__Frame* inFrame, const FLAC__int32* const inBuffer[]) 
-{
+////FLAC Callbacks
+//::FLAC__StreamDecoderReadStatus FLACDecodeInputPin::read_callback(FLAC__byte outBuffer[], unsigned* outNumBytes) 
+//{
+//	//Put some data into the buffer.
+//	//ASSERT(mPendingPackets.size() == 1);
+//	unsigned long locNumPacks = mPendingPackets.size();
+//
+//	//debugLog<<"Read_Callback : numpacks = "<<locNumPacks<<endl;
+//	//First packet
+//	if (locNumPacks != 1) {
+//		//throw 0;
+//		//debugLog<<"Read_Callback : Bailing out with abort code."<<endl;
+//		return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
+//	}
+//	OggPacket* locPacket = mPendingPackets.front()->clone();
+//	
+//	delete mPendingPackets.front();
+//	mPendingPackets.pop();
+//	ASSERT(mPendingPackets.size() == 0);
+//	//mNumPacksBuffered++;
+//
+//	//for (int i = 0; i < locNumPacks; i++) {
+//	//	//mNumPacksBuffered++;
+//	//	//Any more than one packet merge them
+//	//	locPacket->merge(mPendingPackets.front());
+//	//	delete mPendingPackets.front();
+//	//	mPendingPackets.pop();
+//	//}
+//
+//    memcpy((void*)outBuffer, (const void*)locPacket->packetData(), locPacket->packetSize());
+//
+//	*outNumBytes = locPacket->packetSize();
+//	delete locPacket;
+//	locPacket = NULL;
+//	
+//	//debugLog<<"Read_callback : Buffer filled returning sucess"<<endl;
+//		//What return value ??
+//		return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
+//}
+//::FLAC__StreamDecoderWriteStatus FLACDecodeInputPin::write_callback(const ::FLAC__Frame* inFrame, const FLAC__int32* const inBuffer[]) 
+//{
+//
+//	if (! mBegun) {
+//	
+//		mBegun = true;
+//		
+//		mNumChannels = inFrame->header.channels;
+//		mFrameSize = mNumChannels * SIZE_16_BITS;
+//		mSampleRate = inFrame->header.sample_rate;
+//		
+//	}
+//
+//	//FIX::: Most of this will be obselete... the demux does it all.
+//	
+//
+//	//TO DO::: Fix this up... needs to move around order and some only needs to be done once, move it into the block aboce and use member data
+//	unsigned long locNumFrames = inFrame->header.blocksize;
+//	unsigned long locActualSize = locNumFrames * mFrameSize;
+//	unsigned long locTotalFrameCount = locNumFrames * mNumChannels;
+//	
+//	//Make the start timestamp
+//	//FIX:::Abstract this calculation
+//	//REFERENCE_TIME locFrameStart = CurrentStartTime() + (((__int64)(mUptoFrame * UNITS)) / mSampleRate);
+//
+//
+//	//ADDING TIMEBASE INFO.
+//	REFERENCE_TIME locTimeBase = ((mLastSeenStartGranPos * UNITS) / mSampleRate) - mSeekTimeBase;
+//
+//
+//	REFERENCE_TIME locFrameStart = locTimeBase + (((__int64)(mUptoFrame * UNITS)) / mSampleRate);
+//	//Increment the frame counter
+//	mUptoFrame += locNumFrames;
+//	//Make the end frame counter
+//	//REFERENCE_TIME locFrameEnd = CurrentStartTime() + (((__int64)(mUptoFrame * UNITS)) / mSampleRate);
+//	REFERENCE_TIME locFrameEnd = locTimeBase + (((__int64)(mUptoFrame * UNITS)) / mSampleRate);
+//
+//	//Get a pointer to a new sample stamped with our time
+//	IMediaSample* locSample;
+//	//debugLog<<"Write_callback : Calling Getdeliverybuffer................"<<endl;
+//	HRESULT locHR = mOutputPin->GetDeliveryBuffer(&locSample, &locFrameStart, &locFrameEnd, NULL);
+//
+//	if (FAILED(locHR)) {
+//		//debugLog<<"Write_Callback : Get deliverybuffer failed. returning abort code."<<endl;
+//		//We get here when the application goes into stop mode usually.
+//		return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
+//	}	
+//	//debugLog<<"Write_CAllback : Get delivery buffer returned ok"<<endl;
+//	//debugLog<<"Write_Callback : Sample times "<<locFrameStart <<" to "<<locFrameEnd<<endl;
+//	//Set the timestamps
+//	//Now done in SetsampleParams
+//	//	locSample->SetTime(&locFrameStart, &locFrameEnd);
+//
+//	//Create pointers for the samples buffer to be assigned to
+//	BYTE* locBuffer = NULL;
+//	signed short* locShortBuffer = NULL;
+//	
+//	//Make our pointers set to point to the samples buffer
+//	locSample->GetPointer(&locBuffer);
+//	locShortBuffer = (short *) locBuffer;
+//	
+//	signed short tempInt = 0;
+//	int tempLong = 0;
+//	float tempFloat = 0;
+//	
+//	//FIX:::Move the clipping to the abstract function
+//	//Make sure our sample buffer is big enough
+//
+//	//Modified for FLAC int32 not float
+//	if (locSample->GetSize() >= locActualSize) {
+//		
+//		//Must interleave and convert sample size.
+//		for(unsigned long i = 0; i < locNumFrames; i++) {
+//			for (unsigned long j = 0; j < mNumChannels; j++) {
+//				
+//			
+//				//No clipping required for ints
+//				//FIX:::Take out the unnescessary variable.
+//				tempLong = inBuffer[j][i];
+//				//Convert 32 bit to 16 bit
+//
+//				//FIX::: Why on earth are you dividing by 2 ? It does not make sense !
+//				tempInt = (signed short)(tempLong/2);
+//			
+//				*locShortBuffer = tempInt;
+//				locShortBuffer++;
+//			}
+//		}
+//				
+//		//Set the sample parameters.
+//		SetSampleParams(locSample, locActualSize, &locFrameStart, &locFrameEnd);
+//
+//		{
+//			CAutoLock locLock(m_pLock);
+//			//debugLog<<"Write_Callback : Calling deliver............"<<endl;
+//			
+//			
+//			//BUGFIX::: I think this is one of the sources of the seeking bug... the base class has a queue
+//			//			 on the output pin, this call was bypassing it... however the flush calls were
+//			//			 flushing the queue, and thus not the actuall buffer.
+//			//HRESULT locHR = mOutputPin->Deliver(locSample);			
+//
+//			HRESULT locHR = mOutputPin->mDataQueue->Receive(locSample);
+//			if (locHR != S_OK) {
+//				//debugLog<<"Write_Callback : Delivery of sample failed. - "<<locHR<<endl;
+//			} else {
+//				//debugLog<<"Write_Callback : Delivery of sample succeeded"<<endl;
+//			}
+//		}
+//
+//		//locSample->Release();
+//
+//		//debugLog<<"WriteCallback : Returning Sucess code."<<endl;
+//		return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
+//	} else {
+//		//debugLog<<"Write_Callback : Buffer too small."<<endl;
+//		throw 0;
+//	}
+//
+//}
+//void FLACDecodeInputPin::metadata_callback(const ::FLAC__StreamMetadata* inMetadata) 
+//{
+//	int i = 0;
+//}
+//void FLACDecodeInputPin::error_callback(::FLAC__StreamDecoderErrorStatus inStatus) 
+//{
+//	int i = 0;
+//}
 
-	if (! mBegun) {
-	
-		mBegun = true;
-		
-		mNumChannels = inFrame->header.channels;
-		mFrameSize = mNumChannels * SIZE_16_BITS;
-		mSampleRate = inFrame->header.sample_rate;
-		
-	}
 
-	//FIX::: Most of this will be obselete... the demux does it all.
-	
+long FLACDecodeInputPin::decodeData(BYTE* inBuf, long inNumBytes) 
+{
 
-	//TO DO::: Fix this up... needs to move around order and some only needs to be done once, move it into the block aboce and use member data
-	unsigned long locNumFrames = inFrame->header.blocksize;
-	unsigned long locActualSize = locNumFrames * mFrameSize;
-	unsigned long locTotalFrameCount = locNumFrames * mNumChannels;
-	
-	//Make the start timestamp
-	//FIX:::Abstract this calculation
-	//REFERENCE_TIME locFrameStart = CurrentStartTime() + (((__int64)(mUptoFrame * UNITS)) / mSampleRate);
+	//TODO::: Locks ???
 
+	//What happens when another packet arrives and the other one is still there ?
+	//delete mPendingPacket;
+	//debugLog<<"decodeData : "<<endl;
+	if(!m_bFlushing) {
+		unsigned char* locBuff = new unsigned char[inNumBytes];
+		memcpy((void*)locBuff, (const void*)inBuf, inNumBytes);
 
-	//ADDING TIMEBASE INFO.
-	REFERENCE_TIME locTimeBase = ((mLastSeenStartGranPos * UNITS) / mSampleRate) - mSeekTimeBase;
+		OggPacket* locPacket = new OggPacket(locBuff, inNumBytes, false, false);	//We give this away.
 
+		if (mGotMetaData) {
+			StampedOggPacket* locStamped = NULL;
+			{
+				CAutoLock locCodecLock(mCodecLock);
+				//for(unsigned long i = 0; i < mPendingPackets.size(); i++) {
+				 locStamped = (StampedOggPacket*)mFLACDecoder.decodeFLAC(locPacket)->clone();
+			}
 
-	REFERENCE_TIME locFrameStart = locTimeBase + (((__int64)(mUptoFrame * UNITS)) / mSampleRate);
-	//Increment the frame counter
-	mUptoFrame += locNumFrames;
-	//Make the end frame counter
-	//REFERENCE_TIME locFrameEnd = CurrentStartTime() + (((__int64)(mUptoFrame * UNITS)) / mSampleRate);
-	REFERENCE_TIME locFrameEnd = locTimeBase + (((__int64)(mUptoFrame * UNITS)) / mSampleRate);
+			if (locStamped != NULL) {
+				//Do the directshow crap here....
 
-	//Get a pointer to a new sample stamped with our time
-	IMediaSample* locSample;
-	//debugLog<<"Write_callback : Calling Getdeliverybuffer................"<<endl;
-	HRESULT locHR = mOutputPin->GetDeliveryBuffer(&locSample, &locFrameStart, &locFrameEnd, NULL);
+				IMediaSample* locSample;
 
-	if (FAILED(locHR)) {
-		//debugLog<<"Write_Callback : Get deliverybuffer failed. returning abort code."<<endl;
-		//We get here when the application goes into stop mode usually.
-		return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
-	}	
-	//debugLog<<"Write_CAllback : Get delivery buffer returned ok"<<endl;
-	//debugLog<<"Write_Callback : Sample times "<<locFrameStart <<" to "<<locFrameEnd<<endl;
-	//Set the timestamps
-	//Now done in SetsampleParams
-	//	locSample->SetTime(&locFrameStart, &locFrameEnd);
+				HRESULT locHR = mOutputPin->GetDeliveryBuffer(&locSample, NULL, NULL, NULL);
+				
+				if (FAILED(locHR)) {
+					//debugLog<<"Write_Callback : Get deliverybuffer failed. returning abort code."<<endl;
+					//		//We get here when the application goes into stop mode usually.
+						return -1;
+				}	
 
-	//Create pointers for the samples buffer to be assigned to
-	BYTE* locBuffer = NULL;
-	signed short* locShortBuffer = NULL;
-	
-	//Make our pointers set to point to the samples buffer
-	locSample->GetPointer(&locBuffer);
-	locShortBuffer = (short *) locBuffer;
-	
-	signed short tempInt = 0;
-	int tempLong = 0;
-	float tempFloat = 0;
-	
-	//FIX:::Move the clipping to the abstract function
-	//Make sure our sample buffer is big enough
 
-	//Modified for FLAC int32 not float
-	if (locSample->GetSize() >= locActualSize) {
-		
-		//Must interleave and convert sample size.
-		for(unsigned long i = 0; i < locNumFrames; i++) {
-			for (unsigned long j = 0; j < mNumChannels; j++) {
-				
-			
-				//No clipping required for ints
-				//FIX:::Take out the unnescessary variable.
-				tempLong = inBuffer[j][i];
-				//Convert 32 bit to 16 bit
+				BYTE* locBuffer = NULL;
 
-				//FIX::: Why on earth are you dividing by 2 ? It does not make sense !
-				tempInt = (signed short)(tempLong/2);
-			
-				*locShortBuffer = tempInt;
-				locShortBuffer++;
-			}
-		}
-				
-		//Set the sample parameters.
-		SetSampleParams(locSample, locActualSize, &locFrameStart, &locFrameEnd);
 
-		{
-			CAutoLock locLock(m_pLock);
-			//debugLog<<"Write_Callback : Calling deliver............"<<endl;
-			
-			
-			//BUGFIX::: I think this is one of the sources of the seeking bug... the base class has a queue
-			//			 on the output pin, this call was bypassing it... however the flush calls were
-			//			 flushing the queue, and thus not the actuall buffer.
-			//HRESULT locHR = mOutputPin->Deliver(locSample);			
+				//	//Make our pointers set to point to the samples buffer
+				locSample->GetPointer(&locBuffer);
 
-			HRESULT locHR = mOutputPin->mDataQueue->Receive(locSample);
-			if (locHR != S_OK) {
-				//debugLog<<"Write_Callback : Delivery of sample failed. - "<<locHR<<endl;
-			} else {
-				//debugLog<<"Write_Callback : Delivery of sample succeeded"<<endl;
-			}
-		}
 
-		//locSample->Release();
 
-		//debugLog<<"WriteCallback : Returning Sucess code."<<endl;
-		return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
-	} else {
-		//debugLog<<"Write_Callback : Buffer too small."<<endl;
-		throw 0;
-	}
-
-}
-void FLACDecodeInputPin::metadata_callback(const ::FLAC__StreamMetadata* inMetadata) 
-{
-	int i = 0;
-}
-void FLACDecodeInputPin::error_callback(::FLAC__StreamDecoderErrorStatus inStatus) 
-{
-	int i = 0;
-}
 
+				if (locSample->GetSize() >= locStamped->packetSize()) {
+					//	//ADDING TIMEBASE INFO.
+					REFERENCE_TIME locTimeBase = ((mLastSeenStartGranPos * UNITS) / mFLACDecoder.mSampleRate) - mSeekTimeBase;
+					REFERENCE_TIME locFrameStart = locTimeBase + (((__int64)(mUptoFrame * UNITS)) / mFLACDecoder.mSampleRate);
+					
+					//Increment the frame counter
+					mUptoFrame += locStamped->endTime();
+					
+					//	//Make the end frame counter
 
-long FLACDecodeInputPin::decodeData(BYTE* inBuf, long inNumBytes) 
-{
-	//TODO::: Locks ???
+					REFERENCE_TIME locFrameEnd = locTimeBase + (((__int64)(mUptoFrame * UNITS)) / mFLACDecoder.mSampleRate);
 
-	//What happens when another packet arrives and the other one is still there ?
-	//delete mPendingPacket;
-	//debugLog<<"decodeData : "<<endl;
-	if(!m_bFlushing) {
-		unsigned char* locBuff = new unsigned char[inNumBytes];
-		memcpy((void*)locBuff, (const void*)inBuf, inNumBytes);
+					memcpy((void*)locBuffer, (const void*)locStamped->packetData(), locStamped->packetSize());
+					SetSampleParams(locSample, locStamped->packetSize(), &locFrameStart, &locFrameEnd);
+					HRESULT locHR = mOutputPin->mDataQueue->Receive(locSample);
+					if (locHR != S_OK) {
+	
+					} else {
+						//debugLog<<"Write_Callback : Delivery of sample succeeded"<<endl;
+					}
+				} else {
+					throw 0;		//SAMPLE SIZE IS TOO SMALL TO FIT DATA
+				}
 
-		//HACK !!
-		if (mPendingPackets.size() != 0) {
-			
-			unsigned long locSize = mPendingPackets.size();
-			//debugLog<<"decodeData : ERROR packet buffer not empty - "<<locSize<<" packets deleting"<<endl;
-			for (int i = 0; i < locSize; i++) {
-				delete mPendingPackets.front();
-				mPendingPackets.pop();
-			}
-		}
 
-		ASSERT(mPendingPackets.size() == 0);
-														//Packet not truncated or continued.. it's a full packet.
-		mPendingPackets.push(new OggPacket(locBuff, inNumBytes, false, false));
-		ASSERT(mPendingPackets.size() == 1);
-		if (mGotMetaData) {
-			int locRet = 0;
-			//for(unsigned long i = 0; i < mPendingPackets.size(); i++) {
-			ASSERT((locBuff[0] == 255) && (locBuff[1] == 248));
-			if (mPendingPackets.size() == 1) {
-				//debugLog<<"decodeData : Calling process_single with 1 packet."<<endl;
-				
-					locRet = process_single();
-			
+				delete locStamped;
+				return 0;
 			} else {
-				//debugLog<<"decodeData : Something bad happened !"<<endl;
 				return -1;
-				//Shouldn't be possible to get here !
 			}
-			//}
-			//mNumPacksBuffered = 0;
+
 		} else {
-		
+			{
 				CAutoLock locCodecLock(mCodecLock);
-				int locRet = process_until_end_of_metadata();
+				mGotMetaData = mFLACDecoder.acceptMetadata(locPacket);
+			}
+			if (mGotMetaData) {
+				return 0;
+			} else {
+				return -1;
+			}
+
 			
-			mGotMetaData = true;
+			
 		}
 		//debugLog<<"decodeData : Successful return."<<endl;
+
+		//Should be impossible to get here.
 		return 0;
 	} else {
 		//debugLog<<"decodeData : Filter flushing... bad things !!!"<<endl;
 		return -1;
 	}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+	//OLD IMPLEMENTATION
+	//==================================================
+	////TODO::: Locks ???
+
+	////What happens when another packet arrives and the other one is still there ?
+	////delete mPendingPacket;
+	////debugLog<<"decodeData : "<<endl;
+	//if(!m_bFlushing) {
+	//	unsigned char* locBuff = new unsigned char[inNumBytes];
+	//	memcpy((void*)locBuff, (const void*)inBuf, inNumBytes);
+
+	//	//HACK !!
+	//	if (mPendingPackets.size() != 0) {
+	//		
+	//		unsigned long locSize = mPendingPackets.size();
+	//		//debugLog<<"decodeData : ERROR packet buffer not empty - "<<locSize<<" packets deleting"<<endl;
+	//		for (int i = 0; i < locSize; i++) {
+	//			delete mPendingPackets.front();
+	//			mPendingPackets.pop();
+	//		}
+	//	}
+
+	//	ASSERT(mPendingPackets.size() == 0);
+	//													//Packet not truncated or continued.. it's a full packet.
+	//	mPendingPackets.push(new OggPacket(locBuff, inNumBytes, false, false));
+	//	ASSERT(mPendingPackets.size() == 1);
+	//	if (mGotMetaData) {
+	//		int locRet = 0;
+	//		//for(unsigned long i = 0; i < mPendingPackets.size(); i++) {
+	//		ASSERT((locBuff[0] == 255) && (locBuff[1] == 248));
+	//		if (mPendingPackets.size() == 1) {
+	//			//debugLog<<"decodeData : Calling process_single with 1 packet."<<endl;
+	//			
+	//				locRet = process_single();
+	//		
+	//		} else {
+	//			//debugLog<<"decodeData : Something bad happened !"<<endl;
+	//			return -1;
+	//			//Shouldn't be possible to get here !
+	//		}
+	//		//}
+	//		//mNumPacksBuffered = 0;
+	//	} else {
+	//	
+	//			CAutoLock locCodecLock(mCodecLock);
+	//			int locRet = process_until_end_of_metadata();
+	//		
+	//		mGotMetaData = true;
+	//	}
+	//	//debugLog<<"decodeData : Successful return."<<endl;
+	//	return 0;
+	//} else {
+	//	//debugLog<<"decodeData : Filter flushing... bad things !!!"<<endl;
+	//	return -1;
+	//}
 	
 }
 
@@ -323,14 +437,14 @@
 	HRESULT locHR = AbstractAudioDecodeInputPin::BeginFlush();
 	{	//PROTECT CODEC FROM IMPLODING
 		CAutoLock locCodecLock(mCodecLock);
-		flush();
+		mFLACDecoder.flushCodec();
 	}	//END CRITICAL SECTION
-	unsigned long locSize = mPendingPackets.size();
-	//debugLog<<"BeginFlush : deleting "<<locSize<<" packets."<<endl;
-	for (unsigned long i = 0; i < locSize; i++) {
-		delete mPendingPackets.front();
-		mPendingPackets.pop();
-	}
+	//unsigned long locSize = mPendingPackets.size();
+	////debugLog<<"BeginFlush : deleting "<<locSize<<" packets."<<endl;
+	//for (unsigned long i = 0; i < locSize; i++) {
+	//	delete mPendingPackets.front();
+	//	mPendingPackets.pop();
+	//}
 	return locHR;
 	
 }
@@ -339,14 +453,14 @@
 	CAutoLock locStreamLock(mStreamLock);
 	{	//PROTECT CODEC FROM IMPLODING
 		CAutoLock locCodecLock(mCodecLock);
-		flush();
+		mFLACDecoder.flushCodec();
 	}	//END CRITICAL SECTION
 
-	unsigned long locSize = mPendingPackets.size();
-	for (unsigned long i = 0; i < locSize; i++) {
-		delete mPendingPackets.front();
-		mPendingPackets.pop();
-	}
+	//unsigned long locSize = mPendingPackets.size();
+	//for (unsigned long i = 0; i < locSize; i++) {
+	//	delete mPendingPackets.front();
+	//	mPendingPackets.pop();
+	//}
 	return AbstractAudioDecodeInputPin::EndOfStream();
 }
 

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.h	2004-10-16 16:19:09 UTC (rev 8030)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.h	2004-10-16 16:51:51 UTC (rev 8031)
@@ -31,20 +31,22 @@
 
 #pragma once
 #include "FLACdecoderdllstuff.h"
-#include "FLAC++/decoder.h"
+//#include "FLAC++/decoder.h"
+#include "FLACPushDecoder.h"
 #include "OggPacket.h"
-#include <queue>
+#include "StampedOggPacket.h"
+//#include <queue>
 
 //debug only
 #include <fstream>
 //
 
 using namespace std;
-using namespace FLAC::Decoder;
+//using namespace FLAC::Decoder;
 
 class FLACDecodeInputPin
 	:	public AbstractAudioDecodeInputPin
-	,	public Stream
+	//,	public Stream
 {
 public:
 
@@ -56,10 +58,10 @@
 
 	HRESULT SetMediaType(const CMediaType* inMediaType);
 
-	virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes);
-	virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]);
-	virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
-	virtual void error_callback(::FLAC__StreamDecoderErrorStatus status);
+	//virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes);
+	//virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]);
+	//virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
+	//virtual void error_callback(::FLAC__StreamDecoderErrorStatus status);
 
 	//VIRTUAL FUNCTIONS - AbstractAudioDecodeInputPin
 	//FIX:::These should be protected.
@@ -73,12 +75,13 @@
 
 protected:
 	bool mGotMetaData;
+	FLACPushDecoder mFLACDecoder;
 	
 	//debug only
 	//fstream debugLog;
 	//
 
 	CCritSec* mCodecLock;
-	queue<OggPacket*> mPendingPackets;
-	unsigned long mNumPacksBuffered;
+	//queue<OggPacket*> mPendingPackets;
+	//unsigned long mNumPacksBuffered;
 };

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/dsfFLACDecoder.vcproj
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/dsfFLACDecoder.vcproj	2004-10-16 16:19:09 UTC (rev 8030)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/dsfFLACDecoder.vcproj	2004-10-16 16:51:51 UTC (rev 8031)
@@ -19,7 +19,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\dsfAbstractAudioDecoder;..\..\..\..\core\ogg\libOOOgg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper\libilliCore"
+				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\dsfAbstractAudioDecoder;..\..\..\..\core\ogg\libOOOgg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper\libilliCore;..\..\libs\libFLACHelper"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DSFFLACDECODER_EXPORTS"
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
@@ -37,7 +37,7 @@
 				AdditionalDependencies="Strmbasd.lib Msvcrtd.lib Winmm.lib  Strmiids.lib  Quartz.lib"
 				OutputFile="$(OutDir)/dsfFLACDecoder.dll"
 				LinkIncremental="2"
-				AdditionalLibraryDirectories="&quot;E:\Projects\C++\Ogg\libOOOgg\libflac\obj\debug\lib&quot;;&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses\Debug&quot;"
+				AdditionalLibraryDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses\Debug&quot;"
 				ModuleDefinitionFile="FLACdecoder.def"
 				GenerateDebugInformation="TRUE"
 				ProgramDatabaseFile="$(OutDir)/dsfFLACDecoder.pdb"
@@ -81,7 +81,7 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForProcessor="3"
-				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\dsfAbstractAudioDecoder;..\..\..\..\core\ogg\libOOOgg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper\libilliCore"
+				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\dsfAbstractAudioDecoder;..\..\..\..\core\ogg\libOOOgg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper\libilliCore;..\..\libs\libFLACHelper"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DSFFLACDECODER_EXPORTS"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
@@ -98,7 +98,7 @@
 				AdditionalDependencies="Strmbase.lib Winmm.lib Strmiids.lib  Quartz.lib"
 				OutputFile="$(OutDir)/dsfFLACDecoder.dll"
 				LinkIncremental="1"
-				AdditionalLibraryDirectories="&quot;E:\Projects\C++\Ogg\libOOOgg\libflac\obj\release\lib&quot;;&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses\Release&quot;"
+				AdditionalLibraryDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses\Release&quot;"
 				ModuleDefinitionFile="FLACdecoder.def"
 				GenerateDebugInformation="TRUE"
 				SubSystem="2"
@@ -144,7 +144,7 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForProcessor="3"
-				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\dsfAbstractAudioDecoder;..\..\..\..\core\ogg\libOOOgg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper\libilliCore"
+				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\dsfAbstractAudioDecoder;..\..\..\..\core\ogg\libOOOgg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper\libilliCore;..\..\libs\libFLACHelper"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DSFFLACDECODER_EXPORTS"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
@@ -162,7 +162,7 @@
 				AdditionalDependencies="Strmbase.lib Winmm.lib Strmiids.lib  Quartz.lib"
 				OutputFile="$(OutDir)/dsfFLACDecoder.dll"
 				LinkIncremental="1"
-				AdditionalLibraryDirectories="&quot;E:\Projects\C++\Ogg\libOOOgg\libflac\obj\release\lib&quot;;&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses\Release&quot;"
+				AdditionalLibraryDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses\Release&quot;"
 				ModuleDefinitionFile="FLACdecoder.def"
 				GenerateDebugInformation="TRUE"
 				SubSystem="2"
@@ -208,7 +208,7 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForProcessor="3"
-				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\dsfAbstractAudioDecoder;..\..\..\..\core\ogg\libOOOgg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper\libilliCore"
+				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\dsfAbstractAudioDecoder;..\..\..\..\core\ogg\libOOOgg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper\libilliCore;..\..\libs\libFLACHelper"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DSFFLACDECODER_EXPORTS"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
@@ -226,7 +226,7 @@
 				AdditionalDependencies="Strmbase.lib Winmm.lib Strmiids.lib  Quartz.lib"
 				OutputFile="$(OutDir)/dsfFLACDecoder.dll"
 				LinkIncremental="1"
-				AdditionalLibraryDirectories="&quot;E:\Projects\C++\Ogg\libOOOgg\libflac\obj\release\lib&quot;;&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses\Release&quot;"
+				AdditionalLibraryDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses\Release&quot;"
 				ModuleDefinitionFile="FLACdecoder.def"
 				GenerateDebugInformation="TRUE"
 				SubSystem="2"



More information about the commits mailing list