quartz: COM cleanup for PullPin.

This commit is contained in:
Aric Stewart 2012-04-04 08:27:25 -05:00 committed by Alexandre Julliard
parent b751d9ad9c
commit 018161e760
6 changed files with 37 additions and 31 deletions

View File

@ -559,7 +559,7 @@ static HRESULT AVISplitter_ProcessIndex(AVISplitterImpl *This, AVISTDINDEX **ind
if (!pIndex) if (!pIndex)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
IAsyncReader_SyncRead(((PullPin *)This->Parser.ppPins[0])->pReader, qwOffset, cb, (BYTE *)pIndex); IAsyncReader_SyncRead((impl_PullPin_from_IPin(This->Parser.ppPins[0]))->pReader, qwOffset, cb, (BYTE *)pIndex);
rest = cb - sizeof(AVISUPERINDEX) + sizeof(RIFFCHUNK) + sizeof(pIndex->aIndex); rest = cb - sizeof(AVISUPERINDEX) + sizeof(RIFFCHUNK) + sizeof(pIndex->aIndex);
TRACE("FOURCC: %s\n", debugstr_an((char *)&pIndex->fcc, 4)); TRACE("FOURCC: %s\n", debugstr_an((char *)&pIndex->fcc, 4));
@ -1019,7 +1019,7 @@ static HRESULT AVISplitter_Disconnect(LPVOID iface);
/* FIXME: fix leaks on failure here */ /* FIXME: fix leaks on failure here */
static HRESULT AVISplitter_InputPin_PreConnect(IPin * iface, IPin * pConnectPin, ALLOCATOR_PROPERTIES *props) static HRESULT AVISplitter_InputPin_PreConnect(IPin * iface, IPin * pConnectPin, ALLOCATOR_PROPERTIES *props)
{ {
PullPin *This = (PullPin *)iface; PullPin *This = impl_PullPin_from_IPin(iface);
HRESULT hr; HRESULT hr;
RIFFLIST list; RIFFLIST list;
LONGLONG pos = 0; /* in bytes */ LONGLONG pos = 0; /* in bytes */
@ -1301,7 +1301,7 @@ static HRESULT WINAPI AVISplitter_seek(IMediaSeeking *iface)
EnterCriticalSection(&pPin->thread_lock); EnterCriticalSection(&pPin->thread_lock);
/* Send a flush to all output pins */ /* Send a flush to all output pins */
IPin_BeginFlush((IPin *)pPin); IPin_BeginFlush(&pPin->pin.IPin_iface);
/* Make sure this is done while stopped, BeginFlush takes care of this */ /* Make sure this is done while stopped, BeginFlush takes care of this */
EnterCriticalSection(&This->Parser.filter.csFilter); EnterCriticalSection(&This->Parser.filter.csFilter);
@ -1401,7 +1401,7 @@ static HRESULT WINAPI AVISplitter_seek(IMediaSeeking *iface)
LeaveCriticalSection(&This->Parser.filter.csFilter); LeaveCriticalSection(&This->Parser.filter.csFilter);
TRACE("Done flushing\n"); TRACE("Done flushing\n");
IPin_EndFlush((IPin *)pPin); IPin_EndFlush(&pPin->pin.IPin_iface);
LeaveCriticalSection(&pPin->thread_lock); LeaveCriticalSection(&pPin->thread_lock);
return S_OK; return S_OK;

View File

@ -483,7 +483,7 @@ static HRESULT MPEGSplitter_init_audio(MPEGSplitterImpl *This, const BYTE *heade
static HRESULT MPEGSplitter_pre_connect(IPin *iface, IPin *pConnectPin, ALLOCATOR_PROPERTIES *props) static HRESULT MPEGSplitter_pre_connect(IPin *iface, IPin *pConnectPin, ALLOCATOR_PROPERTIES *props)
{ {
PullPin *pPin = (PullPin *)iface; PullPin *pPin = impl_PullPin_from_IPin(iface);
MPEGSplitterImpl *This = (MPEGSplitterImpl*)pPin->pin.pinInfo.pFilter; MPEGSplitterImpl *This = (MPEGSplitterImpl*)pPin->pin.pinInfo.pFilter;
HRESULT hr; HRESULT hr;
LONGLONG pos = 0; /* in bytes */ LONGLONG pos = 0; /* in bytes */
@ -705,7 +705,7 @@ static HRESULT WINAPI MPEGSplitter_seek(IMediaSeeking *iface)
TRACE("Moving sound to %08u bytes!\n", (DWORD)bytepos); TRACE("Moving sound to %08u bytes!\n", (DWORD)bytepos);
EnterCriticalSection(&pin->thread_lock); EnterCriticalSection(&pin->thread_lock);
IPin_BeginFlush((IPin *)pin); IPin_BeginFlush(&pin->pin.IPin_iface);
/* Make sure this is done while stopped, BeginFlush takes care of this */ /* Make sure this is done while stopped, BeginFlush takes care of this */
EnterCriticalSection(&This->Parser.filter.csFilter); EnterCriticalSection(&This->Parser.filter.csFilter);
@ -718,7 +718,7 @@ static HRESULT WINAPI MPEGSplitter_seek(IMediaSeeking *iface)
LeaveCriticalSection(&This->Parser.filter.csFilter); LeaveCriticalSection(&This->Parser.filter.csFilter);
TRACE("Done flushing\n"); TRACE("Done flushing\n");
IPin_EndFlush((IPin *)pin); IPin_EndFlush(&pin->pin.IPin_iface);
LeaveCriticalSection(&pin->thread_lock); LeaveCriticalSection(&pin->thread_lock);
} }
return hr; return hr;

View File

@ -113,7 +113,7 @@ HRESULT Parser_Create(ParserImpl* pParser, const IBaseFilterVtbl *Parser_Vtbl, c
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
pParser->ppPins[0] = (IPin *)pParser->pInputPin; pParser->ppPins[0] = &pParser->pInputPin->pin.IPin_iface;
pParser->pInputPin->fnPreConnect = fnPreConnect; pParser->pInputPin->fnPreConnect = fnPreConnect;
} }
else else
@ -165,14 +165,14 @@ void Parser_Destroy(ParserImpl *This)
PullPin_WaitForStateChange(This->pInputPin, INFINITE); PullPin_WaitForStateChange(This->pInputPin, INFINITE);
/* Don't need to clean up output pins, freeing input pin will do that */ /* Don't need to clean up output pins, freeing input pin will do that */
IPin_ConnectedTo((IPin *)This->pInputPin, &connected); IPin_ConnectedTo(&This->pInputPin->pin.IPin_iface, &connected);
if (connected) if (connected)
{ {
assert(IPin_Disconnect(connected) == S_OK); assert(IPin_Disconnect(connected) == S_OK);
IPin_Release(connected); IPin_Release(connected);
assert(IPin_Disconnect((IPin *)This->pInputPin) == S_OK); assert(IPin_Disconnect(&This->pInputPin->pin.IPin_iface) == S_OK);
} }
pinref = IPin_Release((IPin *)This->pInputPin); pinref = IPin_Release(&This->pInputPin->pin.IPin_iface);
if (pinref) if (pinref)
{ {
/* Valgrind could find this, if I kill it here */ /* Valgrind could find this, if I kill it here */
@ -180,7 +180,7 @@ void Parser_Destroy(ParserImpl *This)
assert((LONG)pinref > 0); assert((LONG)pinref > 0);
while (pinref) while (pinref)
pinref = IPin_Release((IPin *)This->pInputPin); pinref = IPin_Release(&This->pInputPin->pin.IPin_iface);
} }
CoTaskMemFree(This->ppPins); CoTaskMemFree(This->ppPins);
@ -220,7 +220,7 @@ HRESULT WINAPI Parser_GetClassID(IBaseFilter * iface, CLSID * pClsid)
HRESULT WINAPI Parser_Stop(IBaseFilter * iface) HRESULT WINAPI Parser_Stop(IBaseFilter * iface)
{ {
ParserImpl *This = (ParserImpl *)iface; ParserImpl *This = (ParserImpl *)iface;
PullPin *pin = (PullPin *)This->ppPins[0]; PullPin *pin = impl_PullPin_from_IPin(This->ppPins[0]);
ULONG i; ULONG i;
TRACE("()\n"); TRACE("()\n");
@ -259,7 +259,7 @@ HRESULT WINAPI Parser_Pause(IBaseFilter * iface)
{ {
HRESULT hr = S_OK; HRESULT hr = S_OK;
ParserImpl *This = (ParserImpl *)iface; ParserImpl *This = (ParserImpl *)iface;
PullPin *pin = (PullPin *)This->ppPins[0]; PullPin *pin = impl_PullPin_from_IPin(This->ppPins[0]);
TRACE("()\n"); TRACE("()\n");
@ -293,7 +293,7 @@ HRESULT WINAPI Parser_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
{ {
HRESULT hr = S_OK; HRESULT hr = S_OK;
ParserImpl *This = (ParserImpl *)iface; ParserImpl *This = (ParserImpl *)iface;
PullPin *pin = (PullPin *)This->ppPins[0]; PullPin *pin = impl_PullPin_from_IPin(This->ppPins[0]);
ULONG i; ULONG i;
@ -340,7 +340,7 @@ HRESULT WINAPI Parser_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
HRESULT WINAPI Parser_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState) HRESULT WINAPI Parser_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
{ {
ParserImpl *This = (ParserImpl *)iface; ParserImpl *This = (ParserImpl *)iface;
PullPin *pin = (PullPin *)This->ppPins[0]; PullPin *pin = impl_PullPin_from_IPin(This->ppPins[0]);
HRESULT hr = S_OK; HRESULT hr = S_OK;
TRACE("(%d, %p)\n", dwMilliSecsTimeout, pState); TRACE("(%d, %p)\n", dwMilliSecsTimeout, pState);
@ -362,7 +362,7 @@ HRESULT WINAPI Parser_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FI
HRESULT WINAPI Parser_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock) HRESULT WINAPI Parser_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
{ {
ParserImpl *This = (ParserImpl *)iface; ParserImpl *This = (ParserImpl *)iface;
PullPin *pin = (PullPin *)This->ppPins[0]; PullPin *pin = impl_PullPin_from_IPin(This->ppPins[0]);
TRACE("(%p)\n", pClock); TRACE("(%p)\n", pClock);
@ -704,7 +704,7 @@ static const IPinVtbl Parser_OutputPin_Vtbl =
static HRESULT WINAPI Parser_PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv) static HRESULT WINAPI Parser_PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
{ {
PullPin *This = (PullPin *)iface; PullPin *This = impl_PullPin_from_IPin(iface);
TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv); TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
@ -730,7 +730,7 @@ static HRESULT WINAPI Parser_PullPin_QueryInterface(IPin * iface, REFIID riid, L
static HRESULT WINAPI Parser_PullPin_Disconnect(IPin * iface) static HRESULT WINAPI Parser_PullPin_Disconnect(IPin * iface)
{ {
HRESULT hr; HRESULT hr;
PullPin *This = (PullPin *)iface; PullPin *This = impl_PullPin_from_IPin(iface);
TRACE("()\n"); TRACE("()\n");

View File

@ -254,7 +254,7 @@ HRESULT WINAPI PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const
{ {
PIN_DIRECTION pindirReceive; PIN_DIRECTION pindirReceive;
HRESULT hr = S_OK; HRESULT hr = S_OK;
PullPin *This = (PullPin *)iface; PullPin *This = impl_PullPin_from_IPin(iface);
TRACE("(%p/%p)->(%p, %p)\n", This, iface, pReceivePin, pmt); TRACE("(%p/%p)->(%p, %p)\n", This, iface, pReceivePin, pmt);
dump_AM_MEDIA_TYPE(pmt); dump_AM_MEDIA_TYPE(pmt);
@ -344,7 +344,7 @@ HRESULT WINAPI PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const
HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv) HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
{ {
PullPin *This = (PullPin *)iface; PullPin *This = impl_PullPin_from_IPin(iface);
TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv); TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
@ -373,7 +373,7 @@ HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
ULONG WINAPI PullPin_Release(IPin *iface) ULONG WINAPI PullPin_Release(IPin *iface)
{ {
PullPin *This = (PullPin *)iface; PullPin *This = impl_PullPin_from_IPin(iface);
ULONG refCount = InterlockedDecrement(&This->pin.refCount); ULONG refCount = InterlockedDecrement(&This->pin.refCount);
TRACE("(%p)->() Release from %d\n", This, refCount + 1); TRACE("(%p)->() Release from %d\n", This, refCount + 1);
@ -449,7 +449,7 @@ static void PullPin_Thread_Process(PullPin *This)
if (This->rtCurrent >= This->rtStop) if (This->rtCurrent >= This->rtStop)
{ {
IPin_EndOfStream((IPin *)This); IPin_EndOfStream(&This->pin.IPin_iface);
return; return;
} }
@ -717,7 +717,7 @@ HRESULT PullPin_WaitForStateChange(PullPin * This, DWORD dwMilliseconds)
HRESULT WINAPI PullPin_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt) HRESULT WINAPI PullPin_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt)
{ {
PullPin *This = (PullPin *)iface; PullPin *This = impl_PullPin_from_IPin(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pmt); TRACE("(%p/%p)->(%p)\n", This, iface, pmt);
@ -726,7 +726,7 @@ HRESULT WINAPI PullPin_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt)
HRESULT WINAPI PullPin_EndOfStream(IPin * iface) HRESULT WINAPI PullPin_EndOfStream(IPin * iface)
{ {
PullPin *This = (PullPin *)iface; PullPin *This = impl_PullPin_from_IPin(iface);
HRESULT hr = S_FALSE; HRESULT hr = S_FALSE;
TRACE("(%p)->()\n", iface); TRACE("(%p)->()\n", iface);
@ -741,7 +741,7 @@ HRESULT WINAPI PullPin_EndOfStream(IPin * iface)
HRESULT WINAPI PullPin_BeginFlush(IPin * iface) HRESULT WINAPI PullPin_BeginFlush(IPin * iface)
{ {
PullPin *This = (PullPin *)iface; PullPin *This = impl_PullPin_from_IPin(iface);
TRACE("(%p)->()\n", This); TRACE("(%p)->()\n", This);
EnterCriticalSection(This->pin.pCritSec); EnterCriticalSection(This->pin.pCritSec);
@ -775,7 +775,7 @@ HRESULT WINAPI PullPin_BeginFlush(IPin * iface)
HRESULT WINAPI PullPin_EndFlush(IPin * iface) HRESULT WINAPI PullPin_EndFlush(IPin * iface)
{ {
PullPin *This = (PullPin *)iface; PullPin *This = impl_PullPin_from_IPin(iface);
TRACE("(%p)->()\n", iface); TRACE("(%p)->()\n", iface);
@ -806,7 +806,7 @@ HRESULT WINAPI PullPin_EndFlush(IPin * iface)
HRESULT WINAPI PullPin_Disconnect(IPin *iface) HRESULT WINAPI PullPin_Disconnect(IPin *iface)
{ {
HRESULT hr; HRESULT hr;
PullPin *This = (PullPin *)iface; PullPin *This = impl_PullPin_from_IPin(iface);
TRACE("()\n"); TRACE("()\n");

View File

@ -122,3 +122,9 @@ HRESULT WINAPI PullPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE
HRESULT PullPin_StartProcessing(PullPin * This); HRESULT PullPin_StartProcessing(PullPin * This);
HRESULT PullPin_PauseProcessing(PullPin * This); HRESULT PullPin_PauseProcessing(PullPin * This);
HRESULT PullPin_WaitForStateChange(PullPin * This, DWORD dwMilliseconds); HRESULT PullPin_WaitForStateChange(PullPin * This, DWORD dwMilliseconds);
/* COM helpers */
static inline PullPin *impl_PullPin_from_IPin( IPin *iface )
{
return CONTAINING_RECORD(iface, PullPin, pin.IPin_iface);
}

View File

@ -215,7 +215,7 @@ static HRESULT WINAPI WAVEParserImpl_seek(IMediaSeeking *iface)
TRACE("Moving sound to %08u bytes!\n", (DWORD)BYTES_FROM_MEDIATIME(bytepos)); TRACE("Moving sound to %08u bytes!\n", (DWORD)BYTES_FROM_MEDIATIME(bytepos));
EnterCriticalSection(&pPin->thread_lock); EnterCriticalSection(&pPin->thread_lock);
IPin_BeginFlush((IPin *)pPin); IPin_BeginFlush(&pPin->pin.IPin_iface);
/* Make sure this is done while stopped, BeginFlush takes care of this */ /* Make sure this is done while stopped, BeginFlush takes care of this */
EnterCriticalSection(&This->Parser.filter.csFilter); EnterCriticalSection(&This->Parser.filter.csFilter);
@ -231,7 +231,7 @@ static HRESULT WINAPI WAVEParserImpl_seek(IMediaSeeking *iface)
LeaveCriticalSection(&This->Parser.filter.csFilter); LeaveCriticalSection(&This->Parser.filter.csFilter);
TRACE("Done flushing\n"); TRACE("Done flushing\n");
IPin_EndFlush((IPin *)pPin); IPin_EndFlush(&pPin->pin.IPin_iface);
LeaveCriticalSection(&pPin->thread_lock); LeaveCriticalSection(&pPin->thread_lock);
return S_OK; return S_OK;
@ -239,7 +239,7 @@ static HRESULT WINAPI WAVEParserImpl_seek(IMediaSeeking *iface)
static HRESULT WAVEParser_InputPin_PreConnect(IPin * iface, IPin * pConnectPin, ALLOCATOR_PROPERTIES *props) static HRESULT WAVEParser_InputPin_PreConnect(IPin * iface, IPin * pConnectPin, ALLOCATOR_PROPERTIES *props)
{ {
PullPin *This = (PullPin *)iface; PullPin *This = impl_PullPin_from_IPin(iface);
HRESULT hr; HRESULT hr;
RIFFLIST list; RIFFLIST list;
RIFFCHUNK chunk; RIFFCHUNK chunk;