mfplat: Add MFCreateWaveFormatExFromMFMediaType AudioFormat_Float test.

Add test for MFAudioFormat_Float subtype being passed to
MFCreateWaveFormatExFromMFMediaType.

Signed-off-by: Connor McAdams <cmcadams@codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Connor McAdams 2021-04-21 10:20:05 -04:00 committed by Alexandre Julliard
parent 538b702c87
commit 7dc454be85
1 changed files with 48 additions and 35 deletions

View File

@ -4240,10 +4240,20 @@ static void test_wrapped_media_type(void)
static void test_MFCreateWaveFormatExFromMFMediaType(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; WAVEFORMATEXTENSIBLE *format_ext;
IMFMediaType *mediatype; IMFMediaType *mediatype;
WAVEFORMATEX *format; WAVEFORMATEX *format;
UINT32 size; UINT32 size, i;
HRESULT hr; HRESULT hr;
hr = MFCreateMediaType(&mediatype); hr = MFCreateMediaType(&mediatype);
@ -4261,17 +4271,19 @@ static void test_MFCreateWaveFormatExFromMFMediaType(void)
hr = IMFMediaType_SetGUID(mediatype, &MF_MT_SUBTYPE, &MFMediaType_Video); hr = IMFMediaType_SetGUID(mediatype, &MF_MT_SUBTYPE, &MFMediaType_Video);
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr); ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
/* Audio/PCM */
hr = IMFMediaType_SetGUID(mediatype, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); hr = IMFMediaType_SetGUID(mediatype, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr); ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
hr = IMFMediaType_SetGUID(mediatype, &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
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); ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
hr = MFCreateWaveFormatExFromMFMediaType(mediatype, &format, &size, MFWaveFormatExConvertFlag_Normal); hr = MFCreateWaveFormatExFromMFMediaType(mediatype, &format, &size, MFWaveFormatExConvertFlag_Normal);
ok(hr == S_OK, "Failed to create format, hr %#x.\n", hr); ok(hr == S_OK, "Failed to create format, hr %#x.\n", hr);
ok(format != NULL, "Expected format structure.\n"); ok(format != NULL, "Expected format structure.\n");
ok(size == sizeof(*format), "Unexpected size %u.\n", size); ok(size == sizeof(*format), "Unexpected size %u.\n", size);
ok(format->wFormatTag == WAVE_FORMAT_PCM, "Unexpected tag.\n"); 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->nChannels == 0, "Unexpected number of channels, %u.\n", format->nChannels);
ok(format->nSamplesPerSec == 0, "Unexpected sample rate, %u.\n", format->nSamplesPerSec); 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->nAvgBytesPerSec == 0, "Unexpected average data rate rate, %u.\n", format->nAvgBytesPerSec);
@ -4300,6 +4312,7 @@ static void test_MFCreateWaveFormatExFromMFMediaType(void)
ok(hr == S_OK, "Failed to create format, hr %#x.\n", hr); ok(hr == S_OK, "Failed to create format, hr %#x.\n", hr);
ok(size == sizeof(*format), "Unexpected size %u.\n", size); ok(size == sizeof(*format), "Unexpected size %u.\n", size);
CoTaskMemFree(format); CoTaskMemFree(format);
}
IMFMediaType_Release(mediatype); IMFMediaType_Release(mediatype);
} }