Module: wine Branch: master Commit: cf1d2f5e42fe418b0a66984bb9b0bf9134c23f20 URL: http://source.winehq.org/git/wine.git/?a=commit;h=cf1d2f5e42fe418b0a66984bb9...
Author: Maarten Lankhorst m.b.lankhorst@gmail.com Date: Fri Jul 11 10:51:25 2008 -0700
quartz: Fix memory and sample leaks.
---
dlls/quartz/parser.c | 1 - dlls/quartz/pin.c | 29 +++++++++++------------------ dlls/quartz/pin.h | 1 - 3 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/dlls/quartz/parser.c b/dlls/quartz/parser.c index 6883e47..91d1ce9 100644 --- a/dlls/quartz/parser.c +++ b/dlls/quartz/parser.c @@ -246,7 +246,6 @@ HRESULT WINAPI Parser_Stop(IBaseFilter * iface)
PullPin_PauseProcessing(This->pInputPin); PullPin_WaitForStateChange(This->pInputPin, INFINITE); - IAsyncReader_EndFlush(This->pInputPin->pReader);
LeaveCriticalSection(&pin->thread_lock); return S_OK; diff --git a/dlls/quartz/pin.c b/dlls/quartz/pin.c index 0abeb13..5daaf7e 100644 --- a/dlls/quartz/pin.c +++ b/dlls/quartz/pin.c @@ -387,6 +387,8 @@ HRESULT WINAPI IPinImpl_Disconnect(IPin * iface) { IPin_Release(This->pConnectedTo); This->pConnectedTo = NULL; + FreeMediaType(&This->mtCurrent); + ZeroMemory(&This->mtCurrent, sizeof(This->mtCurrent)); hr = S_OK; } else @@ -944,7 +946,7 @@ HRESULT WINAPI OutputPin_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDI (This->pConnectSpecific(iface, pReceivePin, pmtCandidate) == S_OK)) { hr = S_OK; - CoTaskMemFree(pmtCandidate); + DeleteMediaType(pmtCandidate); break; } DeleteMediaType(pmtCandidate); @@ -967,7 +969,7 @@ HRESULT WINAPI OutputPin_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDI (This->pConnectSpecific(iface, pReceivePin, pmtCandidate) == S_OK)) { hr = S_OK; - CoTaskMemFree(pmtCandidate); + DeleteMediaType(pmtCandidate); break; } DeleteMediaType(pmtCandidate); @@ -1008,6 +1010,8 @@ HRESULT WINAPI OutputPin_Disconnect(IPin * iface) { IPin_Release(This->pin.pConnectedTo); This->pin.pConnectedTo = NULL; + FreeMediaType(&This->pin.mtCurrent); + ZeroMemory(&This->pin.mtCurrent, sizeof(This->pin.mtCurrent)); hr = S_OK; } else @@ -1559,6 +1563,8 @@ static void CALLBACK PullPin_Thread_Process(PullPin *This)
static void CALLBACK PullPin_Thread_Pause(PullPin *This) { + PullPin_Flush(This); + EnterCriticalSection(This->pin.pCritSec); This->state = Req_Sleepy; SetEvent(This->hEventStateChanged); @@ -1583,16 +1589,6 @@ static void CALLBACK PullPin_Thread_Stop(PullPin *This) ExitThread(0); }
-static void CALLBACK PullPin_Thread_Flush(PullPin *This) -{ - PullPin_Flush(This); - - EnterCriticalSection(This->pin.pCritSec); - This->state = Req_Sleepy; - SetEvent(This->hEventStateChanged); - LeaveCriticalSection(This->pin.pCritSec); -} - static DWORD WINAPI PullPin_Thread_Main(LPVOID pv) { PullPin *This = pv; @@ -1611,7 +1607,6 @@ static DWORD WINAPI PullPin_Thread_Main(LPVOID pv) case Req_Die: PullPin_Thread_Stop(This); break; case Req_Run: PullPin_Thread_Process(This); break; case Req_Pause: PullPin_Thread_Pause(This); break; - case Req_Flush: PullPin_Thread_Flush(This); break; case Req_Sleepy: ERR("Should not be signalled with SLEEPY!\n"); break; default: ERR("Unknown state request: %d\n", This->state); break; } @@ -1768,11 +1763,6 @@ HRESULT WINAPI PullPin_BeginFlush(IPin * iface) PullPin_PauseProcessing(This); PullPin_WaitForStateChange(This, INFINITE); } - - This->state = Req_Flush; - ResetEvent(This->hEventStateChanged); - SetEvent(This->thread_sleepy); - PullPin_WaitForStateChange(This, INFINITE); } LeaveCriticalSection(&This->thread_lock);
@@ -1828,6 +1818,9 @@ HRESULT WINAPI PullPin_Disconnect(IPin *iface) IPin_Release(This->pin.pConnectedTo); This->pin.pConnectedTo = NULL; PullPin_StopProcessing(This); + + FreeMediaType(&This->pin.mtCurrent); + ZeroMemory(&This->pin.mtCurrent, sizeof(This->pin.mtCurrent)); hr = S_OK; } else diff --git a/dlls/quartz/pin.h b/dlls/quartz/pin.h index 4170ca5..3a9719c 100644 --- a/dlls/quartz/pin.h +++ b/dlls/quartz/pin.h @@ -140,7 +140,6 @@ typedef struct PullPin #define Req_Die 1 #define Req_Run 2 #define Req_Pause 3 -#define Req_Flush 4
/*** Constructors ***/ 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);