mp3dmod: Verify the format type in IMediaObject::SetOutputType().

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-02-24 23:36:15 -06:00 committed by Alexandre Julliard
parent 6d55954b46
commit 690fbf64b8
2 changed files with 29 additions and 0 deletions

View file

@ -266,6 +266,9 @@ static HRESULT WINAPI MediaObject_SetOutputType(IMediaObject *iface, DWORD index
return S_OK;
}
if (!IsEqualGUID(&type->formattype, &WMFORMAT_WaveFormatEx))
return DMO_E_TYPE_NOT_ACCEPTED;
format = (WAVEFORMATEX *)type->pbFormat;
if (format->wBitsPerSample == 8)

View file

@ -394,6 +394,21 @@ static void test_media_types(void)
.nSamplesPerSec = 48000,
};
WAVEFORMATEX output_format =
{
.nChannels = 1,
.nSamplesPerSec = 48000,
.nAvgBytesPerSec = 48000,
.nBlockAlign = 1,
.wBitsPerSample = 8,
};
DMO_MEDIA_TYPE output_mt =
{
.formattype = FORMAT_WaveFormatEx,
.cbFormat = sizeof(output_format),
.pbFormat = (BYTE *)&output_format,
};
DMO_MEDIA_TYPE mt;
IMediaObject *dmo;
HRESULT hr;
@ -514,6 +529,17 @@ static void test_media_types(void)
hr = IMediaObject_GetOutputType(dmo, 0, 2, &mt);
ok(hr == DMO_E_NO_MORE_ITEMS, "Got hr %#x.\n", hr);
hr = IMediaObject_SetOutputType(dmo, 0, &output_mt, DMO_SET_TYPEF_TEST_ONLY);
ok(hr == S_OK, "Got hr %#x.\n", hr);
output_mt.formattype = GUID_NULL;
hr = IMediaObject_SetOutputType(dmo, 0, &output_mt, DMO_SET_TYPEF_TEST_ONLY);
ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr);
output_mt.formattype = FORMAT_None;
hr = IMediaObject_SetOutputType(dmo, 0, &output_mt, DMO_SET_TYPEF_TEST_ONLY);
ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr);
output_mt.formattype = FORMAT_WaveFormatEx;
IMediaObject_Release(dmo);
}