From 5b248546806c247c8a3c5011fc2d78af8d9da253 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sat, 20 Jun 2015 23:34:58 +0300 Subject: [PATCH] amstream: Get rid of some casts by using proper iface types. --- dlls/amstream/amstream.c | 41 ++++++++++++++----------------- dlls/amstream/amstream_private.h | 5 ++-- dlls/amstream/audiodata.c | 2 -- dlls/amstream/main.c | 1 - dlls/amstream/mediastream.c | 9 +++---- dlls/amstream/mediastreamfilter.c | 1 - 6 files changed, 26 insertions(+), 33 deletions(-) diff --git a/dlls/amstream/amstream.c b/dlls/amstream/amstream.c index fcef7ec47aa..372ddd6a5d4 100644 --- a/dlls/amstream/amstream.c +++ b/dlls/amstream/amstream.c @@ -27,7 +27,6 @@ #include "wingdi.h" #include "amstream_private.h" -#include "amstream.h" WINE_DEFAULT_DEBUG_CHANNEL(amstream); @@ -37,10 +36,10 @@ typedef struct { IGraphBuilder* pFilterGraph; IMediaSeeking* media_seeking; IMediaControl* media_control; - IBaseFilter* media_stream_filter; + IMediaStreamFilter *media_stream_filter; IPin* ipin; ULONG nbStreams; - IMediaStream** pStreams; + IAMMediaStream **pStreams; STREAM_TYPE StreamType; OAEVENT event; } IAMMultiMediaStreamImpl; @@ -114,11 +113,11 @@ static ULONG WINAPI IAMMultiMediaStreamImpl_Release(IAMMultiMediaStream* iface) if (!ref) { for(i = 0; i < This->nbStreams; i++) - IMediaStream_Release(This->pStreams[i]); + IAMMediaStream_Release(This->pStreams[i]); if (This->ipin) IPin_Release(This->ipin); if (This->media_stream_filter) - IBaseFilter_Release(This->media_stream_filter); + IMediaStreamFilter_Release(This->media_stream_filter); if (This->media_seeking) IMediaSeeking_Release(This->media_seeking); if (This->media_control) @@ -151,10 +150,10 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_GetMediaStream(IAMMultiMediaStream for (i = 0; i < This->nbStreams; i++) { - IMediaStream_GetInformation(This->pStreams[i], &PurposeId, NULL); + IAMMediaStream_GetInformation(This->pStreams[i], &PurposeId, NULL); if (IsEqualIID(&PurposeId, idPurpose)) { - *ppMediaStream = This->pStreams[i]; + *ppMediaStream = (IMediaStream*)This->pStreams[i]; IMediaStream_AddRef(*ppMediaStream); return S_OK; } @@ -258,9 +257,9 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_Initialize(IAMMultiMediaStream* if if (SUCCEEDED(hr)) hr = IGraphBuilder_QueryInterface(This->pFilterGraph, &IID_IMediaControl, (void**)&This->media_control); if (SUCCEEDED(hr)) - hr = CoCreateInstance(&CLSID_MediaStreamFilter, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&This->media_stream_filter); + hr = CoCreateInstance(&CLSID_MediaStreamFilter, NULL, CLSCTX_INPROC_SERVER, &IID_IMediaStreamFilter, (void**)&This->media_stream_filter); if (SUCCEEDED(hr)) - hr = IGraphBuilder_AddFilter(This->pFilterGraph, This->media_stream_filter, filternameW); + hr = IGraphBuilder_AddFilter(This->pFilterGraph, (IBaseFilter*)This->media_stream_filter, filternameW); if (SUCCEEDED(hr)) { IMediaEventEx* media_event = NULL; @@ -277,7 +276,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_Initialize(IAMMultiMediaStream* if if (FAILED(hr)) { if (This->media_stream_filter) - IBaseFilter_Release(This->media_stream_filter); + IMediaStreamFilter_Release(This->media_stream_filter); This->media_stream_filter = NULL; if (This->media_seeking) IMediaSeeking_Release(This->media_seeking); @@ -313,19 +312,17 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilterGraph(IAMMultiMediaStream static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilter(IAMMultiMediaStream* iface, IMediaStreamFilter** ppFilter) { IAMMultiMediaStreamImpl *This = impl_from_IAMMultiMediaStream(iface); - HRESULT hr = S_OK; TRACE("(%p/%p)->(%p)\n", This, iface, ppFilter); if (!ppFilter) return E_POINTER; - *ppFilter = NULL; + *ppFilter = This->media_stream_filter; + if (*ppFilter) + IMediaStreamFilter_AddRef(*ppFilter); - if (This->media_stream_filter) - hr = IBaseFilter_QueryInterface(This->media_stream_filter, &IID_IMediaStreamFilter, (LPVOID*)ppFilter); - - return hr; + return S_OK; } static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream* iface, IUnknown* stream_object, const MSPID* PurposeId, @@ -333,8 +330,8 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream { IAMMultiMediaStreamImpl *This = impl_from_IAMMultiMediaStream(iface); HRESULT hr; - IMediaStream* pStream; - IMediaStream** pNewStreams; + IAMMediaStream* pStream; + IAMMediaStream** pNewStreams; TRACE("(%p/%p)->(%p,%s,%x,%p)\n", This, iface, stream_object, debugstr_guid(PurposeId), dwFlags, ppNewStream); @@ -374,10 +371,10 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream hr = audiomediastream_create((IMultiMediaStream*)iface, PurposeId, This->StreamType, &pStream); if (SUCCEEDED(hr)) { - pNewStreams = CoTaskMemRealloc(This->pStreams, (This->nbStreams+1) * sizeof(IMediaStream*)); + pNewStreams = CoTaskMemRealloc(This->pStreams, (This->nbStreams+1) * sizeof(IAMMediaStream*)); if (!pNewStreams) { - IMediaStream_Release(pStream); + IAMMediaStream_Release(pStream); return E_OUTOFMEMORY; } This->pStreams = pNewStreams; @@ -385,13 +382,13 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream This->nbStreams++; if (ppNewStream) - *ppNewStream = pStream; + *ppNewStream = (IMediaStream*)pStream; } if (SUCCEEDED(hr)) { /* Add stream to the media stream filter */ - IMediaStreamFilter_AddMediaStream((IMediaStreamFilter*)This->media_stream_filter, (IAMMediaStream*)pStream); + IMediaStreamFilter_AddMediaStream(This->media_stream_filter, pStream); } return hr; diff --git a/dlls/amstream/amstream_private.h b/dlls/amstream/amstream_private.h index 0881c3ee0a7..64a376f0588 100644 --- a/dlls/amstream/amstream_private.h +++ b/dlls/amstream/amstream_private.h @@ -31,13 +31,14 @@ #include "dshow.h" #include "mmstream.h" #include "austream.h" +#include "amstream.h" HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN; HRESULT AMAudioData_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN; HRESULT MediaStreamFilter_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN; HRESULT ddrawmediastream_create(IMultiMediaStream *Parent, const MSPID *pPurposeId, - STREAM_TYPE StreamType, IMediaStream **ppMediaStream) DECLSPEC_HIDDEN; + STREAM_TYPE StreamType, IAMMediaStream **ppMediaStream) DECLSPEC_HIDDEN; HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_id, - STREAM_TYPE stream_type, IMediaStream **media_stream) DECLSPEC_HIDDEN; + STREAM_TYPE stream_type, IAMMediaStream **media_stream) DECLSPEC_HIDDEN; #endif /* __AMSTREAM_PRIVATE_INCLUDED__ */ diff --git a/dlls/amstream/audiodata.c b/dlls/amstream/audiodata.c index 3a62a9f898f..c3bc1a6e035 100644 --- a/dlls/amstream/audiodata.c +++ b/dlls/amstream/audiodata.c @@ -25,8 +25,6 @@ #include "winbase.h" #include "amstream_private.h" -#include "amstream.h" - WINE_DEFAULT_DEBUG_CHANNEL(amstream); typedef struct { diff --git a/dlls/amstream/main.c b/dlls/amstream/main.c index e80c491f666..1149584e7cb 100644 --- a/dlls/amstream/main.c +++ b/dlls/amstream/main.c @@ -32,7 +32,6 @@ #include "rpcproxy.h" #include "amstream_private.h" -#include "amstream.h" #include "wine/debug.h" diff --git a/dlls/amstream/mediastream.c b/dlls/amstream/mediastream.c index f619cbd23e0..b457d1f946b 100644 --- a/dlls/amstream/mediastream.c +++ b/dlls/amstream/mediastream.c @@ -26,7 +26,6 @@ #include "wingdi.h" #include "amstream_private.h" -#include "amstream.h" #include "ddstream.h" @@ -428,7 +427,7 @@ static const struct IDirectDrawMediaStreamVtbl DirectDrawMediaStreamImpl_IDirect }; HRESULT ddrawmediastream_create(IMultiMediaStream *parent, const MSPID *purpose_id, - STREAM_TYPE stream_type, IMediaStream **media_stream) + STREAM_TYPE stream_type, IAMMediaStream **media_stream) { DirectDrawMediaStreamImpl *object; @@ -446,7 +445,7 @@ HRESULT ddrawmediastream_create(IMultiMediaStream *parent, const MSPID *purpose_ object->purpose_id = *purpose_id; object->stream_type = stream_type; - *media_stream = (IMediaStream*)&object->IAMMediaStream_iface; + *media_stream = &object->IAMMediaStream_iface; return S_OK; } @@ -828,7 +827,7 @@ static const struct IAudioMediaStreamVtbl AudioMediaStreamImpl_IAudioMediaStream }; HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_id, - STREAM_TYPE stream_type, IMediaStream **media_stream) + STREAM_TYPE stream_type, IAMMediaStream **media_stream) { AudioMediaStreamImpl *object; @@ -846,7 +845,7 @@ HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_ object->purpose_id = *purpose_id; object->stream_type = stream_type; - *media_stream = (IMediaStream*)&object->IAMMediaStream_iface; + *media_stream = &object->IAMMediaStream_iface; return S_OK; } diff --git a/dlls/amstream/mediastreamfilter.c b/dlls/amstream/mediastreamfilter.c index 8c26c8e2b09..d4289700bbf 100644 --- a/dlls/amstream/mediastreamfilter.c +++ b/dlls/amstream/mediastreamfilter.c @@ -29,7 +29,6 @@ #include "wine/strmbase.h" #include "amstream_private.h" -#include "amstream.h" #include "ddstream.h"