From bdf860033860973bf2b516a1083d5bea86ad8c14 Mon Sep 17 00:00:00 2001 From: Gijs Vermeulen Date: Thu, 6 Aug 2020 20:32:30 +0200 Subject: [PATCH] amstream: Return VFW_E_CANNOT_CONNECT in IAMMultiMediaStream::OpenFile() when no renderers are present and AMMSF_NORENDER is not specified. Signed-off-by: Gijs Vermeulen Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/amstream/multimedia.c | 17 ++++++++++++++- dlls/amstream/tests/amstream.c | 38 ++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index 414a903cf20..5425ef42a37 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -447,7 +447,22 @@ static HRESULT WINAPI multimedia_stream_OpenFile(IAMMultiMediaStream *iface, } if (SUCCEEDED(ret) && !(flags & AMMSF_NORENDER)) - ret = IGraphBuilder_Render(This->graph, This->ipin); + { + IFilterGraph2 *graph; + + if (SUCCEEDED(ret = IGraphBuilder_QueryInterface(This->graph, &IID_IFilterGraph2, (void **)&graph))) + { + ret = IFilterGraph2_RenderEx(graph, This->ipin, AM_RENDEREX_RENDERTOEXISTINGRENDERERS, NULL); + if (ret == VFW_E_CANNOT_RENDER) ret = VFW_E_CANNOT_CONNECT; + else if (ret == VFW_S_PARTIAL_RENDER) ret = S_OK; + IFilterGraph2_Release(graph); + } + else + { + FIXME("Failed to get IFilterGraph2 interface, hr %#x.\n", ret); + ret = IGraphBuilder_Render(This->graph, This->ipin); + } + } IMediaStreamFilter_SupportSeeking(This->filter, This->type == STREAMTYPE_READ); diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 910ab11f525..6a72f3ed891 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -283,13 +283,47 @@ static void test_openfile(const WCHAR *test_avi_path) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(!graph, "Expected NULL graph.\n"); + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); + ok(!!filter, "Expected non-NULL filter.\n"); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + check_interface(filter, &IID_IMediaSeeking, FALSE); + hr = IAMMultiMediaStream_OpenFile(mmstream, test_avi_path, AMMSF_NORENDER); ok(hr == S_OK, "Got hr %#x.\n", hr); + check_interface(filter, &IID_IMediaSeeking, FALSE); + hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(!!graph, "Expected non-NULL graph.\n"); IGraphBuilder_Release(graph); + IMediaStreamFilter_Release(filter); + + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + + mmstream = create_ammultimediastream(); + hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!graph, "Expected NULL graph.\n"); + + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); + ok(!!filter, "Expected non-NULL filter.\n"); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + check_interface(filter, &IID_IMediaSeeking, FALSE); + + hr = IAMMultiMediaStream_OpenFile(mmstream, test_avi_path, 0); + ok(hr == VFW_E_CANNOT_CONNECT, "Got hr %#x.\n", hr); + + check_interface(filter, &IID_IMediaSeeking, FALSE); + + hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!!graph, "Expected non-NULL graph.\n"); + IGraphBuilder_Release(graph); + IMediaStreamFilter_Release(filter); ref = IAMMultiMediaStream_Release(mmstream); ok(!ref, "Got outstanding refcount %d.\n", ref); @@ -389,12 +423,12 @@ static void test_mmstream_get_duration(const WCHAR *test_avi_path) mmstream = create_ammultimediastream(); hr = IAMMultiMediaStream_OpenFile(mmstream, test_avi_path, 0); - todo_wine ok(hr == VFW_E_CANNOT_CONNECT, "Got hr %#x.\n", hr); + ok(hr == VFW_E_CANNOT_CONNECT, "Got hr %#x.\n", hr); duration = 0xdeadbeefdeadbeefULL; hr = IAMMultiMediaStream_GetDuration(mmstream, &duration); todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); - todo_wine ok(duration == 0, "Got duration %s.\n", wine_dbgstr_longlong(duration)); + ok(duration == 0, "Got duration %s.\n", wine_dbgstr_longlong(duration)); ref = IAMMultiMediaStream_Release(mmstream); ok(!ref, "Got outstanding refcount %d.\n", ref);