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

Alexandre Julliard julliard at winehq.org
Tue Jan 17 13:45:24 CST 2012


Module: wine
Branch: master
Commit: b32b1a924eb00b568ebb758fcf5afa12f80d984a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b32b1a924eb00b568ebb758fcf5afa12f80d984a

Author: Aric Stewart <aric at codeweavers.com>
Date:   Mon Jan 16 14:14:23 2012 -0600

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

---

 dlls/strmbase/transform.c |   25 +++++++++++++++----------
 include/wine/strmbase.h   |    1 +
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/dlls/strmbase/transform.c b/dlls/strmbase/transform.c
index ccdef39..b44becf 100644
--- a/dlls/strmbase/transform.c
+++ b/dlls/strmbase/transform.c
@@ -68,25 +68,25 @@ static HRESULT WINAPI TransformFilter_Input_Receive(BaseInputPin *This, IMediaSa
     TRACE("%p\n", This);
     pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
 
-    EnterCriticalSection(&pTransform->filter.csFilter);
+    EnterCriticalSection(&pTransform->csReceive);
     if (pTransform->filter.state == State_Stopped)
     {
-        LeaveCriticalSection(&pTransform->filter.csFilter);
+        LeaveCriticalSection(&pTransform->csReceive);
         return VFW_E_WRONG_STATE;
     }
 
     if (This->end_of_stream || This->flushing)
     {
-        LeaveCriticalSection(&pTransform->filter.csFilter);
+        LeaveCriticalSection(&pTransform->csReceive);
         return S_FALSE;
     }
-    LeaveCriticalSection(&pTransform->filter.csFilter);
 
     if (pTransform->pFuncsTable->pfnReceive)
         hr = pTransform->pFuncsTable->pfnReceive(pTransform, pInSample);
     else
         hr = S_FALSE;
 
+    LeaveCriticalSection(&pTransform->csReceive);
     return hr;
 }
 
@@ -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);
 
+    InitializeCriticalSection(&pTransformFilter->csReceive);
+    pTransformFilter->csReceive.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__": TransformFilter.csReceive");
+
     /* pTransformFilter is already allocated */
     pTransformFilter->pFuncsTable = pFuncsTable;
     ZeroMemory(&pTransformFilter->pmt, sizeof(pTransformFilter->pmt));
@@ -286,6 +289,8 @@ ULONG WINAPI TransformFilterImpl_Release(IBaseFilter * iface)
         CoTaskMemFree(This->ppPins);
 
         TRACE("Destroying transform filter\n");
+        This->csReceive.DebugInfo->Spare[0] = 0;
+        DeleteCriticalSection(&This->csReceive);
         FreeMediaType(&This->pmt);
         CoTaskMemFree(This);
 
@@ -304,13 +309,13 @@ HRESULT WINAPI TransformFilterImpl_Stop(IBaseFilter * iface)
 
     TRACE("(%p/%p)\n", This, iface);
 
-    EnterCriticalSection(&This->filter.csFilter);
+    EnterCriticalSection(&This->csReceive);
     {
         This->filter.state = State_Stopped;
         if (This->pFuncsTable->pfnStopStreaming)
             hr = This->pFuncsTable->pfnStopStreaming(This);
     }
-    LeaveCriticalSection(&This->filter.csFilter);
+    LeaveCriticalSection(&This->csReceive);
 
     return hr;
 }
@@ -322,7 +327,7 @@ HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter * iface)
 
     TRACE("(%p/%p)->()\n", This, iface);
 
-    EnterCriticalSection(&This->filter.csFilter);
+    EnterCriticalSection(&This->csReceive);
     {
         if (This->filter.state == State_Stopped)
             hr = IBaseFilter_Run(iface, -1);
@@ -332,7 +337,7 @@ HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter * iface)
         if (SUCCEEDED(hr))
             This->filter.state = State_Paused;
     }
-    LeaveCriticalSection(&This->filter.csFilter);
+    LeaveCriticalSection(&This->csReceive);
 
     return hr;
 }
@@ -344,7 +349,7 @@ HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStar
 
     TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
 
-    EnterCriticalSection(&This->filter.csFilter);
+    EnterCriticalSection(&This->csReceive);
     {
         if (This->filter.state == State_Stopped)
         {
@@ -361,7 +366,7 @@ HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStar
             This->filter.state = State_Running;
         }
     }
-    LeaveCriticalSection(&This->filter.csFilter);
+    LeaveCriticalSection(&This->csReceive);
 
     return hr;
 }
diff --git a/include/wine/strmbase.h b/include/wine/strmbase.h
index 3d06bf8..6370530 100644
--- a/include/wine/strmbase.h
+++ b/include/wine/strmbase.h
@@ -232,6 +232,7 @@ typedef struct TransformFilter
 	IPin **ppPins;
 	ULONG npins;
 	AM_MEDIA_TYPE pmt;
+	CRITICAL_SECTION csReceive;
 
 	const struct TransformFilterFuncTable * pFuncsTable;
 	QualityControlImpl qcimpl;




More information about the wine-cvs mailing list