Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/audiostream.c | 11 ++++ dlls/amstream/tests/amstream.c | 117 +++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index abc82f3a0e..f1bfb8da71 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -760,6 +760,17 @@ static HRESULT WINAPI audio_sink_ReceiveConnection(IPin *iface, IPin *peer, cons return VFW_E_INVALID_DIRECTION; }
+ if (!IsEqualGUID(&mt->majortype, &MEDIATYPE_Audio) || + !IsEqualGUID(&mt->formattype, &FORMAT_WaveFormatEx) || + !mt->pbFormat || mt->cbFormat < sizeof(WAVEFORMATEX)) + { + LeaveCriticalSection(&stream->cs); + return VFW_E_TYPE_NOT_ACCEPTED; + } + + if (!is_format_compatible(&stream->format, (const WAVEFORMATEX *)mt->pbFormat)) + return E_INVALIDARG; + CopyMediaType(&stream->mt, mt); IPin_AddRef(stream->peer = peer);
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 853949a87b..2bac733484 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -2768,6 +2768,122 @@ static void test_audiostream_set_format(void) IAMMultiMediaStream_Release(mmstream); }
+static void check_audiostream_media_type(const AM_MEDIA_TYPE *media_type, HRESULT expected_hr) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IMediaStream *stream = NULL; + IPin *pin = NULL; + HRESULT hr; + + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, &stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_ReceiveConnection(pin, &output_pin, media_type); + ok(hr == expected_hr, "Got hr %#x.\n", hr); + + if (SUCCEEDED(hr)) + { + hr = IPin_Disconnect(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + } + + IPin_Release(pin); + IMediaStream_Release(stream); + IAMMultiMediaStream_Release(mmstream); +} + +static void test_audiostream_receive_connection(void) +{ + IAMMultiMediaStream *mmstream; + IMediaStream *stream = NULL; + IAudioMediaStream *audio_stream = NULL; + IPin *pin = NULL; + WAVEFORMATPCMEX valid_format = {0}; + WAVEFORMATPCMEX format; + AM_MEDIA_TYPE valid_media_type = {0}; + AM_MEDIA_TYPE media_type; + HRESULT hr; + + valid_format.Format.wFormatTag = WAVE_FORMAT_PCM; + valid_format.Format.nChannels = 2; + valid_format.Format.nSamplesPerSec = 44100; + valid_format.Format.nAvgBytesPerSec = 176400; + valid_format.Format.nBlockAlign = 4; + valid_format.Format.wBitsPerSample = 16; + valid_format.Format.cbSize = 0; + + valid_media_type.majortype = MEDIATYPE_Audio; + valid_media_type.subtype = MEDIASUBTYPE_PCM; + valid_media_type.bFixedSizeSamples = TRUE; + valid_media_type.bTemporalCompression = FALSE; + valid_media_type.lSampleSize = 2; + valid_media_type.formattype = FORMAT_WaveFormatEx; + valid_media_type.pUnk = NULL; + valid_media_type.cbFormat = sizeof(WAVEFORMATEX); + valid_media_type.pbFormat = (BYTE *)&valid_format; + + check_audiostream_media_type(&valid_media_type, S_OK); + + media_type = valid_media_type; + media_type.majortype = GUID_NULL; + check_audiostream_media_type(&media_type, VFW_E_TYPE_NOT_ACCEPTED); + + media_type = valid_media_type; + media_type.subtype = MEDIASUBTYPE_RGB24; + check_audiostream_media_type(&media_type, S_OK); + + media_type = valid_media_type; + media_type.formattype = GUID_NULL; + check_audiostream_media_type(&media_type, VFW_E_TYPE_NOT_ACCEPTED); + + media_type = valid_media_type; + media_type.cbFormat = sizeof(WAVEFORMATEX) - 1; + check_audiostream_media_type(&media_type, VFW_E_TYPE_NOT_ACCEPTED); + + format = valid_format; + format.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; + format.Format.cbSize = 22; + format.Samples.wValidBitsPerSample = 16; + format.dwChannelMask = KSAUDIO_SPEAKER_STEREO; + format.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; + media_type = valid_media_type; + media_type.cbFormat = sizeof(format); + media_type.pbFormat = (BYTE *)&format; + check_audiostream_media_type(&media_type, E_INVALIDARG); + + mmstream = create_ammultimediastream(); + + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, &stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IAudioMediaStream, (void **)&audio_stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAudioMediaStream_SetFormat(audio_stream, &valid_format.Format); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + format = valid_format; + format.Format.nChannels = 1; + media_type = valid_media_type; + media_type.pbFormat = (BYTE *)&format; + hr = IPin_ReceiveConnection(pin, &output_pin, &media_type); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + hr = IPin_ReceiveConnection(pin, &output_pin, &valid_media_type); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_Disconnect(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + IPin_Release(pin); + IAudioMediaStream_Release(audio_stream); + IMediaStream_Release(stream); + IAMMultiMediaStream_Release(mmstream); +} + START_TEST(amstream) { HANDLE file; @@ -2803,6 +2919,7 @@ START_TEST(amstream)
test_audiostream_get_format(); test_audiostream_set_format(); + test_audiostream_receive_connection();
CoUninitialize(); } -- 2.17.1
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=65715
Your paranoid android.
=== build (build log) ===
error: corrupt patch at line 12 Task: Patch failed to apply
=== debian10 (build log) ===
error: corrupt patch at line 12 Task: Patch failed to apply
=== debian10 (build log) ===
error: corrupt patch at line 12 Task: Patch failed to apply