diff --git a/dlls/evr/presenter.c b/dlls/evr/presenter.c index 5b262e7c663..027d0338896 100644 --- a/dlls/evr/presenter.c +++ b/dlls/evr/presenter.c @@ -348,6 +348,9 @@ static HRESULT video_presenter_invalidate_media_type(struct video_presenter *pre RECT rect; HRESULT hr; + if (!presenter->mixer) + return MF_E_TRANSFORM_TYPE_NOT_SET; + if (FAILED(hr = MFCreateMediaType(&media_type))) return hr; @@ -965,7 +968,7 @@ static HRESULT WINAPI video_presenter_ProcessMessage(IMFVideoPresenter *iface, M switch (message) { case MFVP_MESSAGE_INVALIDATEMEDIATYPE: - hr = video_presenter_invalidate_media_type(presenter); + hr = presenter->mixer ? video_presenter_invalidate_media_type(presenter) : MF_E_INVALIDREQUEST; break; case MFVP_MESSAGE_BEGINSTREAMING: hr = video_presenter_start_streaming(presenter); diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c index 6fb92d9ced1..8e3288afaec 100644 --- a/dlls/evr/tests/evr.c +++ b/dlls/evr/tests/evr.c @@ -1754,12 +1754,41 @@ static void test_presenter_video_position(void) DWORD count; HWND hwnd; + hwnd = create_window(); + ok(!!hwnd, "Failed to create a test window.\n"); + + /* Setting position without the mixer. */ + hr = MFCreateVideoPresenter(NULL, &IID_IDirect3DDevice9, &IID_IMFVideoPresenter, (void **)&presenter); + ok(hr == S_OK, "Failed to create default presenter, hr %#x.\n", hr); + hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFVideoDisplayControl, (void **)&display_control); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMFVideoPresenter_ProcessMessage(presenter, MFVP_MESSAGE_INVALIDATEMEDIATYPE, 0); + ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr); + SetRect(&dst_rect, 0, 0, 10, 10); + hr = IMFVideoDisplayControl_SetVideoPosition(display_control, NULL, &dst_rect); + ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); + hr = IMFVideoDisplayControl_SetVideoWindow(display_control, hwnd); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMFVideoPresenter_ProcessMessage(presenter, MFVP_MESSAGE_INVALIDATEMEDIATYPE, 0); + ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr); + hr = IMFVideoDisplayControl_SetVideoPosition(display_control, NULL, &dst_rect); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + IMFVideoDisplayControl_Release(display_control); + IMFVideoPresenter_Release(presenter); + + /* With the mixer. */ hr = MFCreateVideoMixer(NULL, &IID_IDirect3DDevice9, &IID_IMFTransform, (void **)&mixer); ok(hr == S_OK, "Failed to create a mixer, hr %#x.\n", hr); hr = MFCreateVideoPresenter(NULL, &IID_IDirect3DDevice9, &IID_IMFVideoPresenter, (void **)&presenter); ok(hr == S_OK, "Failed to create default presenter, hr %#x.\n", hr); + hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFVideoDisplayControl, (void **)&display_control); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFTopologyServiceLookupClient, (void **)&lookup_client); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); @@ -1785,9 +1814,6 @@ static void test_presenter_video_position(void) ok(src_rect.left == 0.0f && src_rect.top == 0.0f && src_rect.right == 1.0f && src_rect.bottom == 1.0f, "Unexpected source rectangle.\n"); - hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFVideoDisplayControl, (void **)&display_control); - ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - hr = IMFVideoDisplayControl_GetVideoPosition(display_control, NULL, &dst_rect); ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); @@ -1806,9 +1832,6 @@ static void test_presenter_video_position(void) ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); /* Setting position requires a window. */ - hwnd = create_window(); - ok(!!hwnd, "Failed to create a test window.\n"); - SetRect(&dst_rect, 0, 0, 10, 10); memset(&src_rect, 0, sizeof(src_rect)); hr = IMFVideoDisplayControl_SetVideoPosition(display_control, &src_rect, &dst_rect); @@ -2297,6 +2320,44 @@ done: DestroyWindow(window); } +static void test_presenter_shutdown(void) +{ + IMFTopologyServiceLookupClient *lookup_client; + IMFVideoPresenter *presenter; + HRESULT hr; + + hr = MFCreateVideoPresenter(NULL, &IID_IDirect3DDevice9, &IID_IMFVideoPresenter, (void **)&presenter); + ok(hr == S_OK, "Failed to create default presenter, hr %#x.\n", hr); + + hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFTopologyServiceLookupClient, (void **)&lookup_client); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMFTopologyServiceLookupClient_ReleaseServicePointers(lookup_client); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMFVideoPresenter_ProcessMessage(presenter, MFVP_MESSAGE_INVALIDATEMEDIATYPE, 0); +todo_wine + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); + + hr = IMFVideoPresenter_ProcessMessage(presenter, MFVP_MESSAGE_BEGINSTREAMING, 0); +todo_wine + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); + + hr = IMFVideoPresenter_ProcessMessage(presenter, MFVP_MESSAGE_ENDSTREAMING, 0); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMFVideoPresenter_ProcessMessage(presenter, MFVP_MESSAGE_PROCESSINPUTNOTIFY, 0); +todo_wine + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); + + hr = IMFTopologyServiceLookupClient_ReleaseServicePointers(lookup_client); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + IMFTopologyServiceLookupClient_Release(lookup_client); + + IMFVideoPresenter_Release(presenter); +} + static void test_mixer_output_rectangle(void) { IMFVideoMixerControl *mixer_control; @@ -2848,6 +2909,7 @@ START_TEST(evr) test_presenter_video_window(); test_presenter_quality_control(); test_presenter_media_type(); + test_presenter_shutdown(); test_mixer_output_rectangle(); test_mixer_zorder(); test_mixer_samples();