Commit b32b1a92 authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

strmbase: In the TransformFilter add a critical section that protects the streaming state.

parent 9aa3c745
...@@ -68,25 +68,25 @@ static HRESULT WINAPI TransformFilter_Input_Receive(BaseInputPin *This, IMediaSa ...@@ -68,25 +68,25 @@ static HRESULT WINAPI TransformFilter_Input_Receive(BaseInputPin *This, IMediaSa
TRACE("%p\n", This); TRACE("%p\n", This);
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter; pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
EnterCriticalSection(&pTransform->filter.csFilter); EnterCriticalSection(&pTransform->csReceive);
if (pTransform->filter.state == State_Stopped) if (pTransform->filter.state == State_Stopped)
{ {
LeaveCriticalSection(&pTransform->filter.csFilter); LeaveCriticalSection(&pTransform->csReceive);
return VFW_E_WRONG_STATE; return VFW_E_WRONG_STATE;
} }
if (This->end_of_stream || This->flushing) if (This->end_of_stream || This->flushing)
{ {
LeaveCriticalSection(&pTransform->filter.csFilter); LeaveCriticalSection(&pTransform->csReceive);
return S_FALSE; return S_FALSE;
} }
LeaveCriticalSection(&pTransform->filter.csFilter);
if (pTransform->pFuncsTable->pfnReceive) if (pTransform->pFuncsTable->pfnReceive)
hr = pTransform->pFuncsTable->pfnReceive(pTransform, pInSample); hr = pTransform->pFuncsTable->pfnReceive(pTransform, pInSample);
else else
hr = S_FALSE; hr = S_FALSE;
LeaveCriticalSection(&pTransform->csReceive);
return hr; return hr;
} }
...@@ -176,6 +176,9 @@ static HRESULT TransformFilter_Init(const IBaseFilterVtbl *pVtbl, const CLSID* p ...@@ -176,6 +176,9 @@ static HRESULT TransformFilter_Init(const IBaseFilterVtbl *pVtbl, const CLSID* p
BaseFilter_Init(&pTransformFilter->filter, pVtbl, pClsid, (DWORD_PTR)(__FILE__ ": TransformFilter.csFilter"), &tfBaseFuncTable); BaseFilter_Init(&pTransformFilter->filter, pVtbl, pClsid, (DWORD_PTR)(__FILE__ ": TransformFilter.csFilter"), &tfBaseFuncTable);
InitializeCriticalSection(&pTransformFilter->csReceive);
pTransformFilter->csReceive.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__": TransformFilter.csReceive");
/* pTransformFilter is already allocated */ /* pTransformFilter is already allocated */
pTransformFilter->pFuncsTable = pFuncsTable; pTransformFilter->pFuncsTable = pFuncsTable;
ZeroMemory(&pTransformFilter->pmt, sizeof(pTransformFilter->pmt)); ZeroMemory(&pTransformFilter->pmt, sizeof(pTransformFilter->pmt));
...@@ -286,6 +289,8 @@ ULONG WINAPI TransformFilterImpl_Release(IBaseFilter * iface) ...@@ -286,6 +289,8 @@ ULONG WINAPI TransformFilterImpl_Release(IBaseFilter * iface)
CoTaskMemFree(This->ppPins); CoTaskMemFree(This->ppPins);
TRACE("Destroying transform filter\n"); TRACE("Destroying transform filter\n");
This->csReceive.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->csReceive);
FreeMediaType(&This->pmt); FreeMediaType(&This->pmt);
CoTaskMemFree(This); CoTaskMemFree(This);
...@@ -304,13 +309,13 @@ HRESULT WINAPI TransformFilterImpl_Stop(IBaseFilter * iface) ...@@ -304,13 +309,13 @@ HRESULT WINAPI TransformFilterImpl_Stop(IBaseFilter * iface)
TRACE("(%p/%p)\n", This, iface); TRACE("(%p/%p)\n", This, iface);
EnterCriticalSection(&This->filter.csFilter); EnterCriticalSection(&This->csReceive);
{ {
This->filter.state = State_Stopped; This->filter.state = State_Stopped;
if (This->pFuncsTable->pfnStopStreaming) if (This->pFuncsTable->pfnStopStreaming)
hr = This->pFuncsTable->pfnStopStreaming(This); hr = This->pFuncsTable->pfnStopStreaming(This);
} }
LeaveCriticalSection(&This->filter.csFilter); LeaveCriticalSection(&This->csReceive);
return hr; return hr;
} }
...@@ -322,7 +327,7 @@ HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter * iface) ...@@ -322,7 +327,7 @@ HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter * iface)
TRACE("(%p/%p)->()\n", This, iface); TRACE("(%p/%p)->()\n", This, iface);
EnterCriticalSection(&This->filter.csFilter); EnterCriticalSection(&This->csReceive);
{ {
if (This->filter.state == State_Stopped) if (This->filter.state == State_Stopped)
hr = IBaseFilter_Run(iface, -1); hr = IBaseFilter_Run(iface, -1);
...@@ -332,7 +337,7 @@ HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter * iface) ...@@ -332,7 +337,7 @@ HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter * iface)
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
This->filter.state = State_Paused; This->filter.state = State_Paused;
} }
LeaveCriticalSection(&This->filter.csFilter); LeaveCriticalSection(&This->csReceive);
return hr; return hr;
} }
...@@ -344,7 +349,7 @@ HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStar ...@@ -344,7 +349,7 @@ HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStar
TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart)); TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
EnterCriticalSection(&This->filter.csFilter); EnterCriticalSection(&This->csReceive);
{ {
if (This->filter.state == State_Stopped) if (This->filter.state == State_Stopped)
{ {
...@@ -361,7 +366,7 @@ HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStar ...@@ -361,7 +366,7 @@ HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStar
This->filter.state = State_Running; This->filter.state = State_Running;
} }
} }
LeaveCriticalSection(&This->filter.csFilter); LeaveCriticalSection(&This->csReceive);
return hr; return hr;
} }
......
...@@ -232,6 +232,7 @@ typedef struct TransformFilter ...@@ -232,6 +232,7 @@ typedef struct TransformFilter
IPin **ppPins; IPin **ppPins;
ULONG npins; ULONG npins;
AM_MEDIA_TYPE pmt; AM_MEDIA_TYPE pmt;
CRITICAL_SECTION csReceive;
const struct TransformFilterFuncTable * pFuncsTable; const struct TransformFilterFuncTable * pFuncsTable;
QualityControlImpl qcimpl; QualityControlImpl qcimpl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment