From 6a32d2ce4679b50d9615471217dc1ed0d37c4dae Mon Sep 17 00:00:00 2001 From: Hidenori Takeshima <hidenori@a2.ctktv.ne.jp> Date: Tue, 19 Feb 2002 18:30:26 +0000 Subject: [PATCH] Fixed some deadlocks. --- dlls/quartz/asyncsrc.c | 2 +- dlls/quartz/audren.c | 10 ++++++++-- dlls/quartz/audren.h | 2 ++ dlls/quartz/basefilt.h | 2 ++ dlls/quartz/basepin.c | 13 +++++++++---- dlls/quartz/mtype.c | 4 ++-- dlls/quartz/parser.c | 4 ++-- dlls/quartz/vidren.c | 24 ++++++++++++------------ dlls/quartz/vidren.h | 3 ++- dlls/quartz/xform.c | 33 +++++++++++++++++---------------- dlls/quartz/xform.h | 3 ++- 11 files changed, 59 insertions(+), 41 deletions(-) diff --git a/dlls/quartz/asyncsrc.c b/dlls/quartz/asyncsrc.c index c72b2455e7d..bf860483a76 100644 --- a/dlls/quartz/asyncsrc.c +++ b/dlls/quartz/asyncsrc.c @@ -1083,7 +1083,7 @@ HRESULT QUARTZ_CreateAsyncSourcePin( hr = CPinBaseImpl_InitIPin( &This->pin, This->unk.punkControl, - pcsPin, + pcsPin, NULL, &pFilter->basefilter, pwszPinName, TRUE, diff --git a/dlls/quartz/audren.c b/dlls/quartz/audren.c index 4a2c87f8f0e..cad6b94645c 100644 --- a/dlls/quartz/audren.c +++ b/dlls/quartz/audren.c @@ -663,6 +663,8 @@ static void QUARTZ_DestroyAudioRenderer(IUnknown* punk) CAudioRendererImpl_UninitIBasicAudio(This); CBaseFilterImpl_UninitIBaseFilter(&This->basefilter); + + DeleteCriticalSection( &This->m_csReceive ); } HRESULT QUARTZ_CreateAudioRenderer(IUnknown* punkOuter,void** ppobj) @@ -712,9 +714,12 @@ HRESULT QUARTZ_CreateAudioRenderer(IUnknown* punkOuter,void** ppobj) This->unk.dwEntries = sizeof(FilterIFEntries)/sizeof(FilterIFEntries[0]); This->unk.pOnFinalRelease = QUARTZ_DestroyAudioRenderer; + InitializeCriticalSection( &This->m_csReceive ); + hr = QUARTZ_CreateAudioRendererPin( This, &This->basefilter.csFilter, + &This->m_csReceive, &This->pPin ); if ( SUCCEEDED(hr) ) hr = QUARTZ_CompList_AddComp( @@ -764,12 +769,13 @@ static void QUARTZ_DestroyAudioRendererPin(IUnknown* punk) HRESULT QUARTZ_CreateAudioRendererPin( CAudioRendererImpl* pFilter, CRITICAL_SECTION* pcsPin, + CRITICAL_SECTION* pcsPinReceive, CAudioRendererPinImpl** ppPin) { CAudioRendererPinImpl* This = NULL; HRESULT hr; - TRACE("(%p,%p,%p)\n",pFilter,pcsPin,ppPin); + TRACE("(%p,%p,%p,%p)\n",pFilter,pcsPin,pcsPinReceive,ppPin); This = (CAudioRendererPinImpl*) QUARTZ_AllocObj( sizeof(CAudioRendererPinImpl) ); @@ -782,7 +788,7 @@ HRESULT QUARTZ_CreateAudioRendererPin( hr = CPinBaseImpl_InitIPin( &This->pin, This->unk.punkControl, - pcsPin, + pcsPin, pcsPinReceive, &pFilter->basefilter, QUARTZ_AudioRenderPin_Name, FALSE, diff --git a/dlls/quartz/audren.h b/dlls/quartz/audren.h index c3ba4343068..25a976fa6dc 100644 --- a/dlls/quartz/audren.h +++ b/dlls/quartz/audren.h @@ -35,6 +35,7 @@ struct CAudioRendererImpl CSeekingPassThru* pSeekPass; CAudioRendererPinImpl* pPin; + CRITICAL_SECTION m_csReceive; BOOL m_fInFlush; /* for waveOut */ @@ -66,6 +67,7 @@ HRESULT QUARTZ_CreateAudioRenderer(IUnknown* punkOuter,void** ppobj); HRESULT QUARTZ_CreateAudioRendererPin( CAudioRendererImpl* pFilter, CRITICAL_SECTION* pcsPin, + CRITICAL_SECTION* pcsPinReceive, CAudioRendererPinImpl** ppPin); diff --git a/dlls/quartz/basefilt.h b/dlls/quartz/basefilt.h index b80da11c042..742370f264b 100644 --- a/dlls/quartz/basefilt.h +++ b/dlls/quartz/basefilt.h @@ -85,6 +85,7 @@ typedef struct CPinBaseImpl ULONG cAcceptTypes; CRITICAL_SECTION* pcsPin; + CRITICAL_SECTION* pcsPinReceive; CBaseFilterImpl* pFilter; IPin* pPinConnectedTo; IMemInputPin* pMemInputPinConnectedTo; @@ -138,6 +139,7 @@ struct CBasePinHandlers HRESULT CPinBaseImpl_InitIPin( CPinBaseImpl* This, IUnknown* punkControl, CRITICAL_SECTION* pcsPin, + CRITICAL_SECTION* pcsPinReceive, CBaseFilterImpl* pFilter, LPCWSTR pwszId, BOOL bOutput, const CBasePinHandlers* pHandlers ); diff --git a/dlls/quartz/basepin.c b/dlls/quartz/basepin.c index 81bdb7653c9..06ba426e573 100644 --- a/dlls/quartz/basepin.c +++ b/dlls/quartz/basepin.c @@ -488,10 +488,10 @@ CPinBaseImpl_fnEndOfStream(IPin* iface) if ( This->bOutput ) return E_UNEXPECTED; - EnterCriticalSection( This->pcsPin ); + EnterCriticalSection( This->pcsPinReceive ); if ( This->pHandlers->pEndOfStream != NULL ) hr = This->pHandlers->pEndOfStream(This); - LeaveCriticalSection( This->pcsPin ); + LeaveCriticalSection( This->pcsPinReceive ); return hr; } @@ -512,6 +512,9 @@ CPinBaseImpl_fnBeginFlush(IPin* iface) hr = This->pHandlers->pBeginFlush(This); LeaveCriticalSection( This->pcsPin ); + EnterCriticalSection( This->pcsPinReceive ); + LeaveCriticalSection( This->pcsPinReceive ); + return hr; } @@ -585,6 +588,7 @@ static ICOM_VTABLE(IPin) ipin = HRESULT CPinBaseImpl_InitIPin( CPinBaseImpl* This, IUnknown* punkControl, CRITICAL_SECTION* pcsPin, + CRITICAL_SECTION* pcsPinReceive, CBaseFilterImpl* pFilter, LPCWSTR pwszId, BOOL bOutput, const CBasePinHandlers* pHandlers ) @@ -608,6 +612,7 @@ HRESULT CPinBaseImpl_InitIPin( This->pmtAcceptTypes = NULL; This->cAcceptTypes = 0; This->pcsPin = pcsPin; + This->pcsPinReceive = pcsPinReceive; This->pFilter = pFilter; This->pPinConnectedTo = NULL; This->pMemInputPinConnectedTo = NULL; @@ -766,10 +771,10 @@ CMemInputPinBaseImpl_fnReceive(IMemInputPin* iface,IMediaSample* pSample) TRACE("(%p)->(%p)\n",This,pSample); - EnterCriticalSection( This->pPin->pcsPin ); + EnterCriticalSection( This->pPin->pcsPinReceive ); if ( This->pPin->pHandlers->pReceive != NULL ) hr = This->pPin->pHandlers->pReceive(This->pPin,pSample); - LeaveCriticalSection( This->pPin->pcsPin ); + LeaveCriticalSection( This->pPin->pcsPinReceive ); return hr; } diff --git a/dlls/quartz/mtype.c b/dlls/quartz/mtype.c index 00dcfad9409..d31bcac5109 100644 --- a/dlls/quartz/mtype.c +++ b/dlls/quartz/mtype.c @@ -174,7 +174,7 @@ HRESULT QUARTZ_MediaSubType_FromBitmap( if ( pbi->biPlanes == 1 && pbi->biHeight > 0 && pbi->biBitCount == 8 ) { - QUARTZ_MediaSubType_FromFourCC( psubtype, mmioFOURCC('M','R','L','E') ); + QUARTZ_MediaSubType_FromFourCC( psubtype, 1 ); hr = S_OK; } break; @@ -182,7 +182,7 @@ HRESULT QUARTZ_MediaSubType_FromBitmap( if ( pbi->biPlanes == 1 && pbi->biHeight > 0 && pbi->biBitCount == 4 ) { - QUARTZ_MediaSubType_FromFourCC( psubtype, mmioFOURCC('M','R','L','E') ); + QUARTZ_MediaSubType_FromFourCC( psubtype, 2 ); hr = S_OK; } break; diff --git a/dlls/quartz/parser.c b/dlls/quartz/parser.c index 16ce54f8a39..55d91f5121f 100644 --- a/dlls/quartz/parser.c +++ b/dlls/quartz/parser.c @@ -1115,7 +1115,7 @@ HRESULT QUARTZ_CreateParserInPin( hr = CPinBaseImpl_InitIPin( &This->pin, This->unk.punkControl, - pcsPin, + pcsPin, NULL, &pFilter->basefilter, pwszPinName, FALSE, @@ -1217,7 +1217,7 @@ HRESULT QUARTZ_CreateParserOutPin( hr = CPinBaseImpl_InitIPin( &This->pin, This->unk.punkControl, - pcsPin, + pcsPin, NULL, &pFilter->basefilter, pwszPinName, TRUE, diff --git a/dlls/quartz/vidren.c b/dlls/quartz/vidren.c index aafcfe5dbcd..7de3cc8c45d 100644 --- a/dlls/quartz/vidren.c +++ b/dlls/quartz/vidren.c @@ -129,9 +129,9 @@ VIDREN_WndProc( { case WM_PAINT: TRACE("WM_PAINT begin\n"); - EnterCriticalSection( &This->m_csSample ); + EnterCriticalSection( &This->m_csReceive ); VIDREN_OnPaint( This, hwnd ); - LeaveCriticalSection( &This->m_csSample ); + LeaveCriticalSection( &This->m_csReceive ); TRACE("WM_PAINT end\n"); return 0; case WM_CLOSE: @@ -320,9 +320,9 @@ static HRESULT CVideoRendererImpl_OnInactive( CBaseFilterImpl* pImpl ) FIXME( "(%p)\n", This ); - EnterCriticalSection( &This->m_csSample ); + EnterCriticalSection( &This->m_csReceive ); This->m_bSampleIsValid = FALSE; - LeaveCriticalSection( &This->m_csSample ); + LeaveCriticalSection( &This->m_csReceive ); return NOERROR; } @@ -485,11 +485,9 @@ static HRESULT CVideoRendererPinImpl_Receive( CPinBaseImpl* pImpl, IMediaSample* return NOERROR; } - EnterCriticalSection( &This->pRender->m_csSample ); memcpy(This->pRender->m_pSampleData,pData,lLength); This->pRender->m_bSampleIsValid = TRUE; PostMessageA( hwnd, VIDRENMSG_UPDATE, 0, 0 ); - LeaveCriticalSection( &This->pRender->m_csSample ); return NOERROR; } @@ -525,9 +523,9 @@ static HRESULT CVideoRendererPinImpl_BeginFlush( CPinBaseImpl* pImpl ) FIXME( "(%p)\n", This ); This->pRender->m_fInFlush = TRUE; - EnterCriticalSection( &This->pRender->m_csSample ); + EnterCriticalSection( &This->pRender->m_csReceive ); This->pRender->m_bSampleIsValid = FALSE; - LeaveCriticalSection( &This->pRender->m_csSample ); + LeaveCriticalSection( &This->pRender->m_csReceive ); return NOERROR; } @@ -631,7 +629,7 @@ static void QUARTZ_DestroyVideoRenderer(IUnknown* punk) CVideoRendererImpl_UninitIVideoWindow(This); CBaseFilterImpl_UninitIBaseFilter(&This->basefilter); - DeleteCriticalSection( &This->m_csSample ); + DeleteCriticalSection( &This->m_csReceive ); } HRESULT QUARTZ_CreateVideoRenderer(IUnknown* punkOuter,void** ppobj) @@ -694,11 +692,12 @@ HRESULT QUARTZ_CreateVideoRenderer(IUnknown* punkOuter,void** ppobj) This->unk.dwEntries = sizeof(FilterIFEntries)/sizeof(FilterIFEntries[0]); This->unk.pOnFinalRelease = QUARTZ_DestroyVideoRenderer; - InitializeCriticalSection( &This->m_csSample ); + InitializeCriticalSection( &This->m_csReceive ); hr = QUARTZ_CreateVideoRendererPin( This, &This->basefilter.csFilter, + &This->m_csReceive, &This->pPin ); if ( SUCCEEDED(hr) ) hr = QUARTZ_CompList_AddComp( @@ -747,12 +746,13 @@ static void QUARTZ_DestroyVideoRendererPin(IUnknown* punk) HRESULT QUARTZ_CreateVideoRendererPin( CVideoRendererImpl* pFilter, CRITICAL_SECTION* pcsPin, + CRITICAL_SECTION* pcsPinReceive, CVideoRendererPinImpl** ppPin) { CVideoRendererPinImpl* This = NULL; HRESULT hr; - TRACE("(%p,%p,%p)\n",pFilter,pcsPin,ppPin); + TRACE("(%p,%p,%p,%p)\n",pFilter,pcsPin,pcsPinReceive,ppPin); This = (CVideoRendererPinImpl*) QUARTZ_AllocObj( sizeof(CVideoRendererPinImpl) ); @@ -765,7 +765,7 @@ HRESULT QUARTZ_CreateVideoRendererPin( hr = CPinBaseImpl_InitIPin( &This->pin, This->unk.punkControl, - pcsPin, + pcsPin, pcsPinReceive, &pFilter->basefilter, QUARTZ_VideoRendererPin_Name, FALSE, diff --git a/dlls/quartz/vidren.h b/dlls/quartz/vidren.h index a56c530b06e..ddd88466390 100644 --- a/dlls/quartz/vidren.h +++ b/dlls/quartz/vidren.h @@ -42,7 +42,7 @@ struct CVideoRendererImpl HANDLE m_hEventInit; HANDLE m_hThread; HWND m_hwnd; - CRITICAL_SECTION m_csSample; + CRITICAL_SECTION m_csReceive; BOOL m_bSampleIsValid; BYTE* m_pSampleData; DWORD m_cbSampleData; @@ -71,6 +71,7 @@ HRESULT QUARTZ_CreateVideoRenderer(IUnknown* punkOuter,void** ppobj); HRESULT QUARTZ_CreateVideoRendererPin( CVideoRendererImpl* pFilter, CRITICAL_SECTION* pcsPin, + CRITICAL_SECTION* pcsPinReceive, CVideoRendererPinImpl** ppPin); diff --git a/dlls/quartz/xform.c b/dlls/quartz/xform.c index 8a4e96a89b6..6fa31ebc99d 100644 --- a/dlls/quartz/xform.c +++ b/dlls/quartz/xform.c @@ -57,7 +57,7 @@ static HRESULT CTransformBaseImpl_OnInactive( CBaseFilterImpl* pImpl ) This->pOutPin->pin.pPinConnectedTo == NULL ) return NOERROR; - EnterCriticalSection( &This->csFilter ); + EnterCriticalSection( &This->basefilter.csFilter ); pAllocator = This->m_pOutPinAllocator; if ( pAllocator != NULL && @@ -78,7 +78,7 @@ static HRESULT CTransformBaseImpl_OnInactive( CBaseFilterImpl* pImpl ) hr = NOERROR; end: - LeaveCriticalSection( &This->csFilter ); + LeaveCriticalSection( &This->basefilter.csFilter ); return hr; } @@ -90,7 +90,7 @@ static HRESULT CTransformBaseImpl_OnStop( CBaseFilterImpl* pImpl ) TRACE( "(%p)\n", This ); - EnterCriticalSection( &This->csFilter ); + EnterCriticalSection( &This->basefilter.csFilter ); if ( This->m_bFiltering ) { @@ -110,7 +110,7 @@ static HRESULT CTransformBaseImpl_OnStop( CBaseFilterImpl* pImpl ) IMemAllocator_Decommit( pAllocator ); } - LeaveCriticalSection( &This->csFilter ); + LeaveCriticalSection( &This->basefilter.csFilter ); return NOERROR; } @@ -135,14 +135,14 @@ static HRESULT CTransformBaseInPinImpl_OnPostConnect( CPinBaseImpl* pImpl, IPin* TRACE( "(%p,%p)\n", This, pPin ); - EnterCriticalSection( &This->pFilter->csFilter ); + EnterCriticalSection( &This->pFilter->basefilter.csFilter ); hr = This->pFilter->m_pHandler->pGetOutputTypes( This->pFilter, This->pFilter->pInPin->pin.pmtConn, &This->pFilter->pOutPin->pin.pmtAcceptTypes, &This->pFilter->pOutPin->pin.cAcceptTypes ); if ( FAILED(hr) ) goto end; hr = NOERROR; end: - LeaveCriticalSection( &This->pFilter->csFilter ); + LeaveCriticalSection( &This->pFilter->basefilter.csFilter ); return hr; } @@ -170,9 +170,9 @@ static HRESULT CTransformBaseInPinImpl_CheckMediaType( CPinBaseImpl* pImpl, cons TRACE( "(%p,%p)\n", This, pmt ); - EnterCriticalSection( &This->pFilter->csFilter ); + EnterCriticalSection( &This->pFilter->basefilter.csFilter ); hr = This->pFilter->m_pHandler->pCheckMediaType( This->pFilter, pmt, (This->pFilter->pOutPin->pin.pPinConnectedTo != NULL) ? This->pFilter->pOutPin->pin.pmtConn : NULL ); - LeaveCriticalSection( &This->pFilter->csFilter ); + LeaveCriticalSection( &This->pFilter->basefilter.csFilter ); return hr; } @@ -449,9 +449,9 @@ static HRESULT CTransformBaseOutPinImpl_CheckMediaType( CPinBaseImpl* pImpl, con if ( This->pFilter->pInPin->pin.pPinConnectedTo == NULL ) return E_FAIL; - EnterCriticalSection( &This->pFilter->csFilter ); + EnterCriticalSection( &This->pFilter->basefilter.csFilter ); hr = This->pFilter->m_pHandler->pCheckMediaType( This->pFilter, This->pFilter->pInPin->pin.pmtConn, pmt ); - LeaveCriticalSection( &This->pFilter->csFilter ); + LeaveCriticalSection( &This->pFilter->basefilter.csFilter ); return hr; } @@ -512,7 +512,7 @@ static void QUARTZ_DestroyTransformBase(IUnknown* punk) CBaseFilterImpl_UninitIBaseFilter(&This->basefilter); - DeleteCriticalSection( &This->csFilter ); + DeleteCriticalSection( &This->csReceive ); } HRESULT QUARTZ_CreateTransformBase( @@ -577,11 +577,11 @@ HRESULT QUARTZ_CreateTransformBase( This->unk.pEntries = FilterIFEntries; This->unk.dwEntries = sizeof(FilterIFEntries)/sizeof(FilterIFEntries[0]); This->unk.pOnFinalRelease = QUARTZ_DestroyTransformBase; - InitializeCriticalSection( &This->csFilter ); + InitializeCriticalSection( &This->csReceive ); /* create pins. */ hr = QUARTZ_CreateTransformBaseInPin( - This, &This->csFilter, + This, &This->basefilter.csFilter, &This->csReceive, &This->pInPin, pwszInPinName ); if ( SUCCEEDED(hr) ) hr = QUARTZ_CompList_AddComp( @@ -590,7 +590,7 @@ HRESULT QUARTZ_CreateTransformBase( NULL, 0 ); if ( SUCCEEDED(hr) ) hr = QUARTZ_CreateTransformBaseOutPin( - This, &This->csFilter, + This, &This->basefilter.csFilter, &This->pOutPin, pwszOutPinName ); if ( SUCCEEDED(hr) ) hr = QUARTZ_CompList_AddComp( @@ -642,6 +642,7 @@ static void QUARTZ_DestroyTransformBaseInPin(IUnknown* punk) HRESULT QUARTZ_CreateTransformBaseInPin( CTransformBaseImpl* pFilter, CRITICAL_SECTION* pcsPin, + CRITICAL_SECTION* pcsPinReceive, CTransformBaseInPinImpl** ppPin, LPCWSTR pwszPinName ) { @@ -661,7 +662,7 @@ HRESULT QUARTZ_CreateTransformBaseInPin( hr = CPinBaseImpl_InitIPin( &This->pin, This->unk.punkControl, - pcsPin, + pcsPin, pcsPinReceive, &pFilter->basefilter, pwszPinName, FALSE, @@ -764,7 +765,7 @@ HRESULT QUARTZ_CreateTransformBaseOutPin( hr = CPinBaseImpl_InitIPin( &This->pin, This->unk.punkControl, - pcsPin, + pcsPin, NULL, &pFilter->basefilter, pwszPinName, TRUE, diff --git a/dlls/quartz/xform.h b/dlls/quartz/xform.h index db33360bb23..0d0c1636ae5 100644 --- a/dlls/quartz/xform.h +++ b/dlls/quartz/xform.h @@ -26,7 +26,7 @@ struct CTransformBaseImpl CTransformBaseOutPinImpl* pOutPin; CSeekingPassThru* pSeekPass; - CRITICAL_SECTION csFilter; + CRITICAL_SECTION csReceive; IMemAllocator* m_pOutPinAllocator; BOOL m_bPreCopy; /* sample must be copied */ BOOL m_bReuseSample; /* sample must be reused */ @@ -94,6 +94,7 @@ HRESULT QUARTZ_CreateTransformBase( HRESULT QUARTZ_CreateTransformBaseInPin( CTransformBaseImpl* pFilter, CRITICAL_SECTION* pcsPin, + CRITICAL_SECTION* pcsPinReceive, CTransformBaseInPinImpl** ppPin, LPCWSTR pwszPinName ); HRESULT QUARTZ_CreateTransformBaseOutPin( -- GitLab