2 * Copyright 2010 Maarten Lankhorst for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 /* This test is for audio capture specific mechanisms
21 * - IAudioClient with eCapture and IAudioCaptureClient
26 #include "wine/test.h"
36 #include "mmdeviceapi.h"
37 #include "audioclient.h"
39 #define NULL_PTR_ERR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, RPC_X_NULL_REF_POINTER)
41 static IMMDevice *dev = NULL;
43 static void test_uninitialized(IAudioClient *ac)
49 HANDLE handle = CreateEventW(NULL, FALSE, FALSE, NULL);
52 hr = IAudioClient_GetBufferSize(ac, &num);
53 ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized GetBufferSize call returns %08x\n", hr);
55 hr = IAudioClient_GetStreamLatency(ac, &t1);
56 ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized GetStreamLatency call returns %08x\n", hr);
58 hr = IAudioClient_GetCurrentPadding(ac, &num);
59 ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized GetCurrentPadding call returns %08x\n", hr);
61 hr = IAudioClient_Start(ac);
62 ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized Start call returns %08x\n", hr);
64 hr = IAudioClient_Stop(ac);
65 ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized Stop call returns %08x\n", hr);
67 hr = IAudioClient_Reset(ac);
68 ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized Reset call returns %08x\n", hr);
70 hr = IAudioClient_SetEventHandle(ac, handle);
71 ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized SetEventHandle call returns %08x\n", hr);
73 hr = IAudioClient_GetService(ac, &IID_IAudioStreamVolume, (void**)&unk);
74 ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized GetService call returns %08x\n", hr);
79 static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx)
81 IAudioCaptureClient *acc;
83 UINT32 frames, next, pad, sum = 0;
87 REFERENCE_TIME period;
89 hr = IAudioClient_GetService(ac, &IID_IAudioCaptureClient, (void**)&acc);
90 ok(hr == S_OK, "IAudioClient_GetService(IID_IAudioCaptureClient) returns %08x\n", hr);
95 data = (void*)0xdeadf00d;
97 pos = qpc = 0xdeadbeef;
98 hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, &flags, &pos, &qpc);
99 ok(hr == AUDCLNT_S_BUFFER_EMPTY, "Initial IAudioCaptureClient_GetBuffer returns %08x\n", hr);
101 /* should be empty right after start. Otherwise consume one packet */
103 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
104 ok(hr == S_OK, "Releasing buffer returns %08x\n", hr);
108 data = (void*)0xdeadf00d;
110 pos = qpc = 0xdeadbeef;
111 hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, &flags, &pos, &qpc);
112 ok(hr == AUDCLNT_S_BUFFER_EMPTY, "Initial IAudioCaptureClient_GetBuffer returns %08x\n", hr);
115 if(hr == AUDCLNT_S_BUFFER_EMPTY){
116 ok(!frames, "frames changed to %u\n", frames);
117 ok(data == (void*)0xdeadf00d, "data changed to %p\n", data);
118 ok(flags == 0xabadcafe, "flags changed to %x\n", flags);
119 ok(pos == 0xdeadbeef, "position changed to %u\n", (UINT)pos);
120 ok(qpc == 0xdeadbeef, "timer changed to %u\n", (UINT)qpc);
122 /* GetNextPacketSize yields 0 if no data is yet available
123 * it is not constantly period_size * SamplesPerSec */
124 hr = IAudioCaptureClient_GetNextPacketSize(acc, &next);
125 ok(hr == S_OK, "IAudioCaptureClient_GetNextPacketSize returns %08x\n", hr);
126 ok(!next, "GetNextPacketSize %u\n", next);
129 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
130 ok(hr == S_OK, "Releasing buffer returns %08x\n", hr);
133 ok(ResetEvent(handle), "ResetEvent\n");
135 hr = IAudioCaptureClient_GetNextPacketSize(acc, &next);
136 ok(hr == S_OK, "IAudioCaptureClient_GetNextPacketSize returns %08x\n", hr);
138 hr = IAudioClient_GetCurrentPadding(ac, &pad);
139 ok(hr == S_OK, "GetCurrentPadding call returns %08x\n", hr);
140 ok(next == pad, "GetNextPacketSize %u vs. GCP %u\n", next, pad);
141 /* later GCP will grow, while GNPS is 0 or period size */
143 hr = IAudioCaptureClient_GetNextPacketSize(acc, NULL);
144 ok(hr == E_POINTER, "IAudioCaptureClient_GetNextPacketSize(NULL) returns %08x\n", hr);
146 data = (void*)0xdeadf00d;
149 hr = IAudioCaptureClient_GetBuffer(acc, &data, NULL, NULL, NULL, NULL);
150 ok(hr == E_POINTER, "IAudioCaptureClient_GetBuffer(data, NULL, NULL) returns %08x\n", hr);
152 hr = IAudioCaptureClient_GetBuffer(acc, NULL, &frames, NULL, NULL, NULL);
153 ok(hr == E_POINTER, "IAudioCaptureClient_GetBuffer(NULL, &frames, NULL) returns %08x\n", hr);
155 hr = IAudioCaptureClient_GetBuffer(acc, NULL, NULL, &flags, NULL, NULL);
156 ok(hr == E_POINTER, "IAudioCaptureClient_GetBuffer(NULL, NULL, &flags) returns %08x\n", hr);
158 hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, NULL, NULL, NULL);
159 ok(hr == E_POINTER, "IAudioCaptureClient_GetBuffer(&ata, &frames, NULL) returns %08x\n", hr);
160 ok((DWORD_PTR)data == 0xdeadf00d, "data is reset to %p\n", data);
161 ok(frames == 0xdeadbeef, "frames is reset to %08x\n", frames);
162 ok(flags == 0xabadcafe, "flags is reset to %08x\n", flags);
164 hr = IAudioClient_GetDevicePeriod(ac, &period, NULL);
165 ok(hr == S_OK, "GetDevicePeriod failed: %08x\n", hr);
166 period = MulDiv(period, wfx->nSamplesPerSec, 10000000); /* as in render.c */
168 ok(WaitForSingleObject(handle, 1000) == WAIT_OBJECT_0, "Waiting on event handle failed!\n");
170 data = (void*)0xdeadf00d;
171 hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, &flags, &pos, &qpc);
172 ok(hr == S_OK || hr == AUDCLNT_S_BUFFER_EMPTY, "Valid IAudioCaptureClient_GetBuffer returns %08x\n", hr);
174 ok(frames, "Amount of frames locked is 0!\n");
175 /* broken: some w7 machines return pad == 0 and DATA_DISCONTINUITY here,
176 * AUDCLNT_S_BUFFER_EMPTY above, yet pos == 1-2 * period rather than 0 */
177 ok(pos == sum || broken(pos == period || pos == 2*period),
178 "Position %u expected %u\n", (UINT)pos, sum);
180 }else if (hr == AUDCLNT_S_BUFFER_EMPTY){
181 ok(!frames, "Amount of frames locked with empty buffer is %u!\n", frames);
182 ok(data == (void*)0xdeadf00d, "No data changed to %p\n", data);
185 trace("Wait'ed position %d pad %u flags %x, amount of frames locked: %u\n",
186 hr==S_OK ? (UINT)pos : -1, pad, flags, frames);
188 hr = IAudioCaptureClient_GetNextPacketSize(acc, &next);
189 ok(hr == S_OK, "IAudioCaptureClient_GetNextPacketSize returns %08x\n", hr);
190 ok(next == frames, "GetNextPacketSize %u vs. GetBuffer %u\n", next, frames);
192 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
193 ok(hr == S_OK, "Releasing buffer returns %08x\n", hr);
195 hr = IAudioCaptureClient_ReleaseBuffer(acc, 0);
196 ok(hr == S_OK, "Releasing 0 returns %08x\n", hr);
198 hr = IAudioCaptureClient_GetNextPacketSize(acc, &next);
199 ok(hr == S_OK, "IAudioCaptureClient_GetNextPacketSize returns %08x\n", hr);
202 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
203 ok(hr == AUDCLNT_E_OUT_OF_ORDER, "Releasing buffer twice returns %08x\n", hr);
207 Sleep(350); /* for sure there's data now */
209 hr = IAudioClient_GetCurrentPadding(ac, &pad);
210 ok(hr == S_OK, "GetCurrentPadding call returns %08x\n", hr);
212 /** GetNextPacketSize
213 * returns either 0 or one period worth of frames
214 * whereas GetCurrentPadding grows when input is not consumed. */
215 hr = IAudioCaptureClient_GetNextPacketSize(acc, &next);
216 ok(hr == S_OK, "IAudioCaptureClient_GetNextPacketSize returns %08x\n", hr);
217 ok(next < pad, "GetNextPacketSize %u vs. GCP %u\n", next, pad);
219 hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, &flags, &pos, &qpc);
220 ok(hr == S_OK, "Valid IAudioCaptureClient_GetBuffer returns %08x\n", hr);
221 ok(next == frames, "GetNextPacketSize %u vs. GetBuffer %u\n", next, frames);
224 UINT32 frames2 = frames;
226 ok(frames, "Amount of frames locked is 0!\n");
227 ok(pos == sum, "Position %u expected %u\n", (UINT)pos, sum);
229 hr = IAudioCaptureClient_ReleaseBuffer(acc, 0);
230 ok(hr == S_OK, "Releasing 0 returns %08x\n", hr);
232 /* GCP did not decrement, no data consumed */
233 hr = IAudioClient_GetCurrentPadding(ac, &frames);
234 ok(hr == S_OK, "GetCurrentPadding call returns %08x\n", hr);
235 ok(frames == pad || frames == pad + next /* concurrent feeder */,
236 "GCP %u past ReleaseBuffer(0) initially %u\n", frames, pad);
238 /* should re-get the same data */
239 hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, &flags, &pos2, &qpc2);
240 ok(hr == S_OK, "Valid IAudioCaptureClient_GetBuffer returns %08x\n", hr);
241 ok(frames2 == frames, "GetBuffer after ReleaseBuffer(0) %u/%u\n", frames2, frames);
242 ok(pos2 == pos, "Position after ReleaseBuffer(0) %u/%u\n", (UINT)pos2, (UINT)pos);
243 todo_wine ok(qpc2 == qpc, "HPC after ReleaseBuffer(0) %u vs. %u\n", (UINT)qpc2, (UINT)qpc);
246 /* trace after the GCP test because log output to MS-DOS console disturbs timing */
247 trace("Sleep.1 position %d pad %u flags %x, amount of frames locked: %u\n",
248 hr==S_OK ? (UINT)pos : -1, pad, flags, frames);
251 UINT32 frames2 = 0xabadcafe;
252 BYTE *data2 = (void*)0xdeadf00d;
255 ok(pos == sum, "Position %u expected %u\n", (UINT)pos, sum);
257 pos = qpc = 0xdeadbeef;
258 hr = IAudioCaptureClient_GetBuffer(acc, &data2, &frames2, &flags, &pos, &qpc);
259 ok(hr == AUDCLNT_E_OUT_OF_ORDER, "Out of order IAudioCaptureClient_GetBuffer returns %08x\n", hr);
260 ok(frames2 == 0xabadcafe, "Out of order frames changed to %x\n", frames2);
261 ok(data2 == (void*)0xdeadf00d, "Out of order data changed to %p\n", data2);
262 ok(flags == 0xabadcafe, "Out of order flags changed to %x\n", flags);
263 ok(pos == 0xdeadbeef, "Out of order position changed to %x\n", (UINT)pos);
264 ok(qpc == 0xdeadbeef, "Out of order timer changed to %x\n", (UINT)qpc);
266 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames+1);
267 ok(hr == AUDCLNT_E_INVALID_SIZE, "Releasing buffer+1 returns %08x\n", hr);
269 hr = IAudioCaptureClient_ReleaseBuffer(acc, 1);
270 ok(hr == AUDCLNT_E_INVALID_SIZE, "Releasing 1 returns %08x\n", hr);
272 hr = IAudioClient_Reset(ac);
273 ok(hr == AUDCLNT_E_NOT_STOPPED, "Reset failed: %08x\n", hr);
276 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
277 ok(hr == S_OK, "Releasing buffer returns %08x\n", hr);
281 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
282 ok(hr == AUDCLNT_E_OUT_OF_ORDER, "Releasing buffer twice returns %08x\n", hr);
286 ok(next == frames, "GetNextPacketSize %u vs. GetDevicePeriod %u\n", next, frames);
288 /* GetBufferSize is not a multiple of the period size! */
289 hr = IAudioClient_GetBufferSize(ac, &next);
290 ok(hr == S_OK, "GetBufferSize failed: %08x\n", hr);
291 trace("GetBufferSize %u period size %u\n", next, frames);
293 Sleep(400); /* overrun */
295 hr = IAudioClient_GetCurrentPadding(ac, &pad);
296 ok(hr == S_OK, "GetCurrentPadding call returns %08x\n", hr);
298 hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, &flags, &pos, &qpc);
299 ok(hr == S_OK, "Valid IAudioCaptureClient_GetBuffer returns %08x\n", hr);
301 trace("Overrun position %d pad %u flags %x, amount of frames locked: %u\n",
302 hr==S_OK ? (UINT)pos : -1, pad, flags, frames);
305 /* The discontinuity is reported here, but is this an old or new packet? */
306 todo_wine ok(flags & AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY, "expect DISCONTINUITY %x\n", flags);
307 ok(pad == next, "GCP %u vs. BufferSize %u\n", (UINT32)pad, next);
309 /* Native's position is one period further than what we read.
310 * Perhaps that's precisely the meaning of DATA_DISCONTINUITY:
311 * signal when the position jump left a gap. */
312 todo_wine ok(pos == sum + frames, "Position %u gap %d\n",
313 (UINT)pos, (UINT)pos - sum);
314 if(flags & AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY)
318 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
319 ok(hr == S_OK, "Releasing buffer returns %08x\n", hr);
322 hr = IAudioClient_GetCurrentPadding(ac, &pad);
323 ok(hr == S_OK, "GetCurrentPadding call returns %08x\n", hr);
325 hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, &flags, &pos, &qpc);
326 ok(hr == S_OK, "Valid IAudioCaptureClient_GetBuffer returns %08x\n", hr);
328 trace("Cont'ed position %d pad %u flags %x, amount of frames locked: %u\n",
329 hr==S_OK ? (UINT)pos : -1, pad, flags, frames);
332 ok(pos == sum, "Position %u expected %u\n", (UINT)pos, sum);
333 ok(!flags, "flags %u\n", flags);
335 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
336 ok(hr == S_OK, "Releasing buffer returns %08x\n", hr);
340 hr = IAudioClient_Stop(ac);
341 ok(hr == S_OK, "Stop on a started stream returns %08x\n", hr);
343 hr = IAudioClient_Start(ac);
344 ok(hr == S_OK, "Start on a stopped stream returns %08x\n", hr);
346 hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, &flags, &pos, &qpc);
347 ok(hr == S_OK, "Valid IAudioCaptureClient_GetBuffer returns %08x\n", hr);
349 hr = IAudioClient_GetCurrentPadding(ac, &pad);
350 ok(hr == S_OK, "GetCurrentPadding call returns %08x\n", hr);
352 trace("Restart position %d pad %u flags %x, amount of frames locked: %u\n",
353 hr==S_OK ? (UINT)pos : -1, pad, flags, frames);
354 ok(pad > sum, "restarted GCP %u\n", pad); /* GCP is still near buffer size */
357 ok(pos == sum, "Position %u expected %u\n", (UINT)pos, sum);
358 ok(!flags, "flags %u\n", flags);
360 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
361 ok(hr == S_OK, "Releasing buffer returns %08x\n", hr);
365 hr = IAudioClient_Stop(ac);
366 ok(hr == S_OK, "Stop on a started stream returns %08x\n", hr);
368 hr = IAudioClient_Reset(ac);
369 ok(hr == S_OK, "Reset on a stopped stream returns %08x\n", hr);
372 hr = IAudioClient_Start(ac);
373 ok(hr == S_OK, "Start on a stopped stream returns %08x\n", hr);
375 hr = IAudioClient_GetCurrentPadding(ac, &pad);
376 ok(hr == S_OK, "GetCurrentPadding call returns %08x\n", hr);
379 hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, &flags, &pos, &qpc);
380 ok(hr == AUDCLNT_S_BUFFER_EMPTY || /*PulseAudio*/hr == S_OK,
381 "Initial IAudioCaptureClient_GetBuffer returns %08x\n", hr);
383 trace("Reset position %d pad %u flags %x, amount of frames locked: %u\n",
384 hr==S_OK ? (UINT)pos : -1, pad, flags, frames);
387 /* Only PulseAudio goes here; despite snd_pcm_drop it manages
388 * to fill GetBufferSize with a single snd_pcm_read */
389 trace("Test marked todo: only PulseAudio gets here\n");
390 todo_wine ok(flags & AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY, "expect DISCONTINUITY %x\n", flags);
391 /* Reset zeroes padding, not the position */
392 ok(pos >= sum, "Position %u last %u\n", (UINT)pos, sum);
393 /*sum = pos; check after next GetBuffer */
395 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
396 ok(hr == S_OK, "Releasing buffer returns %08x\n", hr);
399 else if(hr == AUDCLNT_S_BUFFER_EMPTY){
400 ok(!pad, "resetted GCP %u\n", pad);
404 hr = IAudioClient_GetCurrentPadding(ac, &pad);
405 ok(hr == S_OK, "GetCurrentPadding call returns %08x\n", hr);
407 hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, &flags, &pos, &qpc);
408 ok(hr == S_OK, "Valid IAudioCaptureClient_GetBuffer returns %08x\n", hr);
409 trace("Running position %d pad %u flags %x, amount of frames locked: %u\n",
410 hr==S_OK ? (UINT)pos : -1, pad, flags, frames);
413 /* Some w7 machines signal DATA_DISCONTINUITY here following the
414 * previous AUDCLNT_S_BUFFER_EMPTY, others not. What logic? */
415 ok(pos >= sum, "Position %u gap %d\n", (UINT)pos, (UINT)pos - sum);
418 IUnknown_Release(acc);
421 static void test_audioclient(void)
427 WAVEFORMATEX *pwfx, *pwfx2;
428 REFERENCE_TIME t1, t2;
431 hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
433 ok(hr == S_OK, "Activation failed with %08x\n", hr);
437 handle = CreateEventW(NULL, FALSE, FALSE, NULL);
439 hr = IAudioClient_QueryInterface(ac, &IID_IUnknown, NULL);
440 ok(hr == E_POINTER, "QueryInterface(NULL) returned %08x\n", hr);
442 unk = (void*)(LONG_PTR)0x12345678;
443 hr = IAudioClient_QueryInterface(ac, &IID_NULL, (void**)&unk);
444 ok(hr == E_NOINTERFACE, "QueryInterface(IID_NULL) returned %08x\n", hr);
445 ok(!unk, "QueryInterface(IID_NULL) returned non-null pointer %p\n", unk);
447 hr = IAudioClient_QueryInterface(ac, &IID_IUnknown, (void**)&unk);
448 ok(hr == S_OK, "QueryInterface(IID_IUnknown) returned %08x\n", hr);
451 ref = IUnknown_Release(unk);
452 ok(ref == 1, "Released count is %u\n", ref);
455 hr = IAudioClient_QueryInterface(ac, &IID_IAudioClient, (void**)&unk);
456 ok(hr == S_OK, "QueryInterface(IID_IAudioClient) returned %08x\n", hr);
459 ref = IUnknown_Release(unk);
460 ok(ref == 1, "Released count is %u\n", ref);
463 hr = IAudioClient_GetDevicePeriod(ac, NULL, NULL);
464 ok(hr == E_POINTER, "Invalid GetDevicePeriod call returns %08x\n", hr);
466 hr = IAudioClient_GetDevicePeriod(ac, &t1, NULL);
467 ok(hr == S_OK, "Valid GetDevicePeriod call returns %08x\n", hr);
469 hr = IAudioClient_GetDevicePeriod(ac, NULL, &t2);
470 ok(hr == S_OK, "Valid GetDevicePeriod call returns %08x\n", hr);
472 hr = IAudioClient_GetDevicePeriod(ac, &t1, &t2);
473 ok(hr == S_OK, "Valid GetDevicePeriod call returns %08x\n", hr);
474 trace("Returned periods: %u.%04u ms %u.%04u ms\n",
475 (UINT)(t1/10000), (UINT)(t1 % 10000),
476 (UINT)(t2/10000), (UINT)(t2 % 10000));
478 hr = IAudioClient_GetMixFormat(ac, NULL);
479 ok(hr == E_POINTER, "GetMixFormat returns %08x\n", hr);
481 hr = IAudioClient_GetMixFormat(ac, &pwfx);
482 ok(hr == S_OK, "Valid GetMixFormat returns %08x\n", hr);
486 trace("pwfx: %p\n", pwfx);
487 trace("Tag: %04x\n", pwfx->wFormatTag);
488 trace("bits: %u\n", pwfx->wBitsPerSample);
489 trace("chan: %u\n", pwfx->nChannels);
490 trace("rate: %u\n", pwfx->nSamplesPerSec);
491 trace("align: %u\n", pwfx->nBlockAlign);
492 trace("extra: %u\n", pwfx->cbSize);
493 ok(pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE, "wFormatTag is %x\n", pwfx->wFormatTag);
494 if (pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
496 WAVEFORMATEXTENSIBLE *pwfxe = (void*)pwfx;
497 trace("Res: %u\n", pwfxe->Samples.wReserved);
498 trace("Mask: %x\n", pwfxe->dwChannelMask);
500 IsEqualGUID(&pwfxe->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)?"PCM":
501 (IsEqualGUID(&pwfxe->SubFormat,
502 &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)?"FLOAT":"Other"));
505 hr = IAudioClient_IsFormatSupported(ac, AUDCLNT_SHAREMODE_SHARED, pwfx, &pwfx2);
506 ok(hr == S_OK, "Valid IsFormatSupported(Shared) call returns %08x\n", hr);
507 ok(pwfx2 == NULL, "pwfx2 is non-null\n");
508 CoTaskMemFree(pwfx2);
510 hr = IAudioClient_IsFormatSupported(ac, AUDCLNT_SHAREMODE_SHARED, NULL, NULL);
511 ok(hr == E_POINTER, "IsFormatSupported(NULL) call returns %08x\n", hr);
513 hr = IAudioClient_IsFormatSupported(ac, AUDCLNT_SHAREMODE_SHARED, pwfx, NULL);
514 ok(hr == E_POINTER, "IsFormatSupported(Shared,NULL) call returns %08x\n", hr);
516 hr = IAudioClient_IsFormatSupported(ac, AUDCLNT_SHAREMODE_EXCLUSIVE, pwfx, NULL);
517 ok(hr == S_OK || hr == AUDCLNT_E_UNSUPPORTED_FORMAT, "IsFormatSupported(Exclusive) call returns %08x\n", hr);
519 hr = IAudioClient_IsFormatSupported(ac, AUDCLNT_SHAREMODE_EXCLUSIVE, pwfx, &pwfx2);
520 ok(hr == S_OK || hr == AUDCLNT_E_UNSUPPORTED_FORMAT, "IsFormatSupported(Exclusive) call returns %08x\n", hr);
521 ok(pwfx2 == NULL, "pwfx2 non-null on exclusive IsFormatSupported\n");
523 hr = IAudioClient_IsFormatSupported(ac, 0xffffffff, pwfx, NULL);
524 ok(hr == E_INVALIDARG/*w32*/ ||
525 broken(hr == AUDCLNT_E_UNSUPPORTED_FORMAT/*w64 response from exclusive mode driver */),
526 "IsFormatSupported(0xffffffff) call returns %08x\n", hr);
529 test_uninitialized(ac);
531 hr = IAudioClient_Initialize(ac, 3, 0, 5000000, 0, pwfx, NULL);
532 ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Initialize with invalid sharemode returns %08x\n", hr);
534 hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0xffffffff, 5000000, 0, pwfx, NULL);
535 ok(hr == E_INVALIDARG, "Initialize with invalid flags returns %08x\n", hr);
537 /* A period != 0 is ignored and the call succeeds.
538 * Since we can only initialize successfully once, skip those tests.
540 hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 5000000, 0, NULL, NULL);
541 ok(hr == E_POINTER, "Initialize with null format returns %08x\n", hr);
543 hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK, 4987654, 0, pwfx, NULL);
544 ok(hr == S_OK, "Valid Initialize returns %08x\n", hr);
548 skip("Cannot initialize %08x, remainder of tests is useless\n", hr);
553 hr = IAudioClient_GetStreamLatency(ac, NULL);
554 ok(hr == E_POINTER, "GetStreamLatency(NULL) call returns %08x\n", hr);
556 hr = IAudioClient_GetStreamLatency(ac, &t1);
557 ok(hr == S_OK, "Valid GetStreamLatency call returns %08x\n", hr);
558 trace("Returned latency: %u.%04u ms\n",
559 (UINT)(t1/10000), (UINT)(t1 % 10000));
561 hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 5000000, 0, pwfx, NULL);
562 ok(hr == AUDCLNT_E_ALREADY_INITIALIZED, "Calling Initialize twice returns %08x\n", hr);
564 hr = IAudioClient_SetEventHandle(ac, NULL);
565 ok(hr == E_INVALIDARG, "SetEventHandle(NULL) returns %08x\n", hr);
567 hr = IAudioClient_Start(ac);
568 ok(hr == AUDCLNT_E_EVENTHANDLE_NOT_SET, "Start before SetEventHandle returns %08x\n", hr);
570 hr = IAudioClient_SetEventHandle(ac, handle);
571 ok(hr == S_OK, "SetEventHandle returns %08x\n", hr);
573 hr = IAudioClient_Reset(ac);
574 ok(hr == S_OK, "Reset on a resetted stream returns %08x\n", hr);
576 hr = IAudioClient_Stop(ac);
577 ok(hr == S_FALSE, "Stop on a stopped stream returns %08x\n", hr);
579 hr = IAudioClient_Start(ac);
580 ok(hr == S_OK, "Start on a stopped stream returns %08x\n", hr);
582 test_capture(ac, handle, pwfx);
584 IAudioClient_Release(ac);
589 static void test_streamvolume(void)
592 IAudioStreamVolume *asv;
598 hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
600 ok(hr == S_OK, "Activation failed with %08x\n", hr);
604 hr = IAudioClient_GetMixFormat(ac, &fmt);
605 ok(hr == S_OK, "GetMixFormat failed: %08x\n", hr);
607 hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 5000000,
609 ok(hr == S_OK, "Initialize failed: %08x\n", hr);
613 hr = IAudioClient_GetService(ac, &IID_IAudioStreamVolume, (void**)&asv);
614 ok(hr == S_OK, "GetService failed: %08x\n", hr);
616 hr = IAudioStreamVolume_GetChannelCount(asv, NULL);
617 ok(hr == E_POINTER, "GetChannelCount gave wrong error: %08x\n", hr);
619 hr = IAudioStreamVolume_GetChannelCount(asv, &chans);
620 ok(hr == S_OK, "GetChannelCount failed: %08x\n", hr);
621 ok(chans == fmt->nChannels, "GetChannelCount gave wrong number of channels: %d\n", chans);
623 hr = IAudioStreamVolume_GetChannelVolume(asv, fmt->nChannels, NULL);
624 ok(hr == E_POINTER, "GetChannelCount gave wrong error: %08x\n", hr);
626 hr = IAudioStreamVolume_GetChannelVolume(asv, fmt->nChannels, &vol);
627 ok(hr == E_INVALIDARG, "GetChannelCount gave wrong error: %08x\n", hr);
629 hr = IAudioStreamVolume_GetChannelVolume(asv, 0, NULL);
630 ok(hr == E_POINTER, "GetChannelCount gave wrong error: %08x\n", hr);
632 hr = IAudioStreamVolume_GetChannelVolume(asv, 0, &vol);
633 ok(hr == S_OK, "GetChannelCount failed: %08x\n", hr);
634 ok(vol == 1.f, "Channel volume was not 1: %f\n", vol);
636 hr = IAudioStreamVolume_SetChannelVolume(asv, fmt->nChannels, -1.f);
637 ok(hr == E_INVALIDARG, "SetChannelVolume gave wrong error: %08x\n", hr);
639 hr = IAudioStreamVolume_SetChannelVolume(asv, 0, -1.f);
640 ok(hr == E_INVALIDARG, "SetChannelVolume gave wrong error: %08x\n", hr);
642 hr = IAudioStreamVolume_SetChannelVolume(asv, 0, 2.f);
643 ok(hr == E_INVALIDARG, "SetChannelVolume gave wrong error: %08x\n", hr);
645 hr = IAudioStreamVolume_SetChannelVolume(asv, 0, 0.2f);
646 ok(hr == S_OK, "SetChannelVolume failed: %08x\n", hr);
648 hr = IAudioStreamVolume_GetChannelVolume(asv, 0, &vol);
649 ok(hr == S_OK, "GetChannelCount failed: %08x\n", hr);
650 ok(fabsf(vol - 0.2f) < 0.05f, "Channel volume wasn't 0.2: %f\n", vol);
652 hr = IAudioStreamVolume_GetAllVolumes(asv, 0, NULL);
653 ok(hr == E_POINTER, "GetAllVolumes gave wrong error: %08x\n", hr);
655 hr = IAudioStreamVolume_GetAllVolumes(asv, fmt->nChannels, NULL);
656 ok(hr == E_POINTER, "GetAllVolumes gave wrong error: %08x\n", hr);
658 vols = HeapAlloc(GetProcessHeap(), 0, fmt->nChannels * sizeof(float));
659 ok(vols != NULL, "HeapAlloc failed\n");
661 hr = IAudioStreamVolume_GetAllVolumes(asv, fmt->nChannels - 1, vols);
662 ok(hr == E_INVALIDARG, "GetAllVolumes gave wrong error: %08x\n", hr);
664 hr = IAudioStreamVolume_GetAllVolumes(asv, fmt->nChannels, vols);
665 ok(hr == S_OK, "GetAllVolumes failed: %08x\n", hr);
666 ok(fabsf(vols[0] - 0.2f) < 0.05f, "Channel 0 volume wasn't 0.2: %f\n", vol);
667 for(i = 1; i < fmt->nChannels; ++i)
668 ok(vols[i] == 1.f, "Channel %d volume is not 1: %f\n", i, vols[i]);
670 hr = IAudioStreamVolume_SetAllVolumes(asv, 0, NULL);
671 ok(hr == E_POINTER, "SetAllVolumes gave wrong error: %08x\n", hr);
673 hr = IAudioStreamVolume_SetAllVolumes(asv, fmt->nChannels, NULL);
674 ok(hr == E_POINTER, "SetAllVolumes gave wrong error: %08x\n", hr);
676 hr = IAudioStreamVolume_SetAllVolumes(asv, fmt->nChannels - 1, vols);
677 ok(hr == E_INVALIDARG, "SetAllVolumes gave wrong error: %08x\n", hr);
679 hr = IAudioStreamVolume_SetAllVolumes(asv, fmt->nChannels, vols);
680 ok(hr == S_OK, "SetAllVolumes failed: %08x\n", hr);
682 HeapFree(GetProcessHeap(), 0, vols);
683 IAudioStreamVolume_Release(asv);
684 IAudioClient_Release(ac);
688 static void test_channelvolume(void)
691 IChannelAudioVolume *acv;
697 hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
699 ok(hr == S_OK, "Activation failed with %08x\n", hr);
703 hr = IAudioClient_GetMixFormat(ac, &fmt);
704 ok(hr == S_OK, "GetMixFormat failed: %08x\n", hr);
706 hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED,
707 AUDCLNT_STREAMFLAGS_NOPERSIST, 5000000, 0, fmt, NULL);
708 ok(hr == S_OK, "Initialize failed: %08x\n", hr);
710 hr = IAudioClient_GetService(ac, &IID_IChannelAudioVolume, (void**)&acv);
711 ok(hr == S_OK, "GetService failed: %08x\n", hr);
715 hr = IChannelAudioVolume_GetChannelCount(acv, NULL);
716 ok(hr == NULL_PTR_ERR, "GetChannelCount gave wrong error: %08x\n", hr);
718 hr = IChannelAudioVolume_GetChannelCount(acv, &chans);
719 ok(hr == S_OK, "GetChannelCount failed: %08x\n", hr);
720 ok(chans == fmt->nChannels, "GetChannelCount gave wrong number of channels: %d\n", chans);
722 hr = IChannelAudioVolume_GetChannelVolume(acv, fmt->nChannels, NULL);
723 ok(hr == NULL_PTR_ERR, "GetChannelCount gave wrong error: %08x\n", hr);
725 hr = IChannelAudioVolume_GetChannelVolume(acv, fmt->nChannels, &vol);
726 ok(hr == E_INVALIDARG, "GetChannelCount gave wrong error: %08x\n", hr);
728 hr = IChannelAudioVolume_GetChannelVolume(acv, 0, NULL);
729 ok(hr == NULL_PTR_ERR, "GetChannelCount gave wrong error: %08x\n", hr);
731 hr = IChannelAudioVolume_GetChannelVolume(acv, 0, &vol);
732 ok(hr == S_OK, "GetChannelCount failed: %08x\n", hr);
733 ok(vol == 1.f, "Channel volume was not 1: %f\n", vol);
735 hr = IChannelAudioVolume_SetChannelVolume(acv, fmt->nChannels, -1.f, NULL);
736 ok(hr == E_INVALIDARG, "SetChannelVolume gave wrong error: %08x\n", hr);
738 hr = IChannelAudioVolume_SetChannelVolume(acv, 0, -1.f, NULL);
739 ok(hr == E_INVALIDARG, "SetChannelVolume gave wrong error: %08x\n", hr);
741 hr = IChannelAudioVolume_SetChannelVolume(acv, 0, 2.f, NULL);
742 ok(hr == E_INVALIDARG, "SetChannelVolume gave wrong error: %08x\n", hr);
744 hr = IChannelAudioVolume_SetChannelVolume(acv, 0, 0.2f, NULL);
745 ok(hr == S_OK, "SetChannelVolume failed: %08x\n", hr);
747 hr = IChannelAudioVolume_GetChannelVolume(acv, 0, &vol);
748 ok(hr == S_OK, "GetChannelCount failed: %08x\n", hr);
749 ok(fabsf(vol - 0.2f) < 0.05f, "Channel volume wasn't 0.2: %f\n", vol);
751 hr = IChannelAudioVolume_GetAllVolumes(acv, 0, NULL);
752 ok(hr == NULL_PTR_ERR, "GetAllVolumes gave wrong error: %08x\n", hr);
754 hr = IChannelAudioVolume_GetAllVolumes(acv, fmt->nChannels, NULL);
755 ok(hr == NULL_PTR_ERR, "GetAllVolumes gave wrong error: %08x\n", hr);
757 vols = HeapAlloc(GetProcessHeap(), 0, fmt->nChannels * sizeof(float));
758 ok(vols != NULL, "HeapAlloc failed\n");
760 hr = IChannelAudioVolume_GetAllVolumes(acv, fmt->nChannels - 1, vols);
761 ok(hr == E_INVALIDARG, "GetAllVolumes gave wrong error: %08x\n", hr);
763 hr = IChannelAudioVolume_GetAllVolumes(acv, fmt->nChannels, vols);
764 ok(hr == S_OK, "GetAllVolumes failed: %08x\n", hr);
765 ok(fabsf(vols[0] - 0.2f) < 0.05f, "Channel 0 volume wasn't 0.2: %f\n", vol);
766 for(i = 1; i < fmt->nChannels; ++i)
767 ok(vols[i] == 1.f, "Channel %d volume is not 1: %f\n", i, vols[i]);
769 hr = IChannelAudioVolume_SetAllVolumes(acv, 0, NULL, NULL);
770 ok(hr == NULL_PTR_ERR, "SetAllVolumes gave wrong error: %08x\n", hr);
772 hr = IChannelAudioVolume_SetAllVolumes(acv, fmt->nChannels, NULL, NULL);
773 ok(hr == NULL_PTR_ERR, "SetAllVolumes gave wrong error: %08x\n", hr);
775 hr = IChannelAudioVolume_SetAllVolumes(acv, fmt->nChannels - 1, vols, NULL);
776 ok(hr == E_INVALIDARG, "SetAllVolumes gave wrong error: %08x\n", hr);
778 hr = IChannelAudioVolume_SetAllVolumes(acv, fmt->nChannels, vols, NULL);
779 ok(hr == S_OK, "SetAllVolumes failed: %08x\n", hr);
781 hr = IChannelAudioVolume_SetChannelVolume(acv, 0, 1.0f, NULL);
782 ok(hr == S_OK, "SetChannelVolume failed: %08x\n", hr);
784 HeapFree(GetProcessHeap(), 0, vols);
785 IChannelAudioVolume_Release(acv);
786 IAudioClient_Release(ac);
790 static void test_simplevolume(void)
793 ISimpleAudioVolume *sav;
799 hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
801 ok(hr == S_OK, "Activation failed with %08x\n", hr);
805 hr = IAudioClient_GetMixFormat(ac, &fmt);
806 ok(hr == S_OK, "GetMixFormat failed: %08x\n", hr);
808 hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED,
809 AUDCLNT_STREAMFLAGS_NOPERSIST, 5000000, 0, fmt, NULL);
810 ok(hr == S_OK, "Initialize failed: %08x\n", hr);
812 hr = IAudioClient_GetService(ac, &IID_ISimpleAudioVolume, (void**)&sav);
813 ok(hr == S_OK, "GetService failed: %08x\n", hr);
817 hr = ISimpleAudioVolume_GetMasterVolume(sav, NULL);
818 ok(hr == NULL_PTR_ERR, "GetMasterVolume gave wrong error: %08x\n", hr);
820 hr = ISimpleAudioVolume_GetMasterVolume(sav, &vol);
821 ok(hr == S_OK, "GetMasterVolume failed: %08x\n", hr);
822 ok(vol == 1.f, "Master volume wasn't 1: %f\n", vol);
824 hr = ISimpleAudioVolume_SetMasterVolume(sav, -1.f, NULL);
825 ok(hr == E_INVALIDARG, "SetMasterVolume gave wrong error: %08x\n", hr);
827 hr = ISimpleAudioVolume_SetMasterVolume(sav, 2.f, NULL);
828 ok(hr == E_INVALIDARG, "SetMasterVolume gave wrong error: %08x\n", hr);
830 hr = ISimpleAudioVolume_SetMasterVolume(sav, 0.2f, NULL);
831 ok(hr == S_OK, "SetMasterVolume failed: %08x\n", hr);
833 hr = ISimpleAudioVolume_GetMasterVolume(sav, &vol);
834 ok(hr == S_OK, "GetMasterVolume failed: %08x\n", hr);
835 ok(fabsf(vol - 0.2f) < 0.05f, "Master volume wasn't 0.2: %f\n", vol);
837 hr = ISimpleAudioVolume_GetMute(sav, NULL);
838 ok(hr == NULL_PTR_ERR, "GetMute gave wrong error: %08x\n", hr);
841 hr = ISimpleAudioVolume_GetMute(sav, &mute);
842 ok(hr == S_OK, "GetMute failed: %08x\n", hr);
843 ok(mute == FALSE, "Session is already muted\n");
845 hr = ISimpleAudioVolume_SetMute(sav, TRUE, NULL);
846 ok(hr == S_OK, "SetMute failed: %08x\n", hr);
849 hr = ISimpleAudioVolume_GetMute(sav, &mute);
850 ok(hr == S_OK, "GetMute failed: %08x\n", hr);
851 ok(mute == TRUE, "Session should have been muted\n");
853 hr = ISimpleAudioVolume_GetMasterVolume(sav, &vol);
854 ok(hr == S_OK, "GetMasterVolume failed: %08x\n", hr);
855 ok(fabsf(vol - 0.2f) < 0.05f, "Master volume wasn't 0.2: %f\n", vol);
857 hr = ISimpleAudioVolume_SetMasterVolume(sav, 1.f, NULL);
858 ok(hr == S_OK, "SetMasterVolume failed: %08x\n", hr);
861 hr = ISimpleAudioVolume_GetMute(sav, &mute);
862 ok(hr == S_OK, "GetMute failed: %08x\n", hr);
863 ok(mute == TRUE, "Session should have been muted\n");
865 hr = ISimpleAudioVolume_SetMute(sav, FALSE, NULL);
866 ok(hr == S_OK, "SetMute failed: %08x\n", hr);
868 ISimpleAudioVolume_Release(sav);
869 IAudioClient_Release(ac);
873 static void test_volume_dependence(void)
875 IAudioClient *ac, *ac2;
876 ISimpleAudioVolume *sav;
877 IChannelAudioVolume *cav;
878 IAudioStreamVolume *asv;
885 hr = CoCreateGuid(&session);
886 ok(hr == S_OK, "CoCreateGuid failed: %08x\n", hr);
888 hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
890 ok(hr == S_OK, "Activation failed with %08x\n", hr);
892 hr = IAudioClient_GetMixFormat(ac, &fmt);
893 ok(hr == S_OK, "GetMixFormat failed: %08x\n", hr);
895 hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED,
896 AUDCLNT_STREAMFLAGS_NOPERSIST, 5000000, 0, fmt, &session);
897 ok(hr == S_OK, "Initialize failed: %08x\n", hr);
899 hr = IAudioClient_GetService(ac, &IID_ISimpleAudioVolume, (void**)&sav);
900 ok(hr == S_OK, "GetService (SimpleAudioVolume) failed: %08x\n", hr);
902 hr = IAudioClient_GetService(ac, &IID_IChannelAudioVolume, (void**)&cav);
903 ok(hr == S_OK, "GetService (ChannelAudioVolme) failed: %08x\n", hr);
905 hr = IAudioClient_GetService(ac, &IID_IAudioStreamVolume, (void**)&asv);
906 ok(hr == S_OK, "GetService (AudioStreamVolume) failed: %08x\n", hr);
910 hr = IAudioStreamVolume_SetChannelVolume(asv, 0, 0.2f);
911 ok(hr == S_OK, "ASV_SetChannelVolume failed: %08x\n", hr);
913 hr = IChannelAudioVolume_SetChannelVolume(cav, 0, 0.4f, NULL);
914 ok(hr == S_OK, "CAV_SetChannelVolume failed: %08x\n", hr);
916 hr = ISimpleAudioVolume_SetMasterVolume(sav, 0.6f, NULL);
917 ok(hr == S_OK, "SAV_SetMasterVolume failed: %08x\n", hr);
919 hr = IAudioStreamVolume_GetChannelVolume(asv, 0, &vol);
920 ok(hr == S_OK, "ASV_GetChannelVolume failed: %08x\n", hr);
921 ok(fabsf(vol - 0.2) < 0.05f, "ASV_GetChannelVolume gave wrong volume: %f\n", vol);
923 hr = IChannelAudioVolume_GetChannelVolume(cav, 0, &vol);
924 ok(hr == S_OK, "CAV_GetChannelVolume failed: %08x\n", hr);
925 ok(fabsf(vol - 0.4) < 0.05f, "CAV_GetChannelVolume gave wrong volume: %f\n", vol);
927 hr = ISimpleAudioVolume_GetMasterVolume(sav, &vol);
928 ok(hr == S_OK, "SAV_GetMasterVolume failed: %08x\n", hr);
929 ok(fabsf(vol - 0.6) < 0.05f, "SAV_GetMasterVolume gave wrong volume: %f\n", vol);
931 hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
934 IChannelAudioVolume *cav2;
935 IAudioStreamVolume *asv2;
937 hr = IAudioClient_Initialize(ac2, AUDCLNT_SHAREMODE_SHARED,
938 AUDCLNT_STREAMFLAGS_NOPERSIST, 5000000, 0, fmt, &session);
939 ok(hr == S_OK, "Initialize failed: %08x\n", hr);
941 hr = IAudioClient_GetService(ac2, &IID_IChannelAudioVolume, (void**)&cav2);
942 ok(hr == S_OK, "GetService failed: %08x\n", hr);
944 hr = IAudioClient_GetService(ac2, &IID_IAudioStreamVolume, (void**)&asv2);
945 ok(hr == S_OK, "GetService failed: %08x\n", hr);
947 hr = IChannelAudioVolume_GetChannelVolume(cav2, 0, &vol);
948 ok(hr == S_OK, "CAV_GetChannelVolume failed: %08x\n", hr);
949 ok(fabsf(vol - 0.4) < 0.05f, "CAV_GetChannelVolume gave wrong volume: %f\n", vol);
951 hr = IAudioStreamVolume_GetChannelVolume(asv2, 0, &vol);
952 ok(hr == S_OK, "ASV_GetChannelVolume failed: %08x\n", hr);
953 ok(vol == 1.f, "ASV_GetChannelVolume gave wrong volume: %f\n", vol);
955 hr = IChannelAudioVolume_GetChannelCount(cav2, &nch);
956 ok(hr == S_OK, "GetChannelCount failed: %08x\n", hr);
957 ok(nch == fmt->nChannels, "Got wrong channel count, expected %u: %u\n", fmt->nChannels, nch);
959 hr = IAudioStreamVolume_GetChannelCount(asv2, &nch);
960 ok(hr == S_OK, "GetChannelCount failed: %08x\n", hr);
961 ok(nch == fmt->nChannels, "Got wrong channel count, expected %u: %u\n", fmt->nChannels, nch);
963 IAudioStreamVolume_Release(asv2);
964 IChannelAudioVolume_Release(cav2);
965 IAudioClient_Release(ac2);
967 skip("Unable to open the same device twice. Skipping session volume control tests\n");
969 hr = IChannelAudioVolume_SetChannelVolume(cav, 0, 1.f, NULL);
970 ok(hr == S_OK, "CAV_SetChannelVolume failed: %08x\n", hr);
972 hr = ISimpleAudioVolume_SetMasterVolume(sav, 1.f, NULL);
973 ok(hr == S_OK, "SAV_SetMasterVolume failed: %08x\n", hr);
976 ISimpleAudioVolume_Release(sav);
977 IChannelAudioVolume_Release(cav);
978 IAudioStreamVolume_Release(asv);
979 IAudioClient_Release(ac);
985 IMMDeviceEnumerator *mme = NULL;
987 CoInitializeEx(NULL, COINIT_MULTITHREADED);
988 hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&mme);
991 skip("mmdevapi not available: 0x%08x\n", hr);
995 hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(mme, eCapture, eMultimedia, &dev);
996 ok(hr == S_OK || hr == E_NOTFOUND, "GetDefaultAudioEndpoint failed: 0x%08x\n", hr);
997 if (hr != S_OK || !dev)
999 if (hr == E_NOTFOUND)
1000 skip("No sound card available\n");
1002 skip("GetDefaultAudioEndpoint returns 0x%08x\n", hr);
1007 test_streamvolume();
1008 test_channelvolume();
1009 test_simplevolume();
1010 test_volume_dependence();
1012 IMMDevice_Release(dev);
1016 IMMDeviceEnumerator_Release(mme);