Commit 7dc454be authored by Connor McAdams's avatar Connor McAdams Committed by Alexandre Julliard

mfplat: Add MFCreateWaveFormatExFromMFMediaType AudioFormat_Float test.

Add test for MFAudioFormat_Float subtype being passed to MFCreateWaveFormatExFromMFMediaType. Signed-off-by: 's avatarConnor McAdams <cmcadams@codeweavers.com> Signed-off-by: 's avatarNikolay Sivov <nsivov@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 538b702c
...@@ -4240,10 +4240,20 @@ static void test_wrapped_media_type(void) ...@@ -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,45 +4271,48 @@ static void test_MFCreateWaveFormatExFromMFMediaType(void) ...@@ -4261,45 +4271,48 @@ 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);
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
hr = MFCreateWaveFormatExFromMFMediaType(mediatype, &format, &size, MFWaveFormatExConvertFlag_Normal); for (i = 0; i < ARRAY_SIZE(wave_fmt_tests); ++i)
ok(hr == S_OK, "Failed to create format, hr %#x.\n", hr); {
ok(format != NULL, "Expected format structure.\n"); hr = IMFMediaType_SetGUID(mediatype, &MF_MT_SUBTYPE, wave_fmt_tests[i].subtype);
ok(size == sizeof(*format), "Unexpected size %u.\n", size); ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
ok(format->wFormatTag == WAVE_FORMAT_PCM, "Unexpected tag.\n");
ok(format->nChannels == 0, "Unexpected number of channels, %u.\n", format->nChannels); hr = MFCreateWaveFormatExFromMFMediaType(mediatype, &format, &size, MFWaveFormatExConvertFlag_Normal);
ok(format->nSamplesPerSec == 0, "Unexpected sample rate, %u.\n", format->nSamplesPerSec); ok(hr == S_OK, "Failed to create format, hr %#x.\n", hr);
ok(format->nAvgBytesPerSec == 0, "Unexpected average data rate rate, %u.\n", format->nAvgBytesPerSec); ok(format != NULL, "Expected format structure.\n");
ok(format->nBlockAlign == 0, "Unexpected alignment, %u.\n", format->nBlockAlign); ok(size == sizeof(*format), "Unexpected size %u.\n", size);
ok(format->wBitsPerSample == 0, "Unexpected sample size, %u.\n", format->wBitsPerSample); 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->cbSize == 0, "Unexpected size field, %u.\n", format->cbSize); ok(format->nChannels == 0, "Unexpected number of channels, %u.\n", format->nChannels);
CoTaskMemFree(format); ok(format->nSamplesPerSec == 0, "Unexpected sample rate, %u.\n", format->nSamplesPerSec);
ok(format->nAvgBytesPerSec == 0, "Unexpected average data rate rate, %u.\n", format->nAvgBytesPerSec);
hr = MFCreateWaveFormatExFromMFMediaType(mediatype, (WAVEFORMATEX **)&format_ext, &size, ok(format->nBlockAlign == 0, "Unexpected alignment, %u.\n", format->nBlockAlign);
MFWaveFormatExConvertFlag_ForceExtensible); ok(format->wBitsPerSample == 0, "Unexpected sample size, %u.\n", format->wBitsPerSample);
ok(hr == S_OK, "Failed to create format, hr %#x.\n", hr); ok(format->cbSize == 0, "Unexpected size field, %u.\n", format->cbSize);
ok(format_ext != NULL, "Expected format structure.\n"); CoTaskMemFree(format);
ok(size == sizeof(*format_ext), "Unexpected size %u.\n", size);
ok(format_ext->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE, "Unexpected tag.\n"); hr = MFCreateWaveFormatExFromMFMediaType(mediatype, (WAVEFORMATEX **)&format_ext, &size,
ok(format_ext->Format.nChannels == 0, "Unexpected number of channels, %u.\n", format_ext->Format.nChannels); MFWaveFormatExConvertFlag_ForceExtensible);
ok(format_ext->Format.nSamplesPerSec == 0, "Unexpected sample rate, %u.\n", format_ext->Format.nSamplesPerSec); ok(hr == S_OK, "Failed to create format, hr %#x.\n", hr);
ok(format_ext->Format.nAvgBytesPerSec == 0, "Unexpected average data rate rate, %u.\n", ok(format_ext != NULL, "Expected format structure.\n");
format_ext->Format.nAvgBytesPerSec); ok(size == sizeof(*format_ext), "Unexpected size %u.\n", size);
ok(format_ext->Format.nBlockAlign == 0, "Unexpected alignment, %u.\n", format_ext->Format.nBlockAlign); ok(format_ext->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE, "Unexpected tag.\n");
ok(format_ext->Format.wBitsPerSample == 0, "Unexpected sample size, %u.\n", format_ext->Format.wBitsPerSample); ok(format_ext->Format.nChannels == 0, "Unexpected number of channels, %u.\n", format_ext->Format.nChannels);
ok(format_ext->Format.cbSize == sizeof(*format_ext) - sizeof(format_ext->Format), "Unexpected size field, %u.\n", ok(format_ext->Format.nSamplesPerSec == 0, "Unexpected sample rate, %u.\n", format_ext->Format.nSamplesPerSec);
format_ext->Format.cbSize); ok(format_ext->Format.nAvgBytesPerSec == 0, "Unexpected average data rate rate, %u.\n",
CoTaskMemFree(format_ext); format_ext->Format.nAvgBytesPerSec);
ok(format_ext->Format.nBlockAlign == 0, "Unexpected alignment, %u.\n", format_ext->Format.nBlockAlign);
hr = MFCreateWaveFormatExFromMFMediaType(mediatype, &format, &size, MFWaveFormatExConvertFlag_ForceExtensible + 1); ok(format_ext->Format.wBitsPerSample == 0, "Unexpected sample size, %u.\n", format_ext->Format.wBitsPerSample);
ok(hr == S_OK, "Failed to create format, hr %#x.\n", hr); ok(format_ext->Format.cbSize == sizeof(*format_ext) - sizeof(format_ext->Format), "Unexpected size field, %u.\n",
ok(size == sizeof(*format), "Unexpected size %u.\n", size); format_ext->Format.cbSize);
CoTaskMemFree(format); 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); IMFMediaType_Release(mediatype);
} }
......
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