Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/multimedia.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index 6fb3ebd17c..ac61010698 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -250,20 +250,19 @@ static HRESULT WINAPI multimedia_stream_Initialize(IAMMultiMediaStream *iface, return hr; }
-static HRESULT WINAPI multimedia_stream_GetFilterGraph(IAMMultiMediaStream *iface, - IGraphBuilder **ppGraphBuilder) +static HRESULT WINAPI multimedia_stream_GetFilterGraph(IAMMultiMediaStream *iface, IGraphBuilder **graph) { - struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface); + struct multimedia_stream *mmstream = impl_from_IAMMultiMediaStream(iface);
- TRACE("(%p/%p)->(%p)\n", This, iface, ppGraphBuilder); + TRACE("mmstream %p, graph %p.\n", mmstream, graph);
- if (!ppGraphBuilder) + if (!graph) return E_POINTER;
- if (This->pFilterGraph) - return IGraphBuilder_QueryInterface(This->pFilterGraph, &IID_IGraphBuilder, (void**)ppGraphBuilder); + if (mmstream->pFilterGraph) + IGraphBuilder_AddRef(*graph = mmstream->pFilterGraph); else - *ppGraphBuilder = NULL; + *graph = NULL;
return S_OK; }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/multimedia.c | 113 +++++++++++++++++---------------- dlls/amstream/tests/amstream.c | 54 +++++++--------- 2 files changed, 83 insertions(+), 84 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index ac61010698..a14771ec75 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -34,12 +34,12 @@ struct multimedia_stream { IAMMultiMediaStream IAMMultiMediaStream_iface; LONG ref; - IGraphBuilder* pFilterGraph; + IGraphBuilder *graph; IMediaSeeking* media_seeking; IMediaControl* media_control; IMediaStreamFilter *filter; IPin* ipin; - STREAM_TYPE StreamType; + STREAM_TYPE type; OAEVENT event; };
@@ -95,8 +95,8 @@ static ULONG WINAPI multimedia_stream_Release(IAMMultiMediaStream *iface) IMediaSeeking_Release(This->media_seeking); if (This->media_control) IMediaControl_Release(This->media_control); - if (This->pFilterGraph) - IGraphBuilder_Release(This->pFilterGraph); + if (This->graph) + IGraphBuilder_Release(This->graph); HeapFree(GetProcessHeap(), 0, This); }
@@ -194,62 +194,64 @@ static HRESULT WINAPI multimedia_stream_GetEndOfStream(IAMMultiMediaStream *ifac return E_NOTIMPL; }
-/*** IAMMultiMediaStream methods ***/ -static HRESULT WINAPI multimedia_stream_Initialize(IAMMultiMediaStream *iface, - STREAM_TYPE StreamType, DWORD dwFlags, IGraphBuilder *pFilterGraph) +static HRESULT create_graph(struct multimedia_stream *mmstream, IGraphBuilder *graph) { - struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface); - HRESULT hr = S_OK; - - TRACE("(%p/%p)->(%x,%x,%p)\n", This, iface, (DWORD)StreamType, dwFlags, pFilterGraph); + IMediaEventEx *eventsrc; + HRESULT hr;
- if (pFilterGraph) - { - This->pFilterGraph = pFilterGraph; - IGraphBuilder_AddRef(This->pFilterGraph); - } - else - { - hr = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IGraphBuilder, (LPVOID*)&This->pFilterGraph); - } + if (graph) + IGraphBuilder_AddRef(mmstream->graph = graph); + else if (FAILED(hr = CoCreateInstance(&CLSID_FilterGraph, NULL, + CLSCTX_INPROC_SERVER, &IID_IGraphBuilder, (void **)&mmstream->graph))) + return hr;
+ hr = IGraphBuilder_QueryInterface(mmstream->graph, &IID_IMediaSeeking, (void **)&mmstream->media_seeking); + if (SUCCEEDED(hr)) + hr = IGraphBuilder_QueryInterface(mmstream->graph, &IID_IMediaControl, (void **)&mmstream->media_control); + if (SUCCEEDED(hr)) + hr = IGraphBuilder_AddFilter(mmstream->graph, (IBaseFilter *)mmstream->filter, L"MediaStreamFilter"); + if (SUCCEEDED(hr)) + hr = IGraphBuilder_QueryInterface(mmstream->graph, &IID_IMediaEventEx, (void **)&eventsrc); if (SUCCEEDED(hr)) { - This->StreamType = StreamType; - hr = IGraphBuilder_QueryInterface(This->pFilterGraph, &IID_IMediaSeeking, (void**)&This->media_seeking); - if (SUCCEEDED(hr)) - hr = IGraphBuilder_QueryInterface(This->pFilterGraph, &IID_IMediaControl, (void**)&This->media_control); + hr = IMediaEventEx_GetEventHandle(eventsrc, &mmstream->event); if (SUCCEEDED(hr)) - hr = IGraphBuilder_AddFilter(This->pFilterGraph, (IBaseFilter*)This->filter, L"MediaStreamFilter"); - if (SUCCEEDED(hr)) - { - IMediaEventEx* media_event = NULL; - hr = IGraphBuilder_QueryInterface(This->pFilterGraph, &IID_IMediaEventEx, (void**)&media_event); - if (SUCCEEDED(hr)) - hr = IMediaEventEx_GetEventHandle(media_event, &This->event); - if (SUCCEEDED(hr)) - hr = IMediaEventEx_SetNotifyFlags(media_event, AM_MEDIAEVENT_NONOTIFY); - if (media_event) - IMediaEventEx_Release(media_event); - } + hr = IMediaEventEx_SetNotifyFlags(eventsrc, AM_MEDIAEVENT_NONOTIFY); + IMediaEventEx_Release(eventsrc); }
if (FAILED(hr)) { - if (This->media_seeking) - IMediaSeeking_Release(This->media_seeking); - This->media_seeking = NULL; - if (This->media_control) - IMediaControl_Release(This->media_control); - This->media_control = NULL; - if (This->pFilterGraph) - IGraphBuilder_Release(This->pFilterGraph); - This->pFilterGraph = NULL; + if (mmstream->media_seeking) + IMediaSeeking_Release(mmstream->media_seeking); + mmstream->media_seeking = NULL; + if (mmstream->media_control) + IMediaControl_Release(mmstream->media_control); + mmstream->media_control = NULL; + if (mmstream->graph) + IGraphBuilder_Release(mmstream->graph); + mmstream->graph = NULL; }
return hr; }
+static HRESULT WINAPI multimedia_stream_Initialize(IAMMultiMediaStream *iface, + STREAM_TYPE type, DWORD flags, IGraphBuilder *graph) +{ + struct multimedia_stream *mmstream = impl_from_IAMMultiMediaStream(iface); + HRESULT hr; + + TRACE("mmstream %p, type %u, flags %#x, graph %p.\n", mmstream, type, flags, graph); + + if (FAILED(hr = create_graph(mmstream, graph))) + return hr; + + mmstream->type = type; + + return S_OK; +} + static HRESULT WINAPI multimedia_stream_GetFilterGraph(IAMMultiMediaStream *iface, IGraphBuilder **graph) { struct multimedia_stream *mmstream = impl_from_IAMMultiMediaStream(iface); @@ -259,8 +261,8 @@ static HRESULT WINAPI multimedia_stream_GetFilterGraph(IAMMultiMediaStream *ifac if (!graph) return E_POINTER;
- if (mmstream->pFilterGraph) - IGraphBuilder_AddRef(*graph = mmstream->pFilterGraph); + if (mmstream->graph) + IGraphBuilder_AddRef(*graph = mmstream->graph); else *graph = NULL;
@@ -302,6 +304,9 @@ static HRESULT WINAPI multimedia_stream_AddMediaStream(IAMMultiMediaStream *ifac return MS_E_PURPOSEID; }
+ if (!This->graph && FAILED(hr = create_graph(This, NULL))) + return hr; + if (dwFlags & AMMSF_ADDDEFAULTRENDERER) { IBaseFilter *dsound_render; @@ -318,16 +323,16 @@ static HRESULT WINAPI multimedia_stream_AddMediaStream(IAMMultiMediaStream *ifac if (SUCCEEDED(hr = CoCreateInstance(&CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (void **)&dsound_render))) { - hr = IGraphBuilder_AddFilter(This->pFilterGraph, dsound_render, NULL); + hr = IGraphBuilder_AddFilter(This->graph, dsound_render, NULL); IBaseFilter_Release(dsound_render); } return hr; }
if (IsEqualGUID(PurposeId, &MSPID_PrimaryVideo)) - hr = ddraw_stream_create((IMultiMediaStream*)iface, PurposeId, stream_object, This->StreamType, &pStream); + hr = ddraw_stream_create((IMultiMediaStream*)iface, PurposeId, stream_object, This->type, &pStream); else - hr = audio_stream_create((IMultiMediaStream*)iface, PurposeId, stream_object, This->StreamType, &pStream); + hr = audio_stream_create((IMultiMediaStream*)iface, PurposeId, stream_object, This->type, &pStream);
if (SUCCEEDED(hr)) { @@ -358,11 +363,11 @@ static HRESULT WINAPI multimedia_stream_OpenFile(IAMMultiMediaStream *iface, return E_POINTER;
/* If Initialize was not called before, we do it here */ - if (!This->pFilterGraph) + if (!This->graph) ret = IAMMultiMediaStream_Initialize(iface, STREAMTYPE_READ, 0, NULL);
if (SUCCEEDED(ret)) - ret = IGraphBuilder_AddSourceFilter(This->pFilterGraph, filename, L"Source", &BaseFilter); + ret = IGraphBuilder_AddSourceFilter(This->graph, filename, L"Source", &BaseFilter);
if (SUCCEEDED(ret)) ret = IBaseFilter_EnumPins(BaseFilter, &EnumPins); @@ -378,7 +383,7 @@ static HRESULT WINAPI multimedia_stream_OpenFile(IAMMultiMediaStream *iface, }
if (SUCCEEDED(ret) && !(flags & AMMSF_NORENDER)) - ret = IGraphBuilder_Render(This->pFilterGraph, This->ipin); + ret = IGraphBuilder_Render(This->graph, This->ipin);
if (EnumPins) IEnumPins_Release(EnumPins); @@ -406,7 +411,7 @@ static HRESULT WINAPI multimedia_stream_Render(IAMMultiMediaStream *iface, DWORD if(dwFlags != AMMSF_NOCLOCK) return E_INVALIDARG;
- return IGraphBuilder_Render(This->pFilterGraph, This->ipin); + return IGraphBuilder_Render(This->graph, This->ipin); }
static const IAMMultiMediaStreamVtbl multimedia_stream_vtbl = diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index f9d348c6e0..511cd1eadd 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -705,20 +705,18 @@ static void test_add_stream(void)
hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(!!graph, "Expected a non-NULL graph.\n"); - if (graph) - { - hr = IGraphBuilder_EnumFilters(graph, &enum_filters); - ok(hr == S_OK, "Got hr %#x.\n", hr); - hr = IEnumFilters_Next(enum_filters, 3, filters, &count); - ok(hr == S_FALSE, "Got hr %#x.\n", hr); - ok(count == 1, "Got count %u.\n", count); - ok(filters[0] == (IBaseFilter *)stream_filter, - "Expected filter %p, got %p.\n", stream_filter, filters[0]); - IBaseFilter_Release(filters[0]); - IEnumFilters_Release(enum_filters); - IGraphBuilder_Release(graph); - } + ok(!!graph, "Expected a non-NULL graph.\n"); + + hr = IGraphBuilder_EnumFilters(graph, &enum_filters); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IEnumFilters_Next(enum_filters, 3, filters, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + ok(filters[0] == (IBaseFilter *)stream_filter, + "Expected filter %p, got %p.\n", stream_filter, filters[0]); + IBaseFilter_Release(filters[0]); + IEnumFilters_Release(enum_filters); + IGraphBuilder_Release(graph);
IMediaStreamFilter_Release(stream_filter); ref = IAMMultiMediaStream_Release(mmstream); @@ -792,10 +790,6 @@ static void test_add_stream(void) hr = IAMMultiMediaStream_GetFilter(mmstream, &stream_filter); ok(hr == S_OK, "Got hr %#x.\n", hr);
- /* 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, AMMSF_ADDDEFAULTRENDERER, &video_stream); ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); @@ -1520,6 +1514,12 @@ static void test_initialize(void) todo_wine ok(type == STREAMTYPE_READ, "Got type %u.\n", type); IMediaStream_Release(stream);
+ ret_graph = NULL; + hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &ret_graph); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!!ret_graph, "Got unexpected graph %p.\n", ret_graph); + IGraphBuilder_Release(ret_graph); + ref = IAMMultiMediaStream_Release(mmstream); ok(!ref, "Got outstanding refcount %d.\n", ref);
@@ -1589,6 +1589,12 @@ static void test_initialize(void) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(type == STREAMTYPE_READ, "Got type %u.\n", type);
+ ret_graph = NULL; + hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &ret_graph); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!!ret_graph, "Got unexpected graph %p.\n", ret_graph); + IGraphBuilder_Release(ret_graph); + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_TRANSFORM, 0, NULL); ok(hr == S_OK, "Got hr %#x.\n", hr);
@@ -1658,10 +1664,6 @@ static void test_enum_media_types(void) 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); @@ -2377,9 +2379,6 @@ static void test_audiostream_get_format(void) ULONG ref; IPin *pin;
- hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); - ok(hr == S_OK, "Got hr %#x.\n", hr); - hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, &stream); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IMediaStream_QueryInterface(stream, &IID_IAudioMediaStream, (void **)&audio_stream); @@ -2570,9 +2569,6 @@ static void test_audiostream_set_format(void)
mmstream = create_ammultimediastream();
- hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); - ok(hr == S_OK, "Got hr %#x.\n", hr); - hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, &stream); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IMediaStream_QueryInterface(stream, &IID_IAudioMediaStream, (void **)&audio_stream); @@ -2653,8 +2649,6 @@ static void test_audiostream_receive_connection(void) IPin *pin;
mmstream = create_ammultimediastream(); - hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); - ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, &stream); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IMediaStream_QueryInterface(stream, &IID_IAudioMediaStream, (void **)&audio_stream);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/multimedia.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index a14771ec75..43e3ee9057 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -364,7 +364,11 @@ static HRESULT WINAPI multimedia_stream_OpenFile(IAMMultiMediaStream *iface,
/* If Initialize was not called before, we do it here */ if (!This->graph) + { ret = IAMMultiMediaStream_Initialize(iface, STREAMTYPE_READ, 0, NULL); + if (SUCCEEDED(ret)) + ret = create_graph(This, NULL); + }
if (SUCCEEDED(ret)) ret = IGraphBuilder_AddSourceFilter(This->graph, filename, L"Source", &BaseFilter);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/multimedia.c | 2 +- dlls/amstream/tests/amstream.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index 43e3ee9057..9ca38d9fa4 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -244,7 +244,7 @@ static HRESULT WINAPI multimedia_stream_Initialize(IAMMultiMediaStream *iface,
TRACE("mmstream %p, type %u, flags %#x, graph %p.\n", mmstream, type, flags, graph);
- if (FAILED(hr = create_graph(mmstream, graph))) + if (graph && FAILED(hr = create_graph(mmstream, graph))) return hr;
mmstream->type = type; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 511cd1eadd..3555eff970 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1504,7 +1504,7 @@ static void test_initialize(void) ret_graph = (IGraphBuilder *)0xdeadbeef; hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &ret_graph); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(!ret_graph, "Got unexpected graph %p.\n", ret_graph); + ok(!ret_graph, "Got unexpected graph %p.\n", ret_graph);
hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, &stream); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -1538,7 +1538,7 @@ static void test_initialize(void) ret_graph = (IGraphBuilder *)0xdeadbeef; hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &ret_graph); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(!ret_graph, "Got unexpected graph %p.\n", ret_graph); + ok(!ret_graph, "Got unexpected graph %p.\n", ret_graph);
hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, &stream); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -1566,7 +1566,7 @@ static void test_initialize(void) ret_graph = (IGraphBuilder *)0xdeadbeef; hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &ret_graph); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(!ret_graph, "Got unexpected graph %p.\n", ret_graph); + ok(!ret_graph, "Got unexpected graph %p.\n", ret_graph);
hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, &stream); ok(hr == S_OK, "Got hr %#x.\n", hr);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/multimedia.c | 6 ++++++ dlls/amstream/tests/amstream.c | 9 +++++++++ 2 files changed, 15 insertions(+)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index 9ca38d9fa4..e62c930a39 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -244,6 +244,12 @@ static HRESULT WINAPI multimedia_stream_Initialize(IAMMultiMediaStream *iface,
TRACE("mmstream %p, type %u, flags %#x, graph %p.\n", mmstream, type, flags, graph);
+ if (graph && mmstream->graph) + { + WARN("Graph already initialized, returning E_INVALIDARG.\n"); + return E_INVALIDARG; + } + if (graph && FAILED(hr = create_graph(mmstream, graph))) return hr;
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 3555eff970..e2c00ebc3a 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1646,6 +1646,15 @@ static void test_initialize(void) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(!got_add_filter, "Got %d calls to IGraphBuilder::AddFilter().\n", got_add_filter);
+ hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, (IGraphBuilder *)&graph); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_WRITE, 0, NULL); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_TRANSFORM, 0, NULL); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + IMediaStreamFilter_Release(filter); ref = IAMMultiMediaStream_Release(mmstream); ok(!ref, "Got outstanding refcount %d.\n", ref);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/multimedia.c | 8 ++++++++ dlls/amstream/tests/amstream.c | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index e62c930a39..07c037505e 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -39,6 +39,7 @@ struct multimedia_stream IMediaControl* media_control; IMediaStreamFilter *filter; IPin* ipin; + BOOL initialized; STREAM_TYPE type; OAEVENT event; }; @@ -250,10 +251,17 @@ static HRESULT WINAPI multimedia_stream_Initialize(IAMMultiMediaStream *iface, return E_INVALIDARG; }
+ if (mmstream->initialized && type != mmstream->type) + { + WARN("Attempt to change type from %u, returning E_INVALIDARG.\n", mmstream->type); + return E_INVALIDARG; + } + if (graph && FAILED(hr = create_graph(mmstream, graph))) return hr;
mmstream->type = type; + mmstream->initialized = TRUE;
return S_OK; } diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index e2c00ebc3a..a55884d8ab 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1497,9 +1497,9 @@ static void test_initialize(void) hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_WRITE, 0, NULL); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_TRANSFORM, 0, NULL); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
ret_graph = (IGraphBuilder *)0xdeadbeef; hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &ret_graph); @@ -1511,7 +1511,7 @@ static void test_initialize(void) type = 0xdeadbeef; hr = IMediaStream_GetInformation(stream, NULL, &type); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(type == STREAMTYPE_READ, "Got type %u.\n", type); + ok(type == STREAMTYPE_READ, "Got type %u.\n", type); IMediaStream_Release(stream);
ret_graph = NULL; @@ -1531,9 +1531,9 @@ static void test_initialize(void) hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_WRITE, 0, NULL); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_TRANSFORM, 0, NULL); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
ret_graph = (IGraphBuilder *)0xdeadbeef; hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &ret_graph); @@ -1545,7 +1545,7 @@ static void test_initialize(void) type = 0xdeadbeef; hr = IMediaStream_GetInformation(stream, NULL, &type); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(type == STREAMTYPE_WRITE, "Got type %u.\n", type); + ok(type == STREAMTYPE_WRITE, "Got type %u.\n", type); IMediaStream_Release(stream);
ref = IAMMultiMediaStream_Release(mmstream); @@ -1559,9 +1559,9 @@ static void test_initialize(void) hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_TRANSFORM, 0, NULL); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_WRITE, 0, NULL); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
ret_graph = (IGraphBuilder *)0xdeadbeef; hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &ret_graph); @@ -1573,7 +1573,7 @@ static void test_initialize(void) type = 0xdeadbeef; hr = IMediaStream_GetInformation(stream, NULL, &type); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(type == STREAMTYPE_TRANSFORM, "Got type %u.\n", type); + ok(type == STREAMTYPE_TRANSFORM, "Got type %u.\n", type); IMediaStream_Release(stream);
ref = IAMMultiMediaStream_Release(mmstream); @@ -1651,9 +1651,9 @@ static void test_initialize(void) hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_WRITE, 0, NULL); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_TRANSFORM, 0, NULL); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
IMediaStreamFilter_Release(filter); ref = IAMMultiMediaStream_Release(mmstream);