Commit cf1d2f5e authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Alexandre Julliard

quartz: Fix memory and sample leaks.

parent 36418d8a
......@@ -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;
......
......@@ -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
......
......@@ -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);
......
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