From: Giovanni Mascellani gmascellani@codeweavers.com
So that the format selection happens before actual testing, in such a way that actual testing is then easy to move to a helper function. --- dlls/mmdevapi/tests/render.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/dlls/mmdevapi/tests/render.c b/dlls/mmdevapi/tests/render.c index 9ac82a65400..bce0a37750d 100644 --- a/dlls/mmdevapi/tests/render.c +++ b/dlls/mmdevapi/tests/render.c @@ -523,15 +523,6 @@ static void test_formats(AUDCLNT_SHAREMODE mode, BOOL extensible) for (k = 0; k < ARRAY_SIZE(sample_formats); k++) { char format_chr[3];
- hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER, - NULL, (void**)&ac); - ok(hr == S_OK, "Activation failed with %08lx\n", hr); - if(hr != S_OK) - continue; - - hr = IAudioClient_GetMixFormat(ac, &pwfx); - ok(hr == S_OK, "GetMixFormat failed: %08lx\n", hr); - fmt.Format.wFormatTag = extensible ? WAVE_FORMAT_EXTENSIBLE : sample_formats[k][0]; fmt.Format.nSamplesPerSec = sampling_rates[i]; fmt.Format.wBitsPerSample = sample_formats[k][1]; @@ -540,8 +531,6 @@ static void test_formats(AUDCLNT_SHAREMODE mode, BOOL extensible) fmt.Format.nAvgBytesPerSec= fmt.Format.nBlockAlign * fmt.Format.nSamplesPerSec;
if (extensible) { - WAVEFORMATEXTENSIBLE *pxwfx = (WAVEFORMATEXTENSIBLE*)pwfx; - fmt.Samples.wValidBitsPerSample = fmt.Format.wBitsPerSample; switch (fmt.Format.nChannels) { case 1: fmt.dwChannelMask = KSAUDIO_SPEAKER_MONO; break; @@ -550,11 +539,6 @@ static void test_formats(AUDCLNT_SHAREMODE mode, BOOL extensible) case 6: fmt.dwChannelMask = KSAUDIO_SPEAKER_5POINT1; break; case 8: fmt.dwChannelMask = KSAUDIO_SPEAKER_7POINT1_SURROUND; break; } - /* We don't want to fight with the driver over the speaker configuration, - * so just take whatever they give us, if it's valid. */ - if (fmt.Format.nChannels == pwfx->nChannels && pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE - && pxwfx->dwChannelMask != 0) - fmt.dwChannelMask = pxwfx->dwChannelMask; fmt.SubFormat = sample_formats[k][0] == WAVE_FORMAT_PCM ? KSDATAFORMAT_SUBTYPE_PCM : KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; } @@ -563,6 +547,25 @@ static void test_formats(AUDCLNT_SHAREMODE mode, BOOL extensible) format_chr[1] = extensible ? 'X' : '\0'; format_chr[2] = '\0';
+ hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER, + NULL, (void**)&ac); + ok(hr == S_OK, "Activation failed with %08lx\n", hr); + if(hr != S_OK) + continue; + + hr = IAudioClient_GetMixFormat(ac, &pwfx); + ok(hr == S_OK, "GetMixFormat failed: %08lx\n", hr); + + if (extensible) { + WAVEFORMATEXTENSIBLE *pxwfx = (WAVEFORMATEXTENSIBLE*)pwfx; + + /* We don't want to fight with the driver over the speaker configuration, + * so just take whatever they give us, if it's valid. */ + if (fmt.Format.nChannels == pwfx->nChannels && pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE + && pxwfx->dwChannelMask != 0) + fmt.dwChannelMask = pxwfx->dwChannelMask; + } + pwfx2 = (WAVEFORMATEX*)0xDEADF00D; hr = IAudioClient_IsFormatSupported(ac, mode, (WAVEFORMATEX*)&fmt, &pwfx2); hrs = hr;