From e8705402a40682b4e6d73856e196c2f6a8cbf3c8 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Tue, 10 Jun 2008 17:57:41 +0200 Subject: [PATCH] quartz: Add the ability to force a pin to use a certain renderer. --- dlls/quartz/dsoundrender.c | 2 +- dlls/quartz/nullrenderer.c | 2 +- dlls/quartz/pin.c | 19 ++++++++++++------- dlls/quartz/pin.h | 3 ++- dlls/quartz/transform.c | 2 +- dlls/quartz/videorenderer.c | 2 +- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/dlls/quartz/dsoundrender.c b/dlls/quartz/dsoundrender.c index 787ffe75fbf..29596eae686 100644 --- a/dlls/quartz/dsoundrender.c +++ b/dlls/quartz/dsoundrender.c @@ -344,7 +344,7 @@ HRESULT DSoundRender_create(IUnknown * pUnkOuter, LPVOID * ppv) piInput.dir = PINDIR_INPUT; piInput.pFilter = (IBaseFilter *)pDSoundRender; lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0])); - hr = InputPin_Construct(&DSoundRender_InputPin_Vtbl, &piInput, DSoundRender_Sample, pDSoundRender, DSoundRender_QueryAccept, NULL, &pDSoundRender->csFilter, (IPin **)&pDSoundRender->pInputPin); + hr = InputPin_Construct(&DSoundRender_InputPin_Vtbl, &piInput, DSoundRender_Sample, pDSoundRender, DSoundRender_QueryAccept, NULL, &pDSoundRender->csFilter, NULL, (IPin **)&pDSoundRender->pInputPin); if (SUCCEEDED(hr)) { diff --git a/dlls/quartz/nullrenderer.c b/dlls/quartz/nullrenderer.c index 45315f77be9..bcbf32b680c 100644 --- a/dlls/quartz/nullrenderer.c +++ b/dlls/quartz/nullrenderer.c @@ -198,7 +198,7 @@ HRESULT NullRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv) piInput.pFilter = (IBaseFilter *)pNullRenderer; lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0])); - hr = InputPin_Construct(&NullRenderer_InputPin_Vtbl, &piInput, NullRenderer_Sample, (LPVOID)pNullRenderer, NullRenderer_QueryAccept, NULL, &pNullRenderer->csFilter, (IPin **)&pNullRenderer->pInputPin); + hr = InputPin_Construct(&NullRenderer_InputPin_Vtbl, &piInput, NullRenderer_Sample, (LPVOID)pNullRenderer, NullRenderer_QueryAccept, NULL, &pNullRenderer->csFilter, NULL, (IPin **)&pNullRenderer->pInputPin); if (SUCCEEDED(hr)) { diff --git a/dlls/quartz/pin.c b/dlls/quartz/pin.c index 8619776b497..18079f3119d 100644 --- a/dlls/quartz/pin.c +++ b/dlls/quartz/pin.c @@ -236,7 +236,7 @@ static HRESULT OutputPin_ConnectSpecific(IPin * iface, IPin * pReceivePin, const } static HRESULT InputPin_Init(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PUSH pSampleProc, LPVOID pUserData, - QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, LPCRITICAL_SECTION pCritSec, InputPin * pPinImpl) + QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, LPCRITICAL_SECTION pCritSec, IMemAllocator *allocator, InputPin * pPinImpl) { TRACE("\n"); @@ -252,7 +252,9 @@ static HRESULT InputPin_Init(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPi /* Input pin attributes */ pPinImpl->fnSampleProc = pSampleProc; pPinImpl->fnCleanProc = pCleanUp; - pPinImpl->pAllocator = NULL; + pPinImpl->pAllocator = pPinImpl->preferred_allocator = allocator; + if (pPinImpl->preferred_allocator) + IMemAllocator_AddRef(pPinImpl->preferred_allocator); pPinImpl->tStart = 0; pPinImpl->tStop = 0; pPinImpl->dRate = 1.0; @@ -299,7 +301,7 @@ static HRESULT OutputPin_Init(const IPinVtbl *OutputPin_Vtbl, const PIN_INFO * p return S_OK; } -HRESULT InputPin_Construct(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PUSH pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, LPCRITICAL_SECTION pCritSec, IPin ** ppPin) +HRESULT InputPin_Construct(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PUSH pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, LPCRITICAL_SECTION pCritSec, IMemAllocator *allocator, IPin ** ppPin) { InputPin * pPinImpl; @@ -316,7 +318,7 @@ HRESULT InputPin_Construct(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinI if (!pPinImpl) return E_OUTOFMEMORY; - if (SUCCEEDED(InputPin_Init(InputPin_Vtbl, pPinInfo, pSampleProc, pUserData, pQueryAccept, pCleanUp, pCritSec, pPinImpl))) + if (SUCCEEDED(InputPin_Init(InputPin_Vtbl, pPinInfo, pSampleProc, pUserData, pQueryAccept, pCleanUp, pCritSec, allocator, pPinImpl))) { *ppPin = (IPin *)pPinImpl; return S_OK; @@ -552,6 +554,8 @@ ULONG WINAPI InputPin_Release(IPin * iface) FreeMediaType(&This->pin.mtCurrent); if (This->pAllocator) IMemAllocator_Release(This->pAllocator); + This->pAllocator = NULL; + This->pin.lpVtbl = NULL; CoTaskMemFree(This); return 0; } @@ -766,6 +770,9 @@ HRESULT WINAPI MemInputPin_NotifyAllocator(IMemInputPin * iface, IMemAllocator * return E_POINTER; } + if (This->preferred_allocator && pAllocator != This->preferred_allocator) + return E_FAIL; + if (This->pAllocator) IMemAllocator_Release(This->pAllocator); This->pAllocator = pAllocator; @@ -824,9 +831,7 @@ HRESULT WINAPI MemInputPin_ReceiveCanBlock(IMemInputPin * iface) { InputPin *This = impl_from_IMemInputPin(iface); - FIXME("(%p/%p)->()\n", This, iface); - - /* FIXME: we should check whether any output pins will block */ + TRACE("(%p/%p)->()\n", This, iface); return S_OK; } diff --git a/dlls/quartz/pin.h b/dlls/quartz/pin.h index 8f160bf44c3..6d0600efec1 100644 --- a/dlls/quartz/pin.h +++ b/dlls/quartz/pin.h @@ -93,6 +93,7 @@ typedef struct InputPin REFERENCE_TIME tStop; double dRate; BOOL flushing, end_of_stream; + IMemAllocator *preferred_allocator; } InputPin; typedef struct OutputPin @@ -142,7 +143,7 @@ typedef struct PullPin #define Req_Pause 3 /*** Constructors ***/ -HRESULT InputPin_Construct(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PUSH pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, LPCRITICAL_SECTION pCritSec, IPin ** ppPin); +HRESULT InputPin_Construct(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PUSH pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, LPCRITICAL_SECTION pCritSec, IMemAllocator *, IPin ** ppPin); HRESULT OutputPin_Construct(const IPinVtbl *OutputPin_Vtbl, long outputpin_size, const PIN_INFO * pPinInfo, ALLOCATOR_PROPERTIES *props, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, LPCRITICAL_SECTION pCritSec, IPin ** ppPin); HRESULT PullPin_Construct(const IPinVtbl *PullPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PULL pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, STOPPROCESSPROC, REQUESTPROC pCustomRequest, LPCRITICAL_SECTION pCritSec, IPin ** ppPin); diff --git a/dlls/quartz/transform.c b/dlls/quartz/transform.c index 7f50268841f..d602c694739 100644 --- a/dlls/quartz/transform.c +++ b/dlls/quartz/transform.c @@ -187,7 +187,7 @@ HRESULT TransformFilter_Create(TransformFilterImpl* pTransformFilter, const CLSI piOutput.pFilter = (IBaseFilter *)pTransformFilter; lstrcpynW(piOutput.achName, wcsOutputPinName, sizeof(piOutput.achName) / sizeof(piOutput.achName[0])); - hr = InputPin_Construct(&TransformFilter_InputPin_Vtbl, &piInput, TransformFilter_Sample, pTransformFilter, TransformFilter_Input_QueryAccept, NULL, &pTransformFilter->csFilter, &pTransformFilter->ppPins[0]); + hr = InputPin_Construct(&TransformFilter_InputPin_Vtbl, &piInput, TransformFilter_Sample, pTransformFilter, TransformFilter_Input_QueryAccept, NULL, &pTransformFilter->csFilter, NULL, &pTransformFilter->ppPins[0]); if (SUCCEEDED(hr)) { diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index 416422c76c3..1decbfe08ef 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -521,7 +521,7 @@ HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv) piInput.pFilter = (IBaseFilter *)pVideoRenderer; lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0])); - hr = InputPin_Construct(&VideoRenderer_InputPin_Vtbl, &piInput, VideoRenderer_Sample, (LPVOID)pVideoRenderer, VideoRenderer_QueryAccept, NULL, &pVideoRenderer->csFilter, (IPin **)&pVideoRenderer->pInputPin); + hr = InputPin_Construct(&VideoRenderer_InputPin_Vtbl, &piInput, VideoRenderer_Sample, (LPVOID)pVideoRenderer, VideoRenderer_QueryAccept, NULL, &pVideoRenderer->csFilter, NULL, (IPin **)&pVideoRenderer->pInputPin); if (SUCCEEDED(hr)) {