Commit 5eb56835 authored by Anton Baskanov's avatar Anton Baskanov Committed by Alexandre Julliard

amstream: Move initialization calls from *_stream_create into AMMultiMediaStream::AddMediaStream.

parent f568c47a
......@@ -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__ */
......@@ -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;
}
hr = IAMMediaStream_JoinAMMultiMediaStream(&object->IAMMediaStream_iface, (IAMMultiMediaStream *)parent);
if (FAILED(hr))
{
IAMMediaStream_Release(&object->IAMMediaStream_iface);
return hr;
}
TRACE("Created audio stream %p.\n", object);
*media_stream = &object->IAMMediaStream_iface;
*out = &object->IAMMediaStream_iface;
return S_OK;
}
......@@ -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;
}
hr = IAMMediaStream_JoinAMMultiMediaStream(&object->IAMMediaStream_iface, (IAMMultiMediaStream *)parent);
if (FAILED(hr))
{
IAMMediaStream_Release(&object->IAMMediaStream_iface);
return hr;
}
TRACE("Created ddraw stream %p.\n", object);
*media_stream = &object->IAMMediaStream_iface;
*out = &object->IAMMediaStream_iface;
return S_OK;
}
......
......@@ -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,
......
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment