[xiph-commits] r8053 - in trunk/oggdsf/src/lib: codecs/flac/filters/dsfFLACDecoder core/directshow/dsfAbstractAudioDecoder

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Mon Oct 18 23:22:26 PDT 2004


Author: illiminable
Date: 2004-10-18 23:22:26 -0700 (Mon, 18 Oct 2004)
New Revision: 8053

Modified:
   trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeFilter.cpp
   trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.cpp
Log:
* FLAC decoder leak free.

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeFilter.cpp	2004-10-19 06:03:02 UTC (rev 8052)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeFilter.cpp	2004-10-19 06:22:26 UTC (rev 8053)
@@ -60,17 +60,18 @@
 {
 	//DestroyPins();
 	delete mFLACFormatBlock;
+	mFLACFormatBlock = NULL;
 }
 
 bool FLACDecodeFilter::ConstructPins() 
 {
 	//Output pin must be done first because it's passed to the input pin.
-	mOutputPin = new FLACDecodeOutputPin(this, m_pLock);
+	mOutputPin = new FLACDecodeOutputPin(this, m_pLock);				//Deleted in destroy pins in base class.
 
-	CMediaType* locAcceptMediaType = new CMediaType(&MEDIATYPE_Audio);
+	CMediaType* locAcceptMediaType = new CMediaType(&MEDIATYPE_Audio);			//Given to Input pin... it's responsible (deletes in base constructor of pin)
 	locAcceptMediaType->subtype = MEDIASUBTYPE_FLAC;
 	locAcceptMediaType->formattype = FORMAT_FLAC;
-	mInputPin = new FLACDecodeInputPin(this, m_pLock, mOutputPin, locAcceptMediaType);
+	mInputPin = new FLACDecodeInputPin(this, m_pLock, mOutputPin, locAcceptMediaType);			//Pin destroyed in base class, media type destroyed in base.
 	return true;
 }
 
@@ -91,6 +92,6 @@
 void FLACDecodeFilter::setFLACFormatBlock(sFLACFormatBlock* inFormatBlock) 
 {
 	delete mFLACFormatBlock;
-	mFLACFormatBlock = new sFLACFormatBlock;
+	mFLACFormatBlock = new sFLACFormatBlock;		//Deleted in destructor.
 	*mFLACFormatBlock = *inFormatBlock;
 }
\ No newline at end of file

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp	2004-10-19 06:03:02 UTC (rev 8052)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp	2004-10-19 06:22:26 UTC (rev 8053)
@@ -40,7 +40,7 @@
 	//,	mNumPacksBuffered(0)
 {
 	//debugLog.open("G:\\logs\\flacfilter.log", ios_base::out);
-	mCodecLock = new CCritSec;
+	mCodecLock = new CCritSec;			//Deleted in destructor.
 	ConstructCodec();
 }
 
@@ -83,7 +83,7 @@
 	//delete mPendingPacket;
 	//debugLog<<"decodeData : "<<endl;
 	if(!m_bFlushing) {
-		unsigned char* locBuff = new unsigned char[inNumBytes];
+		unsigned char* locBuff = new unsigned char[inNumBytes];			//Given to packet.
 		memcpy((void*)locBuff, (const void*)inBuf, inNumBytes);
 
 		OggPacket* locPacket = new OggPacket(locBuff, inNumBytes, false, false);	//We give this away.
@@ -93,7 +93,7 @@
 			{
 				CAutoLock locCodecLock(mCodecLock);
 				//for(unsigned long i = 0; i < mPendingPackets.size(); i++) {
-				 locStamped = (StampedOggPacket*)mFLACDecoder.decodeFLAC(locPacket)->clone();
+				 locStamped = (StampedOggPacket*)mFLACDecoder.decodeFLAC(locPacket)->clone();			//clone deleted below, locpacket accepted by decoder.
 			}
 
 			if (locStamped != NULL) {
@@ -106,7 +106,8 @@
 				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;
+					delete locStamped;
+					return -1;
 				}	
 
 
@@ -140,6 +141,7 @@
 						//debugLog<<"Write_Callback : Delivery of sample succeeded"<<endl;
 					}
 				} else {
+					delete locStamped;
 					throw 0;		//SAMPLE SIZE IS TOO SMALL TO FIT DATA
 				}
 
@@ -153,7 +155,7 @@
 		} else {
 			{
 				CAutoLock locCodecLock(mCodecLock);
-				mGotMetaData = mFLACDecoder.acceptMetadata(locPacket);
+				mGotMetaData = mFLACDecoder.acceptMetadata(locPacket);		//Accepts the packet.
 			}
 			if (mGotMetaData) {
 				return 0;
@@ -209,7 +211,7 @@
 		
 		//Keep the format block
 		
-		((FLACDecodeFilter*)mParentFilter)->setFLACFormatBlock((sFLACFormatBlock*)inMediaType->pbFormat);
+		((FLACDecodeFilter*)mParentFilter)->setFLACFormatBlock((sFLACFormatBlock*)inMediaType->pbFormat);		//Copies the format in the mutator
 
 	} else {
 		throw 0;

Modified: trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.cpp	2004-10-19 06:03:02 UTC (rev 8052)
+++ trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.cpp	2004-10-19 06:22:26 UTC (rev 8053)
@@ -108,6 +108,8 @@
 	//DestroyCodec();
 	//debugLog.close();
 	delete mStreamLock;
+	delete mAcceptableMediaType;
+	mAcceptableMediaType = NULL;
 }
 
 



More information about the commits mailing list