From 7dc454be852a63a776c5cf2d7804f0c97c24ac4a Mon Sep 17 00:00:00 2001 From: Connor McAdams Date: Wed, 21 Apr 2021 10:20:05 -0400 Subject: [PATCH] mfplat: Add MFCreateWaveFormatExFromMFMediaType AudioFormat_Float test. Add test for MFAudioFormat_Float subtype being passed to MFCreateWaveFormatExFromMFMediaType. Signed-off-by: Connor McAdams Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/mfplat/tests/mfplat.c | 83 ++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 35 deletions(-) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index caf6f78d9e9..b6468b5da9b 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -4240,10 +4240,20 @@ static void test_wrapped_media_type(void) static void test_MFCreateWaveFormatExFromMFMediaType(void) { + static const struct wave_fmt_test + { + const GUID *subtype; + WORD format_tag; + } + wave_fmt_tests[] = + { + { &MFAudioFormat_PCM, WAVE_FORMAT_PCM, }, + { &MFAudioFormat_Float, WAVE_FORMAT_IEEE_FLOAT, }, + }; WAVEFORMATEXTENSIBLE *format_ext; IMFMediaType *mediatype; WAVEFORMATEX *format; - UINT32 size; + UINT32 size, i; HRESULT hr; hr = MFCreateMediaType(&mediatype); @@ -4261,45 +4271,48 @@ static void test_MFCreateWaveFormatExFromMFMediaType(void) hr = IMFMediaType_SetGUID(mediatype, &MF_MT_SUBTYPE, &MFMediaType_Video); ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr); - /* Audio/PCM */ hr = IMFMediaType_SetGUID(mediatype, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr); - hr = IMFMediaType_SetGUID(mediatype, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); - ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr); - hr = MFCreateWaveFormatExFromMFMediaType(mediatype, &format, &size, MFWaveFormatExConvertFlag_Normal); - ok(hr == S_OK, "Failed to create format, hr %#x.\n", hr); - ok(format != NULL, "Expected format structure.\n"); - ok(size == sizeof(*format), "Unexpected size %u.\n", size); - ok(format->wFormatTag == WAVE_FORMAT_PCM, "Unexpected tag.\n"); - ok(format->nChannels == 0, "Unexpected number of channels, %u.\n", format->nChannels); - ok(format->nSamplesPerSec == 0, "Unexpected sample rate, %u.\n", format->nSamplesPerSec); - ok(format->nAvgBytesPerSec == 0, "Unexpected average data rate rate, %u.\n", format->nAvgBytesPerSec); - ok(format->nBlockAlign == 0, "Unexpected alignment, %u.\n", format->nBlockAlign); - ok(format->wBitsPerSample == 0, "Unexpected sample size, %u.\n", format->wBitsPerSample); - ok(format->cbSize == 0, "Unexpected size field, %u.\n", format->cbSize); - CoTaskMemFree(format); + for (i = 0; i < ARRAY_SIZE(wave_fmt_tests); ++i) + { + hr = IMFMediaType_SetGUID(mediatype, &MF_MT_SUBTYPE, wave_fmt_tests[i].subtype); + ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr); - hr = MFCreateWaveFormatExFromMFMediaType(mediatype, (WAVEFORMATEX **)&format_ext, &size, - MFWaveFormatExConvertFlag_ForceExtensible); - ok(hr == S_OK, "Failed to create format, hr %#x.\n", hr); - ok(format_ext != NULL, "Expected format structure.\n"); - ok(size == sizeof(*format_ext), "Unexpected size %u.\n", size); - ok(format_ext->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE, "Unexpected tag.\n"); - ok(format_ext->Format.nChannels == 0, "Unexpected number of channels, %u.\n", format_ext->Format.nChannels); - ok(format_ext->Format.nSamplesPerSec == 0, "Unexpected sample rate, %u.\n", format_ext->Format.nSamplesPerSec); - ok(format_ext->Format.nAvgBytesPerSec == 0, "Unexpected average data rate rate, %u.\n", - format_ext->Format.nAvgBytesPerSec); - ok(format_ext->Format.nBlockAlign == 0, "Unexpected alignment, %u.\n", format_ext->Format.nBlockAlign); - ok(format_ext->Format.wBitsPerSample == 0, "Unexpected sample size, %u.\n", format_ext->Format.wBitsPerSample); - ok(format_ext->Format.cbSize == sizeof(*format_ext) - sizeof(format_ext->Format), "Unexpected size field, %u.\n", - format_ext->Format.cbSize); - CoTaskMemFree(format_ext); + hr = MFCreateWaveFormatExFromMFMediaType(mediatype, &format, &size, MFWaveFormatExConvertFlag_Normal); + ok(hr == S_OK, "Failed to create format, hr %#x.\n", hr); + ok(format != NULL, "Expected format structure.\n"); + ok(size == sizeof(*format), "Unexpected size %u.\n", size); + ok(format->wFormatTag == wave_fmt_tests[i].format_tag, "Expected tag %u, got %u.\n", wave_fmt_tests[i].format_tag, format->wFormatTag); + ok(format->nChannels == 0, "Unexpected number of channels, %u.\n", format->nChannels); + ok(format->nSamplesPerSec == 0, "Unexpected sample rate, %u.\n", format->nSamplesPerSec); + ok(format->nAvgBytesPerSec == 0, "Unexpected average data rate rate, %u.\n", format->nAvgBytesPerSec); + ok(format->nBlockAlign == 0, "Unexpected alignment, %u.\n", format->nBlockAlign); + ok(format->wBitsPerSample == 0, "Unexpected sample size, %u.\n", format->wBitsPerSample); + ok(format->cbSize == 0, "Unexpected size field, %u.\n", format->cbSize); + CoTaskMemFree(format); - hr = MFCreateWaveFormatExFromMFMediaType(mediatype, &format, &size, MFWaveFormatExConvertFlag_ForceExtensible + 1); - ok(hr == S_OK, "Failed to create format, hr %#x.\n", hr); - ok(size == sizeof(*format), "Unexpected size %u.\n", size); - CoTaskMemFree(format); + hr = MFCreateWaveFormatExFromMFMediaType(mediatype, (WAVEFORMATEX **)&format_ext, &size, + MFWaveFormatExConvertFlag_ForceExtensible); + ok(hr == S_OK, "Failed to create format, hr %#x.\n", hr); + ok(format_ext != NULL, "Expected format structure.\n"); + ok(size == sizeof(*format_ext), "Unexpected size %u.\n", size); + ok(format_ext->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE, "Unexpected tag.\n"); + ok(format_ext->Format.nChannels == 0, "Unexpected number of channels, %u.\n", format_ext->Format.nChannels); + ok(format_ext->Format.nSamplesPerSec == 0, "Unexpected sample rate, %u.\n", format_ext->Format.nSamplesPerSec); + ok(format_ext->Format.nAvgBytesPerSec == 0, "Unexpected average data rate rate, %u.\n", + format_ext->Format.nAvgBytesPerSec); + ok(format_ext->Format.nBlockAlign == 0, "Unexpected alignment, %u.\n", format_ext->Format.nBlockAlign); + ok(format_ext->Format.wBitsPerSample == 0, "Unexpected sample size, %u.\n", format_ext->Format.wBitsPerSample); + ok(format_ext->Format.cbSize == sizeof(*format_ext) - sizeof(format_ext->Format), "Unexpected size field, %u.\n", + format_ext->Format.cbSize); + CoTaskMemFree(format_ext); + + hr = MFCreateWaveFormatExFromMFMediaType(mediatype, &format, &size, MFWaveFormatExConvertFlag_ForceExtensible + 1); + ok(hr == S_OK, "Failed to create format, hr %#x.\n", hr); + ok(size == sizeof(*format), "Unexpected size %u.\n", size); + CoTaskMemFree(format); + } IMFMediaType_Release(mediatype); }