diff --git a/dlls/amstream/amstream_private.h b/dlls/amstream/amstream_private.h index bec107f819b..e71563cb115 100644 --- a/dlls/amstream/amstream_private.h +++ b/dlls/amstream/amstream_private.h @@ -37,9 +37,7 @@ 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 ddraw_stream_create(IMultiMediaStream *parent, const MSPID *purpose_id, - IUnknown *stream_object, STREAM_TYPE type, IAMMediaStream **stream) DECLSPEC_HIDDEN; -HRESULT audio_stream_create(IMultiMediaStream *parent, const MSPID *purpose_id, - IUnknown *stream_object, STREAM_TYPE stream_type, IAMMediaStream **media_stream) DECLSPEC_HIDDEN; +HRESULT ddraw_stream_create(IUnknown *outer, void **out) DECLSPEC_HIDDEN; +HRESULT audio_stream_create(IUnknown *outer, void **out) DECLSPEC_HIDDEN; #endif /* __AMSTREAM_PRIVATE_INCLUDED__ */ diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index a38cbc5f639..f9470fa5f90 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -1273,13 +1273,12 @@ static const IMemInputPinVtbl audio_meminput_vtbl = audio_meminput_ReceiveCanBlock, }; -HRESULT audio_stream_create(IMultiMediaStream *parent, const MSPID *purpose_id, - IUnknown *stream_object, STREAM_TYPE stream_type, IAMMediaStream **media_stream) +HRESULT audio_stream_create(IUnknown *outer, void **out) { struct audio_stream *object; - HRESULT hr; - TRACE("(%p,%s,%p,%p)\n", parent, debugstr_guid(purpose_id), stream_object, media_stream); + if (outer) + return CLASS_E_NOAGGREGATION; object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); if (!object) @@ -1295,21 +1294,9 @@ HRESULT audio_stream_create(IMultiMediaStream *parent, const MSPID *purpose_id, list_init(&object->receive_queue); list_init(&object->update_queue); - hr = IAMMediaStream_Initialize(&object->IAMMediaStream_iface, stream_object, 0, purpose_id, stream_type); - if (FAILED(hr)) - { - IAMMediaStream_Release(&object->IAMMediaStream_iface); - return hr; - } + TRACE("Created audio stream %p.\n", object); - hr = IAMMediaStream_JoinAMMultiMediaStream(&object->IAMMediaStream_iface, (IAMMultiMediaStream *)parent); - if (FAILED(hr)) - { - IAMMediaStream_Release(&object->IAMMediaStream_iface); - return hr; - } - - *media_stream = &object->IAMMediaStream_iface; + *out = &object->IAMMediaStream_iface; return S_OK; } diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 8e99ea3bf55..1c924e40a20 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -926,13 +926,12 @@ static const IMemInputPinVtbl ddraw_meminput_vtbl = ddraw_meminput_ReceiveCanBlock, }; -HRESULT ddraw_stream_create(IMultiMediaStream *parent, const MSPID *purpose_id, - IUnknown *stream_object, STREAM_TYPE stream_type, IAMMediaStream **media_stream) +HRESULT ddraw_stream_create(IUnknown *outer, void **out) { struct ddraw_stream *object; - HRESULT hr; - TRACE("(%p,%s,%p,%p)\n", parent, debugstr_guid(purpose_id), stream_object, media_stream); + if (outer) + return CLASS_E_NOAGGREGATION; object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); if (!object) @@ -946,21 +945,9 @@ HRESULT ddraw_stream_create(IMultiMediaStream *parent, const MSPID *purpose_id, InitializeCriticalSection(&object->cs); - hr = IAMMediaStream_Initialize(&object->IAMMediaStream_iface, stream_object, 0, purpose_id, stream_type); - if (FAILED(hr)) - { - IAMMediaStream_Release(&object->IAMMediaStream_iface); - return hr; - } + TRACE("Created ddraw stream %p.\n", object); - hr = IAMMediaStream_JoinAMMultiMediaStream(&object->IAMMediaStream_iface, (IAMMultiMediaStream *)parent); - if (FAILED(hr)) - { - IAMMediaStream_Release(&object->IAMMediaStream_iface); - return hr; - } - - *media_stream = &object->IAMMediaStream_iface; + *out = &object->IAMMediaStream_iface; return S_OK; } diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index be8fd4ecbfc..e77392e483a 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -301,6 +301,7 @@ static HRESULT WINAPI multimedia_stream_GetFilter(IAMMultiMediaStream *iface, static void add_stream(struct multimedia_stream *mmstream, IAMMediaStream *stream, IMediaStream **ret_stream) { IMediaStreamFilter_AddMediaStream(mmstream->filter, stream); + IAMMediaStream_JoinAMMultiMediaStream(stream, &mmstream->IAMMultiMediaStream_iface); if (ret_stream) { *ret_stream = (IMediaStream *)stream; @@ -377,19 +378,26 @@ static HRESULT WINAPI multimedia_stream_AddMediaStream(IAMMultiMediaStream *ifac } if (IsEqualGUID(PurposeId, &MSPID_PrimaryVideo)) - hr = ddraw_stream_create((IMultiMediaStream*)iface, PurposeId, stream_object, This->type, &pStream); + hr = ddraw_stream_create(NULL, (void **)&pStream); else if (IsEqualGUID(PurposeId, &MSPID_PrimaryAudio)) - hr = audio_stream_create((IMultiMediaStream*)iface, PurposeId, stream_object, This->type, &pStream); + hr = audio_stream_create(NULL, (void **)&pStream); else return MS_E_PURPOSEID; - if (SUCCEEDED(hr)) + if (FAILED(hr)) + return hr; + + hr = IAMMediaStream_Initialize(pStream, stream_object, dwFlags, PurposeId, This->type); + if (FAILED(hr)) { - add_stream(This, pStream, ret_stream); IAMMediaStream_Release(pStream); + return hr; } - return hr; + add_stream(This, pStream, ret_stream); + IAMMediaStream_Release(pStream); + + return S_OK; } static HRESULT WINAPI multimedia_stream_OpenFile(IAMMultiMediaStream *iface, diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 073e372c94f..13c00aac25a 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -730,7 +730,7 @@ static void test_add_stream(void) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(stream == (IMediaStream *)&teststream, "Streams didn't match.\n"); if (hr == S_OK) IMediaStream_Release(stream); - todo_wine ok(teststream.mmstream == mmstream, "IAMMultiMediaStream objects didn't match.\n"); + ok(teststream.mmstream == mmstream, "IAMMultiMediaStream objects didn't match.\n"); ok(teststream.filter == stream_filter, "IMediaStreamFilter objects didn't match.\n"); todo_wine ok(!!teststream.graph, "Expected a non-NULL graph.\n");