From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/amstream/amstream_private.h | 2 +- dlls/amstream/main.c | 4 +- dlls/amstream/multimedia.c | 95 +++++++++++++++++--------------- 3 files changed, 55 insertions(+), 46 deletions(-)
diff --git a/dlls/amstream/amstream_private.h b/dlls/amstream/amstream_private.h index e44a9de7495..105ddb13f5c 100644 --- a/dlls/amstream/amstream_private.h +++ b/dlls/amstream/amstream_private.h @@ -34,7 +34,7 @@ #include "amstream.h" #include "wine/heap.h"
-HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN; +HRESULT multimedia_stream_create(IUnknown *outer, void **out) DECLSPEC_HIDDEN; HRESULT AMAudioData_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN; HRESULT filter_create(IUnknown *outer, void **out) DECLSPEC_HIDDEN; HRESULT ddrawmediastream_create(IMultiMediaStream *Parent, const MSPID *pPurposeId, diff --git a/dlls/amstream/main.c b/dlls/amstream/main.c index b6705945a85..c718f42448c 100644 --- a/dlls/amstream/main.c +++ b/dlls/amstream/main.c @@ -73,8 +73,8 @@ struct object_creation_info
static const struct object_creation_info object_creation[] = { - { &CLSID_AMMultiMediaStream, AM_create }, - { &CLSID_AMDirectDrawStream, AM_create }, + { &CLSID_AMMultiMediaStream, multimedia_stream_create }, + { &CLSID_AMDirectDrawStream, multimedia_stream_create }, { &CLSID_AMAudioData, AMAudioData_create }, { &CLSID_MediaStreamFilter, filter_create } }; diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index 47753512810..7f0fb34d266 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -50,9 +50,9 @@ static inline struct multimedia_stream *impl_from_IAMMultiMediaStream(IAMMultiMe return CONTAINING_RECORD(iface, struct multimedia_stream, IAMMultiMediaStream_iface); }
-static const struct IAMMultiMediaStreamVtbl AM_Vtbl; +static const struct IAMMultiMediaStreamVtbl multimedia_stream_vtbl;
-HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj) +HRESULT multimedia_stream_create(IUnknown *pUnkOuter, LPVOID *ppObj) { struct multimedia_stream *object; HRESULT hr; @@ -65,7 +65,7 @@ HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj) if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY;
- object->IAMMultiMediaStream_iface.lpVtbl = &AM_Vtbl; + object->IAMMultiMediaStream_iface.lpVtbl = &multimedia_stream_vtbl; object->ref = 1;
if (FAILED(hr = CoCreateInstance(&CLSID_MediaStreamFilter, NULL, @@ -82,7 +82,8 @@ HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj) }
/*** IUnknown methods ***/ -static HRESULT WINAPI IAMMultiMediaStreamImpl_QueryInterface(IAMMultiMediaStream* iface, REFIID riid, void** ppvObject) +static HRESULT WINAPI multimedia_stream_QueryInterface(IAMMultiMediaStream *iface, + REFIID riid, void **ppvObject) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
@@ -102,7 +103,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_QueryInterface(IAMMultiMediaStream return E_NOINTERFACE; }
-static ULONG WINAPI IAMMultiMediaStreamImpl_AddRef(IAMMultiMediaStream* iface) +static ULONG WINAPI multimedia_stream_AddRef(IAMMultiMediaStream *iface) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
@@ -111,7 +112,7 @@ static ULONG WINAPI IAMMultiMediaStreamImpl_AddRef(IAMMultiMediaStream* iface) return InterlockedIncrement(&This->ref); }
-static ULONG WINAPI IAMMultiMediaStreamImpl_Release(IAMMultiMediaStream* iface) +static ULONG WINAPI multimedia_stream_Release(IAMMultiMediaStream *iface) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface); ULONG ref = InterlockedDecrement(&This->ref); @@ -140,7 +141,8 @@ static ULONG WINAPI IAMMultiMediaStreamImpl_Release(IAMMultiMediaStream* iface) }
/*** IMultiMediaStream methods ***/ -static HRESULT WINAPI IAMMultiMediaStreamImpl_GetInformation(IAMMultiMediaStream* iface, DWORD* pdwFlags, STREAM_TYPE* pStreamType) +static HRESULT WINAPI multimedia_stream_GetInformation(IAMMultiMediaStream *iface, + DWORD *pdwFlags, STREAM_TYPE *pStreamType) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
@@ -149,7 +151,8 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_GetInformation(IAMMultiMediaStream return E_NOTIMPL; }
-static HRESULT WINAPI IAMMultiMediaStreamImpl_GetMediaStream(IAMMultiMediaStream* iface, REFMSPID idPurpose, IMediaStream** ppMediaStream) +static HRESULT WINAPI multimedia_stream_GetMediaStream(IAMMultiMediaStream *iface, + REFMSPID idPurpose, IMediaStream **ppMediaStream) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface); MSPID PurposeId; @@ -171,7 +174,8 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_GetMediaStream(IAMMultiMediaStream return MS_E_NOSTREAM; }
-static HRESULT WINAPI IAMMultiMediaStreamImpl_EnumMediaStreams(IAMMultiMediaStream* iface, LONG Index, IMediaStream** ppMediaStream) +static HRESULT WINAPI multimedia_stream_EnumMediaStreams(IAMMultiMediaStream *iface, + LONG Index, IMediaStream **ppMediaStream) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
@@ -180,7 +184,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_EnumMediaStreams(IAMMultiMediaStre return E_NOTIMPL; }
-static HRESULT WINAPI IAMMultiMediaStreamImpl_GetState(IAMMultiMediaStream* iface, STREAM_STATE* pCurrentState) +static HRESULT WINAPI multimedia_stream_GetState(IAMMultiMediaStream *iface, STREAM_STATE *pCurrentState) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
@@ -189,7 +193,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_GetState(IAMMultiMediaStream* ifac return E_NOTIMPL; }
-static HRESULT WINAPI IAMMultiMediaStreamImpl_SetState(IAMMultiMediaStream* iface, STREAM_STATE new_state) +static HRESULT WINAPI multimedia_stream_SetState(IAMMultiMediaStream *iface, STREAM_STATE new_state) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface); HRESULT hr = E_INVALIDARG; @@ -204,7 +208,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_SetState(IAMMultiMediaStream* ifac return hr; }
-static HRESULT WINAPI IAMMultiMediaStreamImpl_GetTime(IAMMultiMediaStream* iface, STREAM_TIME* pCurrentTime) +static HRESULT WINAPI multimedia_stream_GetTime(IAMMultiMediaStream *iface, STREAM_TIME *pCurrentTime) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
@@ -213,7 +217,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_GetTime(IAMMultiMediaStream* iface return E_NOTIMPL; }
-static HRESULT WINAPI IAMMultiMediaStreamImpl_GetDuration(IAMMultiMediaStream* iface, STREAM_TIME* pDuration) +static HRESULT WINAPI multimedia_stream_GetDuration(IAMMultiMediaStream *iface, STREAM_TIME *pDuration) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
@@ -222,7 +226,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_GetDuration(IAMMultiMediaStream* i return E_NOTIMPL; }
-static HRESULT WINAPI IAMMultiMediaStreamImpl_Seek(IAMMultiMediaStream* iface, STREAM_TIME seek_time) +static HRESULT WINAPI multimedia_stream_Seek(IAMMultiMediaStream *iface, STREAM_TIME seek_time) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
@@ -231,7 +235,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_Seek(IAMMultiMediaStream* iface, S return IMediaSeeking_SetPositions(This->media_seeking, &seek_time, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning); }
-static HRESULT WINAPI IAMMultiMediaStreamImpl_GetEndOfStream(IAMMultiMediaStream* iface, HANDLE* phEOS) +static HRESULT WINAPI multimedia_stream_GetEndOfStream(IAMMultiMediaStream *iface, HANDLE *phEOS) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
@@ -241,7 +245,8 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_GetEndOfStream(IAMMultiMediaStream }
/*** IAMMultiMediaStream methods ***/ -static HRESULT WINAPI IAMMultiMediaStreamImpl_Initialize(IAMMultiMediaStream* iface, STREAM_TYPE StreamType, DWORD dwFlags, IGraphBuilder* pFilterGraph) +static HRESULT WINAPI multimedia_stream_Initialize(IAMMultiMediaStream *iface, + STREAM_TYPE StreamType, DWORD dwFlags, IGraphBuilder *pFilterGraph) { static const WCHAR filternameW[] = {'M','e','d','i','a','S','t','r','e','a','m','F','i','l','t','e','r',0}; struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface); @@ -296,7 +301,8 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_Initialize(IAMMultiMediaStream* if return hr; }
-static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilterGraph(IAMMultiMediaStream* iface, IGraphBuilder** ppGraphBuilder) +static HRESULT WINAPI multimedia_stream_GetFilterGraph(IAMMultiMediaStream *iface, + IGraphBuilder **ppGraphBuilder) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
@@ -313,7 +319,8 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilterGraph(IAMMultiMediaStream return S_OK; }
-static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilter(IAMMultiMediaStream *iface, IMediaStreamFilter **filter) +static HRESULT WINAPI multimedia_stream_GetFilter(IAMMultiMediaStream *iface, + IMediaStreamFilter **filter) { struct multimedia_stream *mmstream = impl_from_IAMMultiMediaStream(iface);
@@ -327,8 +334,8 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilter(IAMMultiMediaStream *ifa return S_OK; }
-static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream* iface, IUnknown* stream_object, const MSPID* PurposeId, - DWORD dwFlags, IMediaStream** ppNewStream) +static HRESULT WINAPI multimedia_stream_AddMediaStream(IAMMultiMediaStream *iface, + IUnknown *stream_object, const MSPID *PurposeId, DWORD dwFlags, IMediaStream **ppNewStream) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface); HRESULT hr; @@ -395,7 +402,8 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream return hr; }
-static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenFile(IAMMultiMediaStream* iface, LPCWSTR filename, DWORD flags) +static HRESULT WINAPI multimedia_stream_OpenFile(IAMMultiMediaStream *iface, + const WCHAR *filename, DWORD flags) { static const WCHAR sourceW[] = {'S','o','u','r','c','e',0}; struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface); @@ -440,7 +448,8 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenFile(IAMMultiMediaStream* ifac return ret; }
-static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenMoniker(IAMMultiMediaStream* iface, IBindCtx* pCtx, IMoniker* pMoniker, DWORD dwFlags) +static HRESULT WINAPI multimedia_stream_OpenMoniker(IAMMultiMediaStream *iface, + IBindCtx *pCtx, IMoniker *pMoniker, DWORD dwFlags) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
@@ -449,7 +458,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenMoniker(IAMMultiMediaStream* i return E_NOTIMPL; }
-static HRESULT WINAPI IAMMultiMediaStreamImpl_Render(IAMMultiMediaStream* iface, DWORD dwFlags) +static HRESULT WINAPI multimedia_stream_Render(IAMMultiMediaStream *iface, DWORD dwFlags) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
@@ -461,25 +470,25 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_Render(IAMMultiMediaStream* iface, return IGraphBuilder_Render(This->pFilterGraph, This->ipin); }
-static const IAMMultiMediaStreamVtbl AM_Vtbl = +static const IAMMultiMediaStreamVtbl multimedia_stream_vtbl = { - IAMMultiMediaStreamImpl_QueryInterface, - IAMMultiMediaStreamImpl_AddRef, - IAMMultiMediaStreamImpl_Release, - IAMMultiMediaStreamImpl_GetInformation, - IAMMultiMediaStreamImpl_GetMediaStream, - IAMMultiMediaStreamImpl_EnumMediaStreams, - IAMMultiMediaStreamImpl_GetState, - IAMMultiMediaStreamImpl_SetState, - IAMMultiMediaStreamImpl_GetTime, - IAMMultiMediaStreamImpl_GetDuration, - IAMMultiMediaStreamImpl_Seek, - IAMMultiMediaStreamImpl_GetEndOfStream, - IAMMultiMediaStreamImpl_Initialize, - IAMMultiMediaStreamImpl_GetFilterGraph, - IAMMultiMediaStreamImpl_GetFilter, - IAMMultiMediaStreamImpl_AddMediaStream, - IAMMultiMediaStreamImpl_OpenFile, - IAMMultiMediaStreamImpl_OpenMoniker, - IAMMultiMediaStreamImpl_Render + multimedia_stream_QueryInterface, + multimedia_stream_AddRef, + multimedia_stream_Release, + multimedia_stream_GetInformation, + multimedia_stream_GetMediaStream, + multimedia_stream_EnumMediaStreams, + multimedia_stream_GetState, + multimedia_stream_SetState, + multimedia_stream_GetTime, + multimedia_stream_GetDuration, + multimedia_stream_Seek, + multimedia_stream_GetEndOfStream, + multimedia_stream_Initialize, + multimedia_stream_GetFilterGraph, + multimedia_stream_GetFilter, + multimedia_stream_AddMediaStream, + multimedia_stream_OpenFile, + multimedia_stream_OpenMoniker, + multimedia_stream_Render };
From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/amstream/multimedia.c | 59 ++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 31 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index 7f0fb34d266..7b0b6ae1c98 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -50,37 +50,6 @@ static inline struct multimedia_stream *impl_from_IAMMultiMediaStream(IAMMultiMe return CONTAINING_RECORD(iface, struct multimedia_stream, IAMMultiMediaStream_iface); }
-static const struct IAMMultiMediaStreamVtbl multimedia_stream_vtbl; - -HRESULT multimedia_stream_create(IUnknown *pUnkOuter, LPVOID *ppObj) -{ - struct multimedia_stream *object; - HRESULT hr; - - TRACE("(%p,%p)\n", pUnkOuter, ppObj); - - if( pUnkOuter ) - return CLASS_E_NOAGGREGATION; - - if (!(object = heap_alloc_zero(sizeof(*object)))) - return E_OUTOFMEMORY; - - object->IAMMultiMediaStream_iface.lpVtbl = &multimedia_stream_vtbl; - object->ref = 1; - - if (FAILED(hr = CoCreateInstance(&CLSID_MediaStreamFilter, NULL, - CLSCTX_INPROC_SERVER, &IID_IMediaStreamFilter, (void **)&object->filter))) - { - ERR("Failed to create stream filter, hr %#x.\n", hr); - heap_free(object); - return hr; - } - - *ppObj = &object->IAMMultiMediaStream_iface; - - return S_OK; -} - /*** IUnknown methods ***/ static HRESULT WINAPI multimedia_stream_QueryInterface(IAMMultiMediaStream *iface, REFIID riid, void **ppvObject) @@ -492,3 +461,31 @@ static const IAMMultiMediaStreamVtbl multimedia_stream_vtbl = multimedia_stream_OpenMoniker, multimedia_stream_Render }; + +HRESULT multimedia_stream_create(IUnknown *outer, void **out) +{ + struct multimedia_stream *object; + HRESULT hr; + + if (outer) + return CLASS_E_NOAGGREGATION; + + if (!(object = heap_alloc_zero(sizeof(*object)))) + return E_OUTOFMEMORY; + + object->IAMMultiMediaStream_iface.lpVtbl = &multimedia_stream_vtbl; + object->ref = 1; + + if (FAILED(hr = CoCreateInstance(&CLSID_MediaStreamFilter, NULL, + CLSCTX_INPROC_SERVER, &IID_IMediaStreamFilter, (void **)&object->filter))) + { + ERR("Failed to create stream filter, hr %#x.\n", hr); + heap_free(object); + return hr; + } + + TRACE("Created multimedia stream %p.\n", object); + *out = &object->IAMMultiMediaStream_iface; + + return S_OK; +}
From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/amstream/multimedia.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index 7b0b6ae1c98..1449c457992 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -121,26 +121,13 @@ static HRESULT WINAPI multimedia_stream_GetInformation(IAMMultiMediaStream *ifac }
static HRESULT WINAPI multimedia_stream_GetMediaStream(IAMMultiMediaStream *iface, - REFMSPID idPurpose, IMediaStream **ppMediaStream) + REFMSPID id, IMediaStream **stream) { - struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface); - MSPID PurposeId; - unsigned int i; - - TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_guid(idPurpose), ppMediaStream); + struct multimedia_stream *mmstream = impl_from_IAMMultiMediaStream(iface);
- for (i = 0; i < This->nbStreams; i++) - { - IAMMediaStream_GetInformation(This->pStreams[i], &PurposeId, NULL); - if (IsEqualIID(&PurposeId, idPurpose)) - { - *ppMediaStream = (IMediaStream*)This->pStreams[i]; - IMediaStream_AddRef(*ppMediaStream); - return S_OK; - } - } + TRACE("mmstream %p, id %s, stream %p.\n", mmstream, debugstr_guid(id), stream);
- return MS_E_NOSTREAM; + return IMediaStreamFilter_GetMediaStream(mmstream->filter, id, stream); }
static HRESULT WINAPI multimedia_stream_EnumMediaStreams(IAMMultiMediaStream *iface,
From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/amstream/multimedia.c | 33 +++++++-------------------------- dlls/amstream/tests/amstream.c | 4 ++-- 2 files changed, 9 insertions(+), 28 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index 1449c457992..55c13286eee 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -39,8 +39,6 @@ struct multimedia_stream IMediaControl* media_control; IMediaStreamFilter *filter; IPin* ipin; - ULONG nbStreams; - IAMMediaStream **pStreams; STREAM_TYPE StreamType; OAEVENT event; }; @@ -85,15 +83,11 @@ static ULONG WINAPI multimedia_stream_Release(IAMMultiMediaStream *iface) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface); ULONG ref = InterlockedDecrement(&This->ref); - ULONG i;
TRACE("(%p/%p)\n", iface, This);
if (!ref) { - for(i = 0; i < This->nbStreams; i++) - IAMMediaStream_Release(This->pStreams[i]); - CoTaskMemFree(This->pStreams); if (This->ipin) IPin_Release(This->ipin); IMediaStreamFilter_Release(This->filter); @@ -291,14 +285,14 @@ static HRESULT WINAPI multimedia_stream_GetFilter(IAMMultiMediaStream *iface, }
static HRESULT WINAPI multimedia_stream_AddMediaStream(IAMMultiMediaStream *iface, - IUnknown *stream_object, const MSPID *PurposeId, DWORD dwFlags, IMediaStream **ppNewStream) + IUnknown *stream_object, const MSPID *PurposeId, DWORD dwFlags, IMediaStream **ret_stream) { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface); HRESULT hr; IAMMediaStream* pStream; - IAMMediaStream** pNewStreams;
- TRACE("(%p/%p)->(%p,%s,%x,%p)\n", This, iface, stream_object, debugstr_guid(PurposeId), dwFlags, ppNewStream); + TRACE("mmstream %p, stream_object %p, id %s, flags %#x, ret_stream %p.\n", + This, stream_object, debugstr_guid(PurposeId), dwFlags, ret_stream);
if (!IsEqualGUID(PurposeId, &MSPID_PrimaryVideo) && !IsEqualGUID(PurposeId, &MSPID_PrimaryAudio)) return MS_E_PURPOSEID; @@ -331,28 +325,15 @@ static HRESULT WINAPI multimedia_stream_AddMediaStream(IAMMultiMediaStream *ifac hr = ddrawmediastream_create((IMultiMediaStream*)iface, PurposeId, stream_object, This->StreamType, &pStream); else hr = audiomediastream_create((IMultiMediaStream*)iface, PurposeId, stream_object, This->StreamType, &pStream); - if (SUCCEEDED(hr)) - { - pNewStreams = CoTaskMemRealloc(This->pStreams, (This->nbStreams+1) * sizeof(IAMMediaStream*)); - if (!pNewStreams) - { - IAMMediaStream_Release(pStream); - return E_OUTOFMEMORY; - } - This->pStreams = pNewStreams; - This->pStreams[This->nbStreams] = pStream; - This->nbStreams++; - - if (ppNewStream) - { - IMediaStream_AddRef(*ppNewStream = (IMediaStream*)pStream); - } - }
if (SUCCEEDED(hr)) { /* Add stream to the media stream filter */ IMediaStreamFilter_AddMediaStream(This->filter, pStream); + if (ret_stream) + *ret_stream = (IMediaStream *)pStream; + else + IAMMediaStream_Release(pStream); }
return hr; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index b83e7bc1a84..24c48ec5584 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1152,7 +1152,7 @@ static void test_enum_pins(void) ref = get_refcount(enum1); ok(ref == 1, "Got unexpected refcount %d.\n", ref); ref = get_refcount(pin); - todo_wine ok(ref == 4, "Got unexpected refcount %d.\n", ref); + ok(ref == 4, "Got unexpected refcount %d.\n", ref);
hr = IEnumPins_Next(enum1, 1, pins, NULL); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -1162,7 +1162,7 @@ static void test_enum_pins(void) ref = get_refcount(enum1); ok(ref == 1, "Got unexpected refcount %d.\n", ref); ref = get_refcount(pin); - todo_wine ok(ref == 5, "Got unexpected refcount %d.\n", ref); + ok(ref == 5, "Got unexpected refcount %d.\n", ref); IPin_Release(pins[0]);
hr = IEnumPins_Next(enum1, 1, pins, NULL);
From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/amstream/tests/amstream.c | 132 +++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+)
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 24c48ec5584..000bb40537f 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1649,6 +1649,137 @@ static void test_initialize(void) IUnknown_Release(graph_inner_unk); }
+static void test_enum_media_types(void) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IEnumMediaTypes *enum1, *enum2; + AM_MEDIA_TYPE *mts[2]; + IMediaStream *stream; + ULONG ref, count; + HRESULT hr; + IPin *pin; + + /* FIXME: This call should not be necessary. */ + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, &stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EnumMediaTypes(pin, &enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL); + todo_wine ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enum1, 0, mts, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!count, "Got count %u.\n", count); + + hr = IEnumMediaTypes_Next(enum1, 1, mts, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + CoTaskMemFree(mts[0]); + + hr = IEnumMediaTypes_Next(enum1, 1, mts, &count); + todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + todo_wine ok(!count, "Got count %u.\n", count); + + hr = IEnumMediaTypes_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enum1, 2, mts, &count); + todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + todo_wine ok(count == 1, "Got count %u.\n", count); + CoTaskMemFree(mts[0]); + + hr = IEnumMediaTypes_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Clone(enum1, &enum2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Skip(enum1, 2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enum1, 1, mts, &count); + todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + todo_wine ok(!count, "Got count %u.\n", count); + + hr = IEnumMediaTypes_Next(enum2, 1, mts, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + CoTaskMemFree(mts[0]); + + IEnumMediaTypes_Release(enum2); + IEnumMediaTypes_Release(enum1); + IPin_Release(pin); + IMediaStream_Release(stream); + + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, &stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EnumMediaTypes(pin, &enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL); + todo_wine ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enum1, 0, mts, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!count, "Got count %u.\n", count); + + hr = IEnumMediaTypes_Next(enum1, 1, mts, &count); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(count == 1, "Got count %u.\n", count); + if (hr == S_OK) CoTaskMemFree(mts[0]->pbFormat); + if (hr == S_OK) CoTaskMemFree(mts[0]); + + hr = IEnumMediaTypes_Next(enum1, 1, mts, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(!count, "Got count %u.\n", count); + + hr = IEnumMediaTypes_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enum1, 2, mts, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + CoTaskMemFree(mts[0]->pbFormat); + CoTaskMemFree(mts[0]); + + hr = IEnumMediaTypes_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Clone(enum1, &enum2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Skip(enum1, 2); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enum1, 1, mts, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(!count, "Got count %u.\n", count); + + hr = IEnumMediaTypes_Next(enum2, 1, mts, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + CoTaskMemFree(mts[0]->pbFormat); + CoTaskMemFree(mts[0]); + + IEnumMediaTypes_Release(enum2); + IEnumMediaTypes_Release(enum1); + IPin_Release(pin); + IMediaStream_Release(stream); + + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + static void test_IDirectDrawStreamSample(void) { DDSURFACEDESC desc = { sizeof(desc) }; @@ -2026,6 +2157,7 @@ START_TEST(amstream) test_find_pin(); test_pin_info(); test_initialize(); + test_enum_media_types(); test_IDirectDrawStreamSample();
file = CreateFileW(filenameW, 0, 0, NULL, OPEN_EXISTING, 0, NULL);