quartz: Hold a reference on a filter while sending data to it.

This commit is contained in:
Chris Robinson 2007-03-14 06:39:58 -07:00 committed by Alexandre Julliard
parent 4b4518532a
commit 52529c923d
1 changed files with 16 additions and 4 deletions

View File

@ -880,6 +880,7 @@ HRESULT OutputPin_SendSample(OutputPin * This, IMediaSample * pSample)
{ {
HRESULT hr = S_OK; HRESULT hr = S_OK;
IMemInputPin * pMemConnected = NULL; IMemInputPin * pMemConnected = NULL;
PIN_INFO pinInfo;
EnterCriticalSection(This->pin.pCritSec); EnterCriticalSection(This->pin.pCritSec);
{ {
@ -889,9 +890,10 @@ HRESULT OutputPin_SendSample(OutputPin * This, IMediaSample * pSample)
{ {
/* we don't have the lock held when using This->pMemInputPin, /* we don't have the lock held when using This->pMemInputPin,
* so we need to AddRef it to stop it being deleted while we are * so we need to AddRef it to stop it being deleted while we are
* using it. */ * using it. Same with its filter. */
pMemConnected = This->pMemInputPin; pMemConnected = This->pMemInputPin;
IMemInputPin_AddRef(pMemConnected); IMemInputPin_AddRef(pMemConnected);
hr = IPin_QueryPinInfo(This->pin.pConnectedTo, &pinInfo);
} }
} }
LeaveCriticalSection(This->pin.pCritSec); LeaveCriticalSection(This->pin.pCritSec);
@ -902,9 +904,11 @@ HRESULT OutputPin_SendSample(OutputPin * This, IMediaSample * pSample)
* then it causes some problems (most notably with the native Video * then it causes some problems (most notably with the native Video
* Renderer) if we are re-entered for whatever reason */ * Renderer) if we are re-entered for whatever reason */
hr = IMemInputPin_Receive(pMemConnected, pSample); hr = IMemInputPin_Receive(pMemConnected, pSample);
IMemInputPin_Release(pMemConnected); IBaseFilter_Release(pinInfo.pFilter);
} }
if (pMemConnected)
IMemInputPin_Release(pMemConnected);
return hr; return hr;
} }
@ -1155,6 +1159,7 @@ static void CALLBACK PullPin_Thread_Process(ULONG_PTR iface)
REFERENCE_TIME rtCurrent; REFERENCE_TIME rtCurrent;
ALLOCATOR_PROPERTIES allocProps; ALLOCATOR_PROPERTIES allocProps;
PIN_INFO pinInfo;
CoInitializeEx(NULL, COINIT_MULTITHREADED); CoInitializeEx(NULL, COINIT_MULTITHREADED);
@ -1175,6 +1180,8 @@ static void CALLBACK PullPin_Thread_Process(ULONG_PTR iface)
REFERENCE_TIME rtSampleStop; REFERENCE_TIME rtSampleStop;
DWORD_PTR dwUser; DWORD_PTR dwUser;
pinInfo.pFilter = NULL;
TRACE("Process sample\n"); TRACE("Process sample\n");
hr = IMemAllocator_GetBuffer(This->pAlloc, &pSample, NULL, NULL, 0); hr = IMemAllocator_GetBuffer(This->pAlloc, &pSample, NULL, NULL, 0);
@ -1194,11 +1201,16 @@ static void CALLBACK PullPin_Thread_Process(ULONG_PTR iface)
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = IAsyncReader_WaitForNext(This->pReader, 10000, &pSample, &dwUser); hr = IAsyncReader_WaitForNext(This->pReader, 10000, &pSample, &dwUser);
if (SUCCEEDED(hr))
hr = IPin_QueryPinInfo((IPin*)&This->pin, &pinInfo);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = This->fnSampleProc(This->pin.pUserData, pSample); hr = This->fnSampleProc(This->pin.pUserData, pSample);
else else
ERR("Processing error: %x\n", hr); ERR("Processing error: %x\n", hr);
if (pinInfo.pFilter)
IBaseFilter_Release(pinInfo.pFilter);
if (pSample) if (pSample)
IMediaSample_Release(pSample); IMediaSample_Release(pSample);
} }