From f53fa4f05b7c62ec3cb98f8ff855da93b34f389b Mon Sep 17 00:00:00 2001 From: Alessandro Pignotti Date: Mon, 4 Mar 2013 12:21:19 +0100 Subject: [PATCH] strmbase: Remove code duplicated by every user of ISeekingPassThruImpl. --- dlls/quartz/acmwrapper.c | 26 +------------------------- dlls/quartz/avidec.c | 25 +------------------------ dlls/strmbase/transform.c | 20 ++++++++++++++++++++ dlls/winegstreamer/gsttffilter.c | 25 +------------------------ dlls/wineqtdecoder/qtvdecoder.c | 25 +------------------------ include/wine/strmbase.h | 2 ++ 6 files changed, 26 insertions(+), 97 deletions(-) diff --git a/dlls/quartz/acmwrapper.c b/dlls/quartz/acmwrapper.c index f98362caff5..cd0b0d83ab5 100644 --- a/dlls/quartz/acmwrapper.c +++ b/dlls/quartz/acmwrapper.c @@ -42,7 +42,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(quartz); typedef struct ACMWrapperImpl { TransformFilter tf; - IUnknown *seekthru_unk; HACMSTREAM has; LPWAVEFORMATEX pWfIn; @@ -399,14 +398,6 @@ HRESULT ACMWrapper_create(IUnknown * pUnkOuter, LPVOID * ppv) if (FAILED(hr)) return hr; - else - { - ISeekingPassThru *passthru; - hr = CoCreateInstance(&CLSID_SeekingPassThru, (IUnknown*)This, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&This->seekthru_unk); - IUnknown_QueryInterface(This->seekthru_unk, &IID_ISeekingPassThru, (void**)&passthru); - ISeekingPassThru_Init(passthru, FALSE, This->tf.ppPins[0]); - ISeekingPassThru_Release(passthru); - } *ppv = This; This->lasttime_real = This->lasttime_sent = -1; @@ -414,24 +405,9 @@ HRESULT ACMWrapper_create(IUnknown * pUnkOuter, LPVOID * ppv) return hr; } -static HRESULT WINAPI ACMWrapper_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv) -{ - HRESULT hr; - ACMWrapperImpl *This = impl_from_IBaseFilter(iface); - TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv); - - if (IsEqualIID(riid, &IID_IMediaSeeking)) - return IUnknown_QueryInterface(This->seekthru_unk, riid, ppv); - - hr = TransformFilterImpl_QueryInterface(iface, riid, ppv); - - return hr; -} - - static const IBaseFilterVtbl ACMWrapper_Vtbl = { - ACMWrapper_QueryInterface, + TransformFilterImpl_QueryInterface, BaseFilterImpl_AddRef, TransformFilterImpl_Release, BaseFilterImpl_GetClassID, diff --git a/dlls/quartz/avidec.c b/dlls/quartz/avidec.c index 5537db92a91..30da6fa3340 100644 --- a/dlls/quartz/avidec.c +++ b/dlls/quartz/avidec.c @@ -43,7 +43,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(quartz); typedef struct AVIDecImpl { TransformFilter tf; - IUnknown *seekthru_unk; HIC hvid; BITMAPINFOHEADER* pBihIn; @@ -417,14 +416,6 @@ HRESULT AVIDec_create(IUnknown * pUnkOuter, LPVOID * ppv) if (FAILED(hr)) return hr; - else - { - ISeekingPassThru *passthru; - hr = CoCreateInstance(&CLSID_SeekingPassThru, (IUnknown*)This, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&This->seekthru_unk); - IUnknown_QueryInterface(This->seekthru_unk, &IID_ISeekingPassThru, (void**)&passthru); - ISeekingPassThru_Init(passthru, FALSE, This->tf.ppPins[0]); - ISeekingPassThru_Release(passthru); - } This->hvid = NULL; This->pBihIn = NULL; @@ -435,23 +426,9 @@ HRESULT AVIDec_create(IUnknown * pUnkOuter, LPVOID * ppv) return hr; } -static HRESULT WINAPI AVIDec_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv) -{ - HRESULT hr; - AVIDecImpl *This = impl_from_IBaseFilter(iface); - TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv); - - if (IsEqualIID(riid, &IID_IMediaSeeking)) - return IUnknown_QueryInterface(This->seekthru_unk, riid, ppv); - - hr = TransformFilterImpl_QueryInterface(iface, riid, ppv); - - return hr; -} - static const IBaseFilterVtbl AVIDec_Vtbl = { - AVIDec_QueryInterface, + TransformFilterImpl_QueryInterface, BaseFilterImpl_AddRef, TransformFilterImpl_Release, BaseFilterImpl_GetClassID, diff --git a/dlls/strmbase/transform.c b/dlls/strmbase/transform.c index f97052750f5..0e014b07756 100644 --- a/dlls/strmbase/transform.c +++ b/dlls/strmbase/transform.c @@ -238,6 +238,20 @@ static HRESULT TransformFilter_Init(const IBaseFilterVtbl *pVtbl, const CLSID* p pTransformFilter->qcimpl->IQualityControl_iface.lpVtbl = &TransformFilter_QualityControl_Vtbl; } } + + if (SUCCEEDED(hr)) + { + ISeekingPassThru *passthru; + pTransformFilter->seekthru_unk = NULL; + hr = CoCreateInstance(&CLSID_SeekingPassThru, (IUnknown*)pTransformFilter, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&pTransformFilter->seekthru_unk); + if (SUCCEEDED(hr)) + { + IUnknown_QueryInterface(pTransformFilter->seekthru_unk, &IID_ISeekingPassThru, (void**)&passthru); + ISeekingPassThru_Init(passthru, FALSE, pTransformFilter->ppPins[0]); + ISeekingPassThru_Release(passthru); + } + } + if (FAILED(hr)) { CoTaskMemFree(pTransformFilter->ppPins); @@ -283,6 +297,11 @@ HRESULT WINAPI TransformFilterImpl_QueryInterface(IBaseFilter * iface, REFIID ri IUnknown_AddRef((IUnknown*)*ppv); return S_OK; } + else if (IsEqualIID(riid, &IID_IMediaSeeking) || + IsEqualIID(riid, &IID_IMediaPosition)) + { + return IUnknown_QueryInterface(This->seekthru_unk, riid, ppv); + } hr = BaseFilterImpl_QueryInterface(iface, riid, ppv); if (FAILED(hr) && !IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IVideoWindow) && @@ -325,6 +344,7 @@ ULONG WINAPI TransformFilterImpl_Release(IBaseFilter * iface) FreeMediaType(&This->pmt); QualityControlImpl_Destroy(This->qcimpl); CoTaskMemFree(This); + IUnknown_Release(This->seekthru_unk); return 0; } diff --git a/dlls/winegstreamer/gsttffilter.c b/dlls/winegstreamer/gsttffilter.c index 42220088ac7..575d6e35175 100644 --- a/dlls/winegstreamer/gsttffilter.c +++ b/dlls/winegstreamer/gsttffilter.c @@ -115,7 +115,6 @@ static const char *Gstreamer_FindMatch(const char *strcaps) typedef struct GstTfImpl { TransformFilter tf; - IUnknown *seekthru_unk; const char *gstreamer_name; GstElement *filter; GstPad *my_src, *my_sink, *their_src, *their_sink; @@ -450,14 +449,6 @@ static HRESULT Gstreamer_transform_create(IUnknown *punkout, const CLSID *clsid, if (FAILED(TransformFilter_Construct(&GSTTf_Vtbl, sizeof(GstTfImpl), clsid, vtbl, (IBaseFilter**)&This))) return E_OUTOFMEMORY; - else - { - ISeekingPassThru *passthru; - CoCreateInstance(&CLSID_SeekingPassThru, (IUnknown*)This, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&This->seekthru_unk); - IUnknown_QueryInterface(This->seekthru_unk, &IID_ISeekingPassThru, (void**)&passthru); - ISeekingPassThru_Init(passthru, FALSE, (IPin*)This->tf.ppPins[0]); - ISeekingPassThru_Release(passthru); - } This->gstreamer_name = name; *obj = This; @@ -830,23 +821,9 @@ IUnknown * CALLBACK Gstreamer_AudioConvert_create(IUnknown *punkout, HRESULT *ph return obj; } -static HRESULT WINAPI GSTTf_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv) -{ - HRESULT hr; - GstTfImpl *This = (GstTfImpl*)iface; - TRACE("(%p/%p)->(%s, %p)\n", This, iface, debugstr_guid(riid), ppv); - - if (IsEqualIID(riid, &IID_IMediaSeeking) || IsEqualIID(riid, &IID_IMediaPosition)) - return IUnknown_QueryInterface(This->seekthru_unk, riid, ppv); - - hr = TransformFilterImpl_QueryInterface(iface, riid, ppv); - - return hr; -} - static const IBaseFilterVtbl GSTTf_Vtbl = { - GSTTf_QueryInterface, + TransformFilterImpl_QueryInterface, BaseFilterImpl_AddRef, TransformFilterImpl_Release, BaseFilterImpl_GetClassID, diff --git a/dlls/wineqtdecoder/qtvdecoder.c b/dlls/wineqtdecoder/qtvdecoder.c index 3dfece83747..6e2ceb169a2 100644 --- a/dlls/wineqtdecoder/qtvdecoder.c +++ b/dlls/wineqtdecoder/qtvdecoder.c @@ -136,7 +136,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(qtdecoder); typedef struct QTVDecoderImpl { TransformFilter tf; - IUnknown *seekthru_unk; ImageDescriptionHandle hImageDescription; CFMutableDictionaryRef outputBufferAttributes; @@ -545,36 +544,14 @@ IUnknown * CALLBACK QTVDecoder_create(IUnknown * pUnkOuter, HRESULT* phr) *phr = hr; return NULL; } - else - { - ISeekingPassThru *passthru; - hr = CoCreateInstance(&CLSID_SeekingPassThru, (IUnknown*)This, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&This->seekthru_unk); - IUnknown_QueryInterface(This->seekthru_unk, &IID_ISeekingPassThru, (void**)&passthru); - ISeekingPassThru_Init(passthru, FALSE, This->tf.ppPins[0]); - ISeekingPassThru_Release(passthru); - } *phr = hr; return (IUnknown*)This; } -HRESULT WINAPI QTVDecoder_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv) -{ - HRESULT hr; - QTVDecoderImpl *This = impl_from_IBaseFilter(iface); - TRACE("(%p/%p)->(%s, %p)\n", This, iface, debugstr_guid(riid), ppv); - - if (IsEqualIID(riid, &IID_IMediaSeeking) || IsEqualIID(riid, &IID_IMediaPosition)) - return IUnknown_QueryInterface(This->seekthru_unk, riid, ppv); - - hr = TransformFilterImpl_QueryInterface(iface, riid, ppv); - - return hr; -} - static const IBaseFilterVtbl QTVDecoder_Vtbl = { - QTVDecoder_QueryInterface, + TransformFilterImpl_QueryInterface, BaseFilterImpl_AddRef, TransformFilterImpl_Release, BaseFilterImpl_GetClassID, diff --git a/include/wine/strmbase.h b/include/wine/strmbase.h index cbb7d23a008..ecb53c41c6d 100644 --- a/include/wine/strmbase.h +++ b/include/wine/strmbase.h @@ -207,6 +207,8 @@ typedef struct TransformFilter const struct TransformFilterFuncTable * pFuncsTable; struct QualityControlImpl *qcimpl; + /* IMediaSeeking and IMediaPosition are implemented by ISeekingPassThru */ + IUnknown *seekthru_unk; } TransformFilter; typedef HRESULT (WINAPI *TransformFilter_DecideBufferSize) (TransformFilter *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest);