[xiph-commits] r7644 - in trunk/oggdsf/src/lib: codecs/vorbis/filters/dsfVorbisDecoder core/directshow/dsfAbstractAudioDecoder core/directshow/dsfAbstractVideoDecoder

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Fri Aug 27 04:27:02 PDT 2004


Author: illiminable
Date: 2004-08-27 04:27:02 -0700 (Fri, 27 Aug 2004)
New Revision: 7644

Modified:
   trunk/oggdsf/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/VorbisDecodeInputPin.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.h
   trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeOutputPin.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoDecoder/AbstractVideoDecodeInputPin.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoDecoder/AbstractVideoDecodeInputPin.h
Log:
* Fixed more refernce counting problems in the video decoder.

Modified: trunk/oggdsf/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/VorbisDecodeInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/VorbisDecodeInputPin.cpp	2004-08-27 09:37:32 UTC (rev 7643)
+++ trunk/oggdsf/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/VorbisDecodeInputPin.cpp	2004-08-27 11:27:02 UTC (rev 7644)
@@ -89,109 +89,115 @@
 	VorbisDecodeFilter* locFilter = reinterpret_cast<VorbisDecodeFilter*>(locThis->m_pFilter);
 	
 
-	if (! locThis->mBegun) {
+	if (locThis->CheckStreaming() == S_OK) {
+		if (! locThis->mBegun) {
 
-	
-		fish_sound_command (locThis->mFishSound, FISH_SOUND_GET_INFO, &(locThis->mFishInfo), sizeof (FishSoundInfo)); 
-		locThis->mBegun = true;
 		
-		locThis->mNumChannels = locThis->mFishInfo.channels;
-		locThis->mFrameSize = locThis->mNumChannels * SIZE_16_BITS;
-		locThis->mSampleRate = locThis->mFishInfo.samplerate;
+			fish_sound_command (locThis->mFishSound, FISH_SOUND_GET_INFO, &(locThis->mFishInfo), sizeof (FishSoundInfo)); 
+			locThis->mBegun = true;
+			
+			locThis->mNumChannels = locThis->mFishInfo.channels;
+			locThis->mFrameSize = locThis->mNumChannels * SIZE_16_BITS;
+			locThis->mSampleRate = locThis->mFishInfo.samplerate;
 
-	}
+		}
 
-	//FIX::: Most of this will be obselete... the demux does it all.
-	
+		//FIX::: Most of this will be obselete... the demux does it all.
+		
 
-	unsigned long locActualSize = inFrames * locThis->mFrameSize;
-	unsigned long locTotalFrameCount = inFrames * locThis->mNumChannels;
-	
-	//REFERENCE_TIME locFrameStart = locThis->CurrentStartTime() + (((__int64)(locThis->mUptoFrame * UNITS)) / locThis->mSampleRate);
+		unsigned long locActualSize = inFrames * locThis->mFrameSize;
+		unsigned long locTotalFrameCount = inFrames * locThis->mNumChannels;
+		
+		//REFERENCE_TIME locFrameStart = locThis->CurrentStartTime() + (((__int64)(locThis->mUptoFrame * UNITS)) / locThis->mSampleRate);
 
-	//Start time hacks
-	REFERENCE_TIME locTimeBase = ((locThis->mLastSeenStartGranPos * UNITS) / locThis->mSampleRate) - locThis->mSeekTimeBase;
-	//locThis->aadDebug<<"Last Seen  : " <<locThis->mLastSeenStartGranPos<<endl;
-	//locThis->debugLog<<"Last Seen  : " << locThis->mLastSeenStartGranPos<<endl;
-	//locThis->debugLog<<"Time Base  : " << locTimeBase << endl;
-	//locThis->debugLog<<"FrameCount : " <<locThis->mUptoFrame<<endl;
-	//locThis->debugLog<<"Seek TB    : " <<locThis->mSeekTimeBase<<endl;
+		//Start time hacks
+		REFERENCE_TIME locTimeBase = ((locThis->mLastSeenStartGranPos * UNITS) / locThis->mSampleRate) - locThis->mSeekTimeBase;
+		//locThis->aadDebug<<"Last Seen  : " <<locThis->mLastSeenStartGranPos<<endl;
+		//locThis->debugLog<<"Last Seen  : " << locThis->mLastSeenStartGranPos<<endl;
+		//locThis->debugLog<<"Time Base  : " << locTimeBase << endl;
+		//locThis->debugLog<<"FrameCount : " <<locThis->mUptoFrame<<endl;
+		//locThis->debugLog<<"Seek TB    : " <<locThis->mSeekTimeBase<<endl;
 
-	//Temp - this will break seeking
-	REFERENCE_TIME locFrameStart = locTimeBase + (((__int64)(locThis->mUptoFrame * UNITS)) / locThis->mSampleRate);
-	//Increment the frame counter
-	locThis->mUptoFrame += inFrames;
-	//Make the end frame counter
+		//Temp - this will break seeking
+		REFERENCE_TIME locFrameStart = locTimeBase + (((__int64)(locThis->mUptoFrame * UNITS)) / locThis->mSampleRate);
+		//Increment the frame counter
+		locThis->mUptoFrame += inFrames;
+		//Make the end frame counter
 
-	//REFERENCE_TIME locFrameEnd = locThis->CurrentStartTime() + (((__int64)(locThis->mUptoFrame * UNITS)) / locThis->mSampleRate);
-	REFERENCE_TIME locFrameEnd = locTimeBase + (((__int64)(locThis->mUptoFrame * UNITS)) / locThis->mSampleRate);
+		//REFERENCE_TIME locFrameEnd = locThis->CurrentStartTime() + (((__int64)(locThis->mUptoFrame * UNITS)) / locThis->mSampleRate);
+		REFERENCE_TIME locFrameEnd = locTimeBase + (((__int64)(locThis->mUptoFrame * UNITS)) / locThis->mSampleRate);
 
 
-	//locThis->debugLog<<"Start      : "<<locFrameStart<<endl;
-	//locThis->debugLog<<"End        : "<<locFrameEnd<<endl;
-	//locThis->debugLog<<"=================================================="<<endl;
-	IMediaSample* locSample;
-	HRESULT locHR = locThis->mOutputPin->GetDeliveryBuffer(&locSample, &locFrameStart, &locFrameEnd, NULL);
+		//locThis->debugLog<<"Start      : "<<locFrameStart<<endl;
+		//locThis->debugLog<<"End        : "<<locFrameEnd<<endl;
+		//locThis->debugLog<<"=================================================="<<endl;
+		IMediaSample* locSample;
+		HRESULT locHR = locThis->mOutputPin->GetDeliveryBuffer(&locSample, &locFrameStart, &locFrameEnd, NULL);
 
-	if (locHR != S_OK) {
-		return -1;
-	}	
-	
+		if (locHR != S_OK) {
+			return -1;
+		}	
+		
 
-	//Create pointers for the samples buffer to be assigned to
-	BYTE* locBuffer = NULL;
-	signed short* locShortBuffer = NULL;
-	
-	locSample->GetPointer(&locBuffer);
-	locShortBuffer = (short *) locBuffer;
-	
-	signed short tempInt = 0;
-	float tempFloat = 0;
-	
-	//FIX:::Move the clipping to the abstract function
+		//Create pointers for the samples buffer to be assigned to
+		BYTE* locBuffer = NULL;
+		signed short* locShortBuffer = NULL;
+		
+		locSample->GetPointer(&locBuffer);
+		locShortBuffer = (short *) locBuffer;
+		
+		signed short tempInt = 0;
+		float tempFloat = 0;
+		
+		//FIX:::Move the clipping to the abstract function
 
-	if (locSample->GetSize() >= locActualSize) {
-		//Do float to int conversion with clipping
-		const float SINT_MAX_AS_FLOAT = 32767.0f;
-		for (unsigned long i = 0; i < locTotalFrameCount; i++) {
-			//Clipping because vorbis puts out floats out of range -1 to 1
-			if (((float*)inPCM)[i] <= -1.0f) {
-				tempInt = SINT_MIN;	
-			} else if (((float*)inPCM)[i] >= 1.0f) {
-				tempInt = SINT_MAX;
-			} else {
-				//FIX:::Take out the unnescessary variable.
-				tempFloat = ((( (float*) inPCM )[i]) * SINT_MAX_AS_FLOAT);
-				//ASSERT((tempFloat <= 32767.0f) && (tempFloat >= -32786.0f));
-				tempInt = (signed short)(tempFloat);
-				//tempInt = (signed short) ((( (float*) inPCM )[i]) * SINT_MAX_AS_FLOAT);
+		if (locSample->GetSize() >= locActualSize) {
+			//Do float to int conversion with clipping
+			const float SINT_MAX_AS_FLOAT = 32767.0f;
+			for (unsigned long i = 0; i < locTotalFrameCount; i++) {
+				//Clipping because vorbis puts out floats out of range -1 to 1
+				if (((float*)inPCM)[i] <= -1.0f) {
+					tempInt = SINT_MIN;	
+				} else if (((float*)inPCM)[i] >= 1.0f) {
+					tempInt = SINT_MAX;
+				} else {
+					//FIX:::Take out the unnescessary variable.
+					tempFloat = ((( (float*) inPCM )[i]) * SINT_MAX_AS_FLOAT);
+					//ASSERT((tempFloat <= 32767.0f) && (tempFloat >= -32786.0f));
+					tempInt = (signed short)(tempFloat);
+					//tempInt = (signed short) ((( (float*) inPCM )[i]) * SINT_MAX_AS_FLOAT);
+				}
+				
+				*locShortBuffer = tempInt;
+				locShortBuffer++;
 			}
 			
-			*locShortBuffer = tempInt;
-			locShortBuffer++;
-		}
+			//Set the sample parameters.
+			locThis->SetSampleParams(locSample, locActualSize, &locFrameStart, &locFrameEnd);
+
+			{
 		
-		//Set the sample parameters.
-		locThis->SetSampleParams(locSample, locActualSize, &locFrameStart, &locFrameEnd);
+				CAutoLock locLock(locThis->m_pLock);
 
-		{
-	
-			CAutoLock locLock(locThis->m_pLock);
-
-			//Add a reference so it isn't deleted en route.... or not
-			//locSample->AddRef();
-			HRESULT lHR = locThis->mOutputPin->mDataQueue->Receive(locSample);
-			if (lHR != S_OK) {
-				return -1;
+				//Add a reference so it isn't deleted en route.... or not
+				//locSample->AddRef();
+				HRESULT lHR = locThis->mOutputPin->mDataQueue->Receive(locSample);
+				if (lHR != S_OK) {
+					DbgLog((LOG_TRACE,1,TEXT("Queue rejected us...")));
+					return -1;
+				}
 			}
-		}
 
-		//Don't Release the sample it gets done for us !
-		//locSample->Release();
+			//Don't Release the sample it gets done for us !
+			//locSample->Release();
 
-		return 0;
+			return 0;
+		} else {
+			throw 0;
+		}
 	} else {
-		throw 0;
+		DbgLog((LOG_TRACE,1,TEXT("Fishsound sending stuff we aren't ready for...")));
+		return -1;
 	}
 
 }

Modified: trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.cpp	2004-08-27 09:37:32 UTC (rev 7643)
+++ trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.cpp	2004-08-27 11:27:02 UTC (rev 7644)
@@ -47,7 +47,7 @@
 	,	mSeekTimeBase(0)
 {
 	//ConstructCodec();
-	//debugLog.open("g:\\logs\\aad.log", ios_base::out);
+	debugLog.open("g:\\logs\\aad.log", ios_base::out);
 	mAcceptableMediaType = inAcceptMediaType;
 	mStreamLock = new CCritSec;
 
@@ -89,6 +89,7 @@
 }
 
 HRESULT AbstractAudioDecodeInputPin::BreakConnect() {
+	CAutoLock locLock(mFilterLock);
 	//Need a lock ??
 	ReleaseDelegate();
 	return CBaseInputPin::BreakConnect();
@@ -104,7 +105,7 @@
 AbstractAudioDecodeInputPin::~AbstractAudioDecodeInputPin(void)
 {
 	//DestroyCodec();
-	//debugLog.close();
+	debugLog.close();
 	delete mStreamLock;
 }
 
@@ -130,52 +131,60 @@
 
 STDMETHODIMP AbstractAudioDecodeInputPin::Receive(IMediaSample* inSample) 
 {
+	//
+	inSample->AddRef();
+	debugLog<<"Received Sample with refcount = "<<inSample->Release()<<endl;
+	//
 	//TO DO::: Fix this up...
 	CAutoLock locLock(mStreamLock);
-	HRESULT locHR;
-	BYTE* locBuff = NULL;
-	locHR = inSample->GetPointer(&locBuff);
+	HRESULT locHR = CheckStreaming();
+	if (locHR == S_OK) {
+		BYTE* locBuff = NULL;
+		locHR = inSample->GetPointer(&locBuff);
 
-	if (FAILED(locHR)) {
-		
-		return locHR;
-	} else {
-		//New start time hacks
-		REFERENCE_TIME locStart = 0;
-		REFERENCE_TIME locEnd = 0;
+		if (FAILED(locHR)) {
+			
+			return locHR;
+		} else {
+			//New start time hacks
+			REFERENCE_TIME locStart = 0;
+			REFERENCE_TIME locEnd = 0;
 
-		//More work arounds for that stupid granule pos scheme in theora!
-		REFERENCE_TIME locTimeBase = 0;
-		REFERENCE_TIME locDummy = 0;
-		inSample->GetMediaTime(&locTimeBase, &locDummy);
-		mSeekTimeBase = locTimeBase;
-		//
+			//More work arounds for that stupid granule pos scheme in theora!
+			REFERENCE_TIME locTimeBase = 0;
+			REFERENCE_TIME locDummy = 0;
+			inSample->GetMediaTime(&locTimeBase, &locDummy);
+			mSeekTimeBase = locTimeBase;
+			//
 
-		inSample->GetTime(&locStart, &locEnd);
-		//Error chacks needed here
-		//debugLog<<"Receive : Start    = "<<locStart<<endl;
-		//debugLog<<"Receive : End      = "<<locEnd<<endl;
-		//debugLog<<"Receive : Timebase = "<<locTimeBase<<endl;
-		
-		if ((mLastSeenStartGranPos != locStart) && (locStart != -1)) {
-			//debugLog<<"Receive : RESETTING FRAME COUNT !!"<<endl;
-			ResetFrameCount();
-		}
-		//debugLog<<endl;
-		mLastSeenStartGranPos = locStart;
-		//End of additions
-		
-		long locResult = decodeData(locBuff, inSample->GetActualDataLength());
-		if (locResult == 0) {
+			inSample->GetTime(&locStart, &locEnd);
+			//Error chacks needed here
+			//debugLog<<"Receive : Start    = "<<locStart<<endl;
+			//debugLog<<"Receive : End      = "<<locEnd<<endl;
+			//debugLog<<"Receive : Timebase = "<<locTimeBase<<endl;
+			
+			if ((mLastSeenStartGranPos != locStart) && (locStart != -1)) {
+				//debugLog<<"Receive : RESETTING FRAME COUNT !!"<<endl;
+				ResetFrameCount();
+			}
+			//debugLog<<endl;
+			mLastSeenStartGranPos = locStart;
+			//End of additions
+			
+			long locResult = decodeData(locBuff, inSample->GetActualDataLength());
+			if (locResult == 0) {
 
-			//aadDebug<<"Receive Decode : OK"<<endl;
-			return S_OK;
-		} else {
-			//aadDebug<<"Receive Decode : *** FAILED *** "<<locResult<<endl;
-			return S_FALSE;
+				//aadDebug<<"Receive Decode : OK"<<endl;
+				return S_OK;
+			} else {
+				//aadDebug<<"Receive Decode : *** FAILED *** "<<locResult<<endl;
+				return S_FALSE;
+			}
 		}
+	} else {
+		debugLog<<"NOT STREAMING.... "<<endl;
+		return locHR;
 	}
-
 	
 	return S_OK;
 }

Modified: trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.h	2004-08-27 09:37:32 UTC (rev 7643)
+++ trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.h	2004-08-27 11:27:02 UTC (rev 7644)
@@ -96,7 +96,7 @@
 	AbstractAudioDecodeFilter* mParentFilter;
 	CMediaType* mAcceptableMediaType;
 
-	//fstream debugLog;
+	fstream debugLog;
 	CCritSec* mStreamLock;
 	CCritSec* mFilterLock;
 

Modified: trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeOutputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeOutputPin.cpp	2004-08-27 09:37:32 UTC (rev 7643)
+++ trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeOutputPin.cpp	2004-08-27 11:27:02 UTC (rev 7644)
@@ -190,8 +190,9 @@
 
 HRESULT AbstractAudioDecodeOutputPin::BreakConnect(void) {
 
+	HRESULT locHR = CBaseOutputPin::BreakConnect();
 	ReleaseDelegate();
 	delete mDataQueue;
 	mDataQueue = NULL;
-	return CBaseOutputPin::BreakConnect();
+	return locHR;
 }
\ No newline at end of file

Modified: trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoDecoder/AbstractVideoDecodeInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoDecoder/AbstractVideoDecodeInputPin.cpp	2004-08-27 09:37:32 UTC (rev 7643)
+++ trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoDecoder/AbstractVideoDecodeInputPin.cpp	2004-08-27 11:27:02 UTC (rev 7644)
@@ -75,6 +75,12 @@
 	return CBaseInputPin::NonDelegatingQueryInterface(riid, ppv); 
 }
 
+HRESULT AbstractVideoDecodeInputPin::BreakConnect() {
+	CAutoLock locLock(m_pLock);
+	//Need a lock ??
+	ReleaseDelegate();
+	return CBaseInputPin::BreakConnect();
+}
 HRESULT AbstractVideoDecodeInputPin::CompleteConnect (IPin *inReceivePin) {
 	CAutoLock locLock(m_pLock);
 	

Modified: trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoDecoder/AbstractVideoDecodeInputPin.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoDecoder/AbstractVideoDecodeInputPin.h	2004-08-27 09:37:32 UTC (rev 7643)
+++ trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoDecoder/AbstractVideoDecodeInputPin.h	2004-08-27 11:27:02 UTC (rev 7644)
@@ -57,6 +57,7 @@
 	virtual void DestroyCodec() = 0;
 	
 
+	virtual HRESULT BreakConnect();
 	virtual HRESULT CompleteConnect (IPin *inReceivePin);
 	STDMETHODIMP Receive(IMediaSample *pSample);
 	virtual HRESULT CheckMediaType(const CMediaType *inMediaType);



More information about the commits mailing list