Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/mediatype.c | 13 ++++++++++--- dlls/mfplat/tests/mfplat.c | 28 +++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index f3895ca4d49..62d75e80146 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -2943,6 +2943,13 @@ static void mediatype_set_guid(IMFMediaType *mediatype, const GUID *attr, const *hr = IMFMediaType_SetGUID(mediatype, attr, value); }
+static void mediatype_set_blob(IMFMediaType *mediatype, const GUID *attr, const UINT8 *data, + unsigned int size, HRESULT *hr) +{ + if (SUCCEEDED(*hr)) + *hr = IMFMediaType_SetBlob(mediatype, attr, data, size); +} + /*********************************************************************** * MFInitMediaTypeFromWaveFormatEx (mfplat.@) */ @@ -2957,9 +2964,6 @@ HRESULT WINAPI MFInitMediaTypeFromWaveFormatEx(IMFMediaType *mediatype, const WA if (!mediatype || !format) return E_POINTER;
- if (format->cbSize && format->cbSize < sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)) - return E_INVALIDARG; - if (format->cbSize + sizeof(*format) > size) return E_INVALIDARG;
@@ -3007,6 +3011,9 @@ HRESULT WINAPI MFInitMediaTypeFromWaveFormatEx(IMFMediaType *mediatype, const WA mediatype_set_uint32(mediatype, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1, &hr); }
+ if (format->cbSize) + mediatype_set_blob(mediatype, &MF_MT_USER_DATA, (const UINT8 *)(format + 1), format->cbSize, &hr); + return hr; }
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 474d6281f5f..38e8acb966e 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -5600,9 +5600,12 @@ static void test_MFInitMediaTypeFromWaveFormatEx(void) { WAVE_FORMAT_WMAUDIO_LOSSLESS }, { WAVE_FORMAT_WMASPDIF }, }; + + UINT8 buff[MPEGLAYER3_WFX_EXTRA_BYTES]; WAVEFORMATEXTENSIBLE waveformatext; + MPEGLAYER3WAVEFORMAT mp3format; IMFMediaType *mediatype; - unsigned int i; + unsigned int i, size; HRESULT hr;
hr = MFCreateMediaType(&mediatype); @@ -5628,6 +5631,29 @@ static void test_MFInitMediaTypeFromWaveFormatEx(void) validate_media_type(mediatype, &waveformatext.Format); }
+ /* MPEGLAYER3WAVEFORMAT */ + mp3format.wfx.wFormatTag = WAVE_FORMAT_MPEGLAYER3; + mp3format.wfx.nChannels = 2; + mp3format.wfx.nSamplesPerSec = 44100; + mp3format.wfx.nAvgBytesPerSec = 16000; + mp3format.wfx.nBlockAlign = 1; + mp3format.wfx.wBitsPerSample = 0; + mp3format.wfx.cbSize = MPEGLAYER3_WFX_EXTRA_BYTES; + mp3format.wID = MPEGLAYER3_ID_MPEG; + mp3format.fdwFlags = 0; + mp3format.nBlockSize = 417; + mp3format.nFramesPerBlock = 0; + mp3format.nCodecDelay = 0; + + hr = MFInitMediaTypeFromWaveFormatEx(mediatype, (WAVEFORMATEX *)&mp3format, sizeof(mp3format)); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + validate_media_type(mediatype, &mp3format.wfx); + hr = IMFMediaType_GetBlob(mediatype, &MF_MT_USER_DATA, buff, sizeof(buff), &size); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(size == mp3format.wfx.cbSize, "Unexpected size %u.\n", size); + ok(!memcmp(buff, (WAVEFORMATEX *)&mp3format + 1, size), "Unexpected user data.\n"); + IMFMediaType_Release(mediatype); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=82724
Your paranoid android.
=== wvistau64 (32 bit report) ===
mfplat: mfplat: Timeout
=== wvistau64 (64 bit report) ===
mfplat: mfplat: Timeout
=== w1064_2qxl (64 bit report) ===
mfplat: mfplat.c:2868: Test failed: Unexpected return value 0x102. mfplat.c:2224: Test failed: Failed to get event, hr 0xc00d3e85. mfplat.c:2227: Test failed: Failed to get event, hr 0xc00d3e85. mfplat.c:2230: Test failed: Failed to finalize GetEvent, hr 0xc00d3e85. mfplat.c:2233: Test failed: Unexpected result, hr 0xc00d3e85.