Commit c5663827 authored by Tingzhong Luo's avatar Tingzhong Luo Committed by Alexandre Julliard

evr: Fix crash when clearing input type for the mixer.

parent aa3e772a
...@@ -240,7 +240,7 @@ static void video_mixer_clear_types(struct video_mixer *mixer) ...@@ -240,7 +240,7 @@ static void video_mixer_clear_types(struct video_mixer *mixer)
free(mixer->output.rt_formats); free(mixer->output.rt_formats);
if (mixer->output.media_type) if (mixer->output.media_type)
IMFMediaType_Release(mixer->output.media_type); IMFMediaType_Release(mixer->output.media_type);
mixer->output.media_type = NULL; memset(&mixer->output, 0, sizeof(mixer->output));
} }
static HRESULT WINAPI video_mixer_inner_QueryInterface(IUnknown *iface, REFIID riid, void **obj) static HRESULT WINAPI video_mixer_inner_QueryInterface(IUnknown *iface, REFIID riid, void **obj)
...@@ -855,12 +855,17 @@ static HRESULT WINAPI video_mixer_transform_SetInputType(IMFTransform *iface, DW ...@@ -855,12 +855,17 @@ static HRESULT WINAPI video_mixer_transform_SetInputType(IMFTransform *iface, DW
TRACE("%p, %lu, %p, %#lx.\n", iface, id, media_type, flags); TRACE("%p, %lu, %p, %#lx.\n", iface, id, media_type, flags);
if (!media_type && (flags & MFT_SET_TYPE_TEST_ONLY))
return E_INVALIDARG;
EnterCriticalSection(&mixer->cs); EnterCriticalSection(&mixer->cs);
if (!(flags & MFT_SET_TYPE_TEST_ONLY)) if (!(flags & MFT_SET_TYPE_TEST_ONLY))
video_mixer_clear_types(mixer); video_mixer_clear_types(mixer);
if (!mixer->device_manager) if (!media_type)
hr = S_OK;
else if (!mixer->device_manager)
hr = MF_E_NOT_INITIALIZED; hr = MF_E_NOT_INITIALIZED;
else else
{ {
......
...@@ -1249,6 +1249,11 @@ static void test_default_mixer_type_negotiation(void) ...@@ -1249,6 +1249,11 @@ static void test_default_mixer_type_negotiation(void)
goto done; goto done;
} }
hr = IMFTransform_SetInputType(transform, 0, NULL, 0);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_SetInputType(transform, 0, NULL, MFT_SET_TYPE_TEST_ONLY);
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = DXVA2CreateDirect3DDeviceManager9(&token, &manager); hr = DXVA2CreateDirect3DDeviceManager9(&token, &manager);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
...@@ -1469,9 +1474,48 @@ static void test_default_mixer_type_negotiation(void) ...@@ -1469,9 +1474,48 @@ static void test_default_mixer_type_negotiation(void)
hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type2); hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type2);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(media_type == media_type2, "Unexpected media type instance.\n"); ok(media_type == media_type2, "Unexpected media type instance.\n");
IMFMediaType_Release(media_type);
/* Clear input types */
hr = IMFTransform_SetInputType(transform, 0, NULL, MFT_SET_TYPE_TEST_ONLY);
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_SetInputType(transform, 0, NULL, 0);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_GetInputCurrentType(transform, 0, &media_type);
ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type);
ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr);
/* Restore types */
hr = IMFTransform_SetOutputType(transform, 0, media_type2, 0);
ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type);
ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_SetInputType(transform, 0, video_type, 0);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_GetInputCurrentType(transform, 0, &media_type);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(media_type == video_type, "Unexpected media type instance.\n");
IMFMediaType_Release(media_type);
hr = IMFTransform_SetOutputType(transform, 0, media_type2, 0);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(media_type2 == media_type, "Unexpected media type instance.\n");
IMFMediaType_Release(media_type2); IMFMediaType_Release(media_type2);
IMFMediaType_Release(media_type); IMFMediaType_Release(media_type);
/* Resetting type twice */
hr = IMFTransform_SetInputType(transform, 0, NULL, 0);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_SetInputType(transform, 0, NULL, 0);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
IMFVideoProcessor_Release(processor); IMFVideoProcessor_Release(processor);
IMFMediaType_Release(video_type); IMFMediaType_Release(video_type);
......
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