36#include "mmdeviceapi.h"
37#include "audioclient.h"
39#define NULL_PTR_ERR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, RPC_X_NULL_REF_POINTER)
42#define D3D11_ERROR_4E MAKE_HRESULT(SEVERITY_ERROR, FACILITY_DIRECT3D11, 0x4e)
56 hr = IAudioClient_GetBufferSize(ac, &
num);
57 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized GetBufferSize call returns %08x\n",
hr);
59 hr = IAudioClient_GetStreamLatency(ac, &t1);
60 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized GetStreamLatency call returns %08x\n",
hr);
62 hr = IAudioClient_GetCurrentPadding(ac, &
num);
63 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized GetCurrentPadding call returns %08x\n",
hr);
65 hr = IAudioClient_Start(ac);
66 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized Start call returns %08x\n",
hr);
68 hr = IAudioClient_Stop(ac);
69 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized Stop call returns %08x\n",
hr);
71 hr = IAudioClient_Reset(ac);
72 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized Reset call returns %08x\n",
hr);
74 hr = IAudioClient_SetEventHandle(ac,
handle);
75 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized SetEventHandle call returns %08x\n",
hr);
77 hr = IAudioClient_GetService(ac, &IID_IAudioStreamVolume, (
void**)&unk);
78 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized GetService call returns %08x\n",
hr);
93 hr = IAudioClient_GetService(ac, &IID_IAudioCaptureClient, (
void**)&acc);
94 ok(
hr ==
S_OK,
"IAudioClient_GetService(IID_IAudioCaptureClient) returns %08x\n",
hr);
99 data = (
void*)0xdeadf00d;
101 pos = qpc = 0xdeadbeef;
102 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
103 ok(
hr == AUDCLNT_S_BUFFER_EMPTY,
"Initial IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
107 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
108 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
112 data = (
void*)0xdeadf00d;
114 pos = qpc = 0xdeadbeef;
115 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
116 ok(
hr == AUDCLNT_S_BUFFER_EMPTY,
"Initial IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
119 if(
hr == AUDCLNT_S_BUFFER_EMPTY){
120 ok(!frames,
"frames changed to %u\n", frames);
121 ok(
data == (
void*)0xdeadf00d,
"data changed to %p\n",
data);
122 ok(
flags == 0xabadcafe,
"flags changed to %x\n",
flags);
123 ok(
pos == 0xdeadbeef,
"position changed to %u\n", (
UINT)
pos);
124 ok(qpc == 0xdeadbeef,
"timer changed to %u\n", (
UINT)qpc);
128 hr = IAudioCaptureClient_GetNextPacketSize(acc, &
next);
129 ok(
hr ==
S_OK,
"IAudioCaptureClient_GetNextPacketSize returns %08x\n",
hr);
133 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
134 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
139 hr = IAudioCaptureClient_GetNextPacketSize(acc, &
next);
140 ok(
hr ==
S_OK,
"IAudioCaptureClient_GetNextPacketSize returns %08x\n",
hr);
142 hr = IAudioClient_GetCurrentPadding(ac, &pad);
143 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
144 ok(
next == pad,
"GetNextPacketSize %u vs. GCP %u\n",
next, pad);
147 hr = IAudioCaptureClient_GetNextPacketSize(acc,
NULL);
148 ok(
hr ==
E_POINTER,
"IAudioCaptureClient_GetNextPacketSize(NULL) returns %08x\n",
hr);
150 data = (
void*)0xdeadf00d;
154 ok(
hr ==
E_POINTER,
"IAudioCaptureClient_GetBuffer(data, NULL, NULL) returns %08x\n",
hr);
157 ok(
hr ==
E_POINTER,
"IAudioCaptureClient_GetBuffer(NULL, &frames, NULL) returns %08x\n",
hr);
160 ok(
hr ==
E_POINTER,
"IAudioCaptureClient_GetBuffer(NULL, NULL, &flags) returns %08x\n",
hr);
163 ok(
hr ==
E_POINTER,
"IAudioCaptureClient_GetBuffer(&ata, &frames, NULL) returns %08x\n",
hr);
165 ok(frames == 0xdeadbeef,
"frames is reset to %08x\n", frames);
166 ok(
flags == 0xabadcafe,
"flags is reset to %08x\n",
flags);
168 hr = IAudioClient_GetDevicePeriod(ac, &period,
NULL);
169 ok(
hr ==
S_OK,
"GetDevicePeriod failed: %08x\n",
hr);
174 data = (
void*)0xdeadf00d;
175 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
176 ok(
hr ==
S_OK ||
hr == AUDCLNT_S_BUFFER_EMPTY,
"Valid IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
178 ok(frames,
"Amount of frames locked is 0!\n");
184 }
else if (
hr == AUDCLNT_S_BUFFER_EMPTY){
185 ok(!frames,
"Amount of frames locked with empty buffer is %u!\n", frames);
186 ok(
data == (
void*)0xdeadf00d,
"No data changed to %p\n",
data);
189 trace(
"Wait'ed position %d pad %u flags %x, amount of frames locked: %u\n",
192 hr = IAudioCaptureClient_GetNextPacketSize(acc, &
next);
193 ok(
hr ==
S_OK,
"IAudioCaptureClient_GetNextPacketSize returns %08x\n",
hr);
194 ok(
next == frames,
"GetNextPacketSize %u vs. GetBuffer %u\n",
next, frames);
196 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
197 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
199 hr = IAudioCaptureClient_ReleaseBuffer(acc, 0);
200 ok(
hr ==
S_OK,
"Releasing 0 returns %08x\n",
hr);
202 hr = IAudioCaptureClient_GetNextPacketSize(acc, &
next);
203 ok(
hr ==
S_OK,
"IAudioCaptureClient_GetNextPacketSize returns %08x\n",
hr);
206 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
207 ok(
hr == AUDCLNT_E_OUT_OF_ORDER,
"Releasing buffer twice returns %08x\n",
hr);
213 hr = IAudioClient_GetCurrentPadding(ac, &pad);
214 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
219 hr = IAudioCaptureClient_GetNextPacketSize(acc, &
next);
220 ok(
hr ==
S_OK,
"IAudioCaptureClient_GetNextPacketSize returns %08x\n",
hr);
221 ok(
next < pad,
"GetNextPacketSize %u vs. GCP %u\n",
next, pad);
223 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
224 ok(
hr ==
S_OK,
"Valid IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
225 ok(
next == frames,
"GetNextPacketSize %u vs. GetBuffer %u\n",
next, frames);
230 ok(frames,
"Amount of frames locked is 0!\n");
233 hr = IAudioCaptureClient_ReleaseBuffer(acc, 0);
234 ok(
hr ==
S_OK,
"Releasing 0 returns %08x\n",
hr);
237 hr = IAudioClient_GetCurrentPadding(ac, &frames);
238 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
239 ok(frames == pad || frames == pad +
next ,
240 "GCP %u past ReleaseBuffer(0) initially %u\n", frames, pad);
243 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &pos2, &qpc2);
244 ok(
hr ==
S_OK,
"Valid IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
245 ok(frames2 == frames,
"GetBuffer after ReleaseBuffer(0) %u/%u\n", frames2, frames);
246 ok(pos2 ==
pos,
"Position after ReleaseBuffer(0) %u/%u\n", (
UINT)pos2, (
UINT)
pos);
249 ok(qpc2 == qpc,
"HPC after ReleaseBuffer(0) %u vs. %u\n", (
UINT)qpc2, (
UINT)qpc);
253 trace(
"Sleep.1 position %d pad %u flags %x, amount of frames locked: %u\n",
257 UINT32 frames2 = 0xabadcafe;
263 pos = qpc = 0xdeadbeef;
264 hr = IAudioCaptureClient_GetBuffer(acc, &
data2, &frames2, &
flags, &
pos, &qpc);
265 ok(
hr == AUDCLNT_E_OUT_OF_ORDER,
"Out of order IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
266 ok(frames2 == 0xabadcafe,
"Out of order frames changed to %x\n", frames2);
267 ok(
data2 == (
void*)0xdeadf00d,
"Out of order data changed to %p\n",
data2);
268 ok(
flags == 0xabadcafe,
"Out of order flags changed to %x\n",
flags);
269 ok(
pos == 0xdeadbeef,
"Out of order position changed to %x\n", (
UINT)
pos);
270 ok(qpc == 0xdeadbeef,
"Out of order timer changed to %x\n", (
UINT)qpc);
272 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames+1);
273 ok(
hr == AUDCLNT_E_INVALID_SIZE,
"Releasing buffer+1 returns %08x\n",
hr);
275 hr = IAudioCaptureClient_ReleaseBuffer(acc, 1);
276 ok(
hr == AUDCLNT_E_INVALID_SIZE,
"Releasing 1 returns %08x\n",
hr);
278 hr = IAudioClient_Reset(ac);
279 ok(
hr == AUDCLNT_E_NOT_STOPPED,
"Reset failed: %08x\n",
hr);
282 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
283 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
287 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
288 ok(
hr == AUDCLNT_E_OUT_OF_ORDER,
"Releasing buffer twice returns %08x\n",
hr);
292 ok(
next == frames,
"GetNextPacketSize %u vs. GetDevicePeriod %u\n",
next, frames);
295 hr = IAudioClient_GetBufferSize(ac, &
next);
296 ok(
hr ==
S_OK,
"GetBufferSize failed: %08x\n",
hr);
297 trace(
"GetBufferSize %u period size %u\n",
next, frames);
301 hr = IAudioClient_GetCurrentPadding(ac, &pad);
302 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
304 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
305 ok(
hr ==
S_OK,
"Valid IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
307 trace(
"Overrun position %d pad %u flags %x, amount of frames locked: %u\n",
324 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
325 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
328 hr = IAudioClient_GetCurrentPadding(ac, &pad);
329 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
331 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
332 ok(
hr ==
S_OK,
"Valid IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
334 trace(
"Cont'ed position %d pad %u flags %x, amount of frames locked: %u\n",
341 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
342 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
346 hr = IAudioClient_Stop(ac);
347 ok(
hr ==
S_OK,
"Stop on a started stream returns %08x\n",
hr);
349 hr = IAudioClient_Start(ac);
350 ok(
hr ==
S_OK,
"Start on a stopped stream returns %08x\n",
hr);
352 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
353 ok(
hr ==
S_OK,
"Valid IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
355 hr = IAudioClient_GetCurrentPadding(ac, &pad);
356 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
358 trace(
"Restart position %d pad %u flags %x, amount of frames locked: %u\n",
360 ok(pad >
sum,
"restarted GCP %u\n", pad);
366 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
367 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
371 hr = IAudioClient_Stop(ac);
372 ok(
hr ==
S_OK,
"Stop on a started stream returns %08x\n",
hr);
374 hr = IAudioClient_Reset(ac);
375 ok(
hr ==
S_OK,
"Reset on a stopped stream returns %08x\n",
hr);
378 hr = IAudioClient_Start(ac);
379 ok(
hr ==
S_OK,
"Start on a stopped stream returns %08x\n",
hr);
381 hr = IAudioClient_GetCurrentPadding(ac, &pad);
382 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
385 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
386 ok(
hr == AUDCLNT_S_BUFFER_EMPTY ||
hr ==
S_OK,
387 "Initial IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
389 trace(
"Reset position %d pad %u flags %x, amount of frames locked: %u\n",
395 trace(
"Test marked todo: only PulseAudio gets here\n");
401 hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
402 ok(
hr ==
S_OK,
"Releasing buffer returns %08x\n",
hr);
405 else if(
hr == AUDCLNT_S_BUFFER_EMPTY){
406 ok(!pad,
"reset GCP %u\n", pad);
410 hr = IAudioClient_GetCurrentPadding(ac, &pad);
411 ok(
hr ==
S_OK,
"GetCurrentPadding call returns %08x\n",
hr);
413 hr = IAudioCaptureClient_GetBuffer(acc, &
data, &frames, &
flags, &
pos, &qpc);
414 ok(
hr ==
S_OK,
"Valid IAudioCaptureClient_GetBuffer returns %08x\n",
hr);
415 trace(
"Running position %d pad %u flags %x, amount of frames locked: %u\n",
422 IAudioCaptureClient_ReleaseBuffer(acc, frames);
425 IAudioCaptureClient_Release(acc);
438 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
440 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
450 hr = IAudioClient_QueryInterface(ac, &
IID_NULL, (
void**)&unk);
452 ok(!unk,
"QueryInterface(IID_NULL) returned non-null pointer %p\n", unk);
454 hr = IAudioClient_QueryInterface(ac, &
IID_IUnknown, (
void**)&unk);
455 ok(
hr ==
S_OK,
"QueryInterface(IID_IUnknown) returned %08x\n",
hr);
458 ref = IUnknown_Release(unk);
459 ok(
ref == 1,
"Released count is %u\n",
ref);
462 hr = IAudioClient_QueryInterface(ac, &IID_IAudioClient, (
void**)&unk);
463 ok(
hr ==
S_OK,
"QueryInterface(IID_IAudioClient) returned %08x\n",
hr);
466 ref = IUnknown_Release(unk);
467 ok(
ref == 1,
"Released count is %u\n",
ref);
470 hr = IAudioClient_GetDevicePeriod(ac,
NULL,
NULL);
471 ok(
hr ==
E_POINTER,
"Invalid GetDevicePeriod call returns %08x\n",
hr);
473 hr = IAudioClient_GetDevicePeriod(ac, &t1,
NULL);
474 ok(
hr ==
S_OK,
"Valid GetDevicePeriod call returns %08x\n",
hr);
476 hr = IAudioClient_GetDevicePeriod(ac,
NULL, &t2);
477 ok(
hr ==
S_OK,
"Valid GetDevicePeriod call returns %08x\n",
hr);
479 hr = IAudioClient_GetDevicePeriod(ac, &t1, &t2);
480 ok(
hr ==
S_OK,
"Valid GetDevicePeriod call returns %08x\n",
hr);
481 trace(
"Returned periods: %u.%04u ms %u.%04u ms\n",
482 (
UINT)(t1/10000), (
UINT)(t1 % 10000),
483 (
UINT)(t2/10000), (
UINT)(t2 % 10000));
485 hr = IAudioClient_GetMixFormat(ac,
NULL);
488 hr = IAudioClient_GetMixFormat(ac, &pwfx);
489 ok(
hr ==
S_OK,
"Valid GetMixFormat returns %08x\n",
hr);
493 trace(
"pwfx: %p\n", pwfx);
513 ok(
hr ==
S_OK,
"Valid IsFormatSupported(Shared) call returns %08x\n",
hr);
514 ok(pwfx2 ==
NULL,
"pwfx2 is non-null\n");
518 ok(
hr ==
E_POINTER,
"IsFormatSupported(NULL) call returns %08x\n",
hr);
521 ok(
hr ==
E_POINTER,
"IsFormatSupported(Shared,NULL) call returns %08x\n",
hr);
524 ok(
hr ==
S_OK ||
hr == AUDCLNT_E_UNSUPPORTED_FORMAT,
"IsFormatSupported(Exclusive) call returns %08x\n",
hr);
527 ok(
hr ==
S_OK ||
hr == AUDCLNT_E_UNSUPPORTED_FORMAT,
"IsFormatSupported(Exclusive) call returns %08x\n",
hr);
528 ok(pwfx2 ==
NULL,
"pwfx2 non-null on exclusive IsFormatSupported\n");
530 hr = IAudioClient_IsFormatSupported(ac, 0xffffffff, pwfx,
NULL);
532 broken(
hr == AUDCLNT_E_UNSUPPORTED_FORMAT),
533 "IsFormatSupported(0xffffffff) call returns %08x\n",
hr);
538 hr = IAudioClient_Initialize(ac, 3, 0, 5000000, 0, pwfx,
NULL);
539 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Initialize with invalid sharemode returns %08x\n",
hr);
542 ok(
hr ==
E_INVALIDARG ||
hr == AUDCLNT_E_INVALID_STREAM_FLAG,
"Initialize with invalid flags returns %08x\n",
hr);
551 ok(
hr ==
S_OK,
"Valid Initialize returns %08x\n",
hr);
555 skip(
"Cannot initialize %08x, remainder of tests is useless\n",
hr);
559 hr = IAudioClient_GetStreamLatency(ac,
NULL);
562 hr = IAudioClient_GetStreamLatency(ac, &t1);
563 ok(
hr ==
S_OK,
"Valid GetStreamLatency call returns %08x\n",
hr);
564 trace(
"Returned latency: %u.%04u ms\n",
565 (
UINT)(t1/10000), (
UINT)(t1 % 10000));
568 ok(
hr == AUDCLNT_E_ALREADY_INITIALIZED,
"Calling Initialize twice returns %08x\n",
hr);
570 hr = IAudioClient_SetEventHandle(ac,
NULL);
573 hr = IAudioClient_Start(ac);
574 ok(
hr == AUDCLNT_E_EVENTHANDLE_NOT_SET ||
577 hr = IAudioClient_SetEventHandle(ac,
handle);
578 ok(
hr ==
S_OK,
"SetEventHandle returns %08x\n",
hr);
580 hr = IAudioClient_Reset(ac);
581 ok(
hr ==
S_OK,
"Reset on an already reset stream returns %08x\n",
hr);
583 hr = IAudioClient_Stop(ac);
584 ok(
hr ==
S_FALSE,
"Stop on a stopped stream returns %08x\n",
hr);
586 hr = IAudioClient_Start(ac);
587 ok(
hr ==
S_OK,
"Start on a stopped stream returns %08x\n",
hr);
592 IAudioClient_Release(ac);
606 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
608 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
612 hr = IAudioClient_GetMixFormat(ac, &
fmt);
613 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
617 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
621 hr = IAudioClient_GetService(ac, &IID_IAudioStreamVolume, (
void**)&asv);
622 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
624 hr = IAudioStreamVolume_GetChannelCount(asv,
NULL);
627 hr = IAudioStreamVolume_GetChannelCount(asv, &chans);
628 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
629 ok(chans ==
fmt->nChannels,
"GetChannelCount gave wrong number of channels: %d\n", chans);
631 hr = IAudioStreamVolume_GetChannelVolume(asv,
fmt->nChannels,
NULL);
634 hr = IAudioStreamVolume_GetChannelVolume(asv,
fmt->nChannels, &vol);
637 hr = IAudioStreamVolume_GetChannelVolume(asv, 0,
NULL);
640 hr = IAudioStreamVolume_GetChannelVolume(asv, 0, &vol);
641 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
642 ok(vol == 1.f,
"Channel volume was not 1: %f\n", vol);
644 hr = IAudioStreamVolume_SetChannelVolume(asv,
fmt->nChannels, -1.f);
647 hr = IAudioStreamVolume_SetChannelVolume(asv, 0, -1.f);
650 hr = IAudioStreamVolume_SetChannelVolume(asv, 0, 2.f);
653 hr = IAudioStreamVolume_SetChannelVolume(asv, 0, 0.2f);
654 ok(
hr ==
S_OK,
"SetChannelVolume failed: %08x\n",
hr);
656 hr = IAudioStreamVolume_GetChannelVolume(asv, 0, &vol);
657 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
658 ok(
fabsf(vol - 0.2f) < 0.05f,
"Channel volume wasn't 0.2: %f\n", vol);
660 hr = IAudioStreamVolume_GetAllVolumes(asv, 0,
NULL);
663 hr = IAudioStreamVolume_GetAllVolumes(asv,
fmt->nChannels,
NULL);
667 ok(vols !=
NULL,
"HeapAlloc failed\n");
669 hr = IAudioStreamVolume_GetAllVolumes(asv,
fmt->nChannels - 1, vols);
672 hr = IAudioStreamVolume_GetAllVolumes(asv,
fmt->nChannels, vols);
673 ok(
hr ==
S_OK,
"GetAllVolumes failed: %08x\n",
hr);
674 ok(
fabsf(vols[0] - 0.2f) < 0.05f,
"Channel 0 volume wasn't 0.2: %f\n", vol);
675 for(
i = 1;
i <
fmt->nChannels; ++
i)
676 ok(vols[
i] == 1.f,
"Channel %d volume is not 1: %f\n",
i, vols[
i]);
678 hr = IAudioStreamVolume_SetAllVolumes(asv, 0,
NULL);
681 hr = IAudioStreamVolume_SetAllVolumes(asv,
fmt->nChannels,
NULL);
684 hr = IAudioStreamVolume_SetAllVolumes(asv,
fmt->nChannels - 1, vols);
687 hr = IAudioStreamVolume_SetAllVolumes(asv,
fmt->nChannels, vols);
688 ok(
hr ==
S_OK,
"SetAllVolumes failed: %08x\n",
hr);
691 IAudioStreamVolume_Release(asv);
692 IAudioClient_Release(ac);
705 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
707 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
711 hr = IAudioClient_GetMixFormat(ac, &
fmt);
712 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
716 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
718 hr = IAudioClient_GetService(ac, &IID_IChannelAudioVolume, (
void**)&acv);
719 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
723 hr = IChannelAudioVolume_GetChannelCount(acv,
NULL);
726 hr = IChannelAudioVolume_GetChannelCount(acv, &chans);
727 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
728 ok(chans ==
fmt->nChannels,
"GetChannelCount gave wrong number of channels: %d\n", chans);
730 hr = IChannelAudioVolume_GetChannelVolume(acv,
fmt->nChannels,
NULL);
733 hr = IChannelAudioVolume_GetChannelVolume(acv,
fmt->nChannels, &vol);
736 hr = IChannelAudioVolume_GetChannelVolume(acv, 0,
NULL);
739 hr = IChannelAudioVolume_GetChannelVolume(acv, 0, &vol);
740 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
741 ok(vol == 1.f,
"Channel volume was not 1: %f\n", vol);
743 hr = IChannelAudioVolume_SetChannelVolume(acv,
fmt->nChannels, -1.f,
NULL);
746 hr = IChannelAudioVolume_SetChannelVolume(acv, 0, -1.f,
NULL);
749 hr = IChannelAudioVolume_SetChannelVolume(acv, 0, 2.f,
NULL);
752 hr = IChannelAudioVolume_SetChannelVolume(acv, 0, 0.2f,
NULL);
753 ok(
hr ==
S_OK,
"SetChannelVolume failed: %08x\n",
hr);
755 hr = IChannelAudioVolume_GetChannelVolume(acv, 0, &vol);
756 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
757 ok(
fabsf(vol - 0.2f) < 0.05f,
"Channel volume wasn't 0.2: %f\n", vol);
759 hr = IChannelAudioVolume_GetAllVolumes(acv, 0,
NULL);
762 hr = IChannelAudioVolume_GetAllVolumes(acv,
fmt->nChannels,
NULL);
766 ok(vols !=
NULL,
"HeapAlloc failed\n");
768 hr = IChannelAudioVolume_GetAllVolumes(acv,
fmt->nChannels - 1, vols);
771 hr = IChannelAudioVolume_GetAllVolumes(acv,
fmt->nChannels, vols);
772 ok(
hr ==
S_OK,
"GetAllVolumes failed: %08x\n",
hr);
773 ok(
fabsf(vols[0] - 0.2f) < 0.05f,
"Channel 0 volume wasn't 0.2: %f\n", vol);
774 for(
i = 1;
i <
fmt->nChannels; ++
i)
775 ok(vols[
i] == 1.f,
"Channel %d volume is not 1: %f\n",
i, vols[
i]);
777 hr = IChannelAudioVolume_SetAllVolumes(acv, 0,
NULL,
NULL);
780 hr = IChannelAudioVolume_SetAllVolumes(acv,
fmt->nChannels,
NULL,
NULL);
783 hr = IChannelAudioVolume_SetAllVolumes(acv,
fmt->nChannels - 1, vols,
NULL);
786 hr = IChannelAudioVolume_SetAllVolumes(acv,
fmt->nChannels, vols,
NULL);
787 ok(
hr ==
S_OK,
"SetAllVolumes failed: %08x\n",
hr);
789 hr = IChannelAudioVolume_SetChannelVolume(acv, 0, 1.0f,
NULL);
790 ok(
hr ==
S_OK,
"SetChannelVolume failed: %08x\n",
hr);
793 IChannelAudioVolume_Release(acv);
794 IAudioClient_Release(ac);
807 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
809 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
813 hr = IAudioClient_GetMixFormat(ac, &
fmt);
814 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
818 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
820 hr = IAudioClient_GetService(ac, &IID_ISimpleAudioVolume, (
void**)&sav);
821 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
825 hr = ISimpleAudioVolume_GetMasterVolume(sav,
NULL);
828 hr = ISimpleAudioVolume_GetMasterVolume(sav, &vol);
829 ok(
hr ==
S_OK,
"GetMasterVolume failed: %08x\n",
hr);
831 hr = ISimpleAudioVolume_SetMasterVolume(sav, -1.f,
NULL);
834 hr = ISimpleAudioVolume_SetMasterVolume(sav, 2.f,
NULL);
837 hr = ISimpleAudioVolume_SetMasterVolume(sav, 0.2f,
NULL);
838 ok(
hr ==
S_OK,
"SetMasterVolume failed: %08x\n",
hr);
840 hr = ISimpleAudioVolume_GetMasterVolume(sav, &vol);
841 ok(
hr ==
S_OK,
"GetMasterVolume failed: %08x\n",
hr);
842 ok(
fabsf(vol - 0.2f) < 0.05f,
"Master volume wasn't 0.2: %f\n", vol);
844 hr = ISimpleAudioVolume_GetMute(sav,
NULL);
848 hr = ISimpleAudioVolume_GetMute(sav, &mute);
850 ok(mute ==
FALSE,
"Session is already muted\n");
852 hr = ISimpleAudioVolume_SetMute(sav,
TRUE,
NULL);
856 hr = ISimpleAudioVolume_GetMute(sav, &mute);
858 ok(mute ==
TRUE,
"Session should have been muted\n");
860 hr = ISimpleAudioVolume_GetMasterVolume(sav, &vol);
861 ok(
hr ==
S_OK,
"GetMasterVolume failed: %08x\n",
hr);
862 ok(
fabsf(vol - 0.2f) < 0.05f,
"Master volume wasn't 0.2: %f\n", vol);
864 hr = ISimpleAudioVolume_SetMasterVolume(sav, 1.f,
NULL);
865 ok(
hr ==
S_OK,
"SetMasterVolume failed: %08x\n",
hr);
868 hr = ISimpleAudioVolume_GetMute(sav, &mute);
870 ok(mute ==
TRUE,
"Session should have been muted\n");
875 ISimpleAudioVolume_Release(sav);
876 IAudioClient_Release(ac);
893 ok(
hr ==
S_OK,
"CoCreateGuid failed: %08x\n",
hr);
895 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
897 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
901 hr = IAudioClient_GetMixFormat(ac, &
fmt);
902 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
906 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
908 hr = IAudioClient_GetService(ac, &IID_ISimpleAudioVolume, (
void**)&sav);
909 ok(
hr ==
S_OK,
"GetService (SimpleAudioVolume) failed: %08x\n",
hr);
911 hr = IAudioClient_GetService(ac, &IID_IChannelAudioVolume, (
void**)&cav);
912 ok(
hr ==
S_OK,
"GetService (ChannelAudioVolume) failed: %08x\n",
hr);
914 hr = IAudioClient_GetService(ac, &IID_IAudioStreamVolume, (
void**)&asv);
915 ok(
hr ==
S_OK,
"GetService (AudioStreamVolume) failed: %08x\n",
hr);
919 hr = IAudioStreamVolume_SetChannelVolume(asv, 0, 0.2f);
920 ok(
hr ==
S_OK,
"ASV_SetChannelVolume failed: %08x\n",
hr);
922 hr = IChannelAudioVolume_SetChannelVolume(cav, 0, 0.4f,
NULL);
923 ok(
hr ==
S_OK,
"CAV_SetChannelVolume failed: %08x\n",
hr);
925 hr = ISimpleAudioVolume_SetMasterVolume(sav, 0.6f,
NULL);
926 ok(
hr ==
S_OK,
"SAV_SetMasterVolume failed: %08x\n",
hr);
928 hr = IAudioStreamVolume_GetChannelVolume(asv, 0, &vol);
929 ok(
hr ==
S_OK,
"ASV_GetChannelVolume failed: %08x\n",
hr);
930 ok(
fabsf(vol - 0.2f) < 0.05f,
"ASV_GetChannelVolume gave wrong volume: %f\n", vol);
932 hr = IChannelAudioVolume_GetChannelVolume(cav, 0, &vol);
933 ok(
hr ==
S_OK,
"CAV_GetChannelVolume failed: %08x\n",
hr);
934 ok(
fabsf(vol - 0.4f) < 0.05f,
"CAV_GetChannelVolume gave wrong volume: %f\n", vol);
936 hr = ISimpleAudioVolume_GetMasterVolume(sav, &vol);
937 ok(
hr ==
S_OK,
"SAV_GetMasterVolume failed: %08x\n",
hr);
938 ok(
fabsf(vol - 0.6f) < 0.05f,
"SAV_GetMasterVolume gave wrong volume: %f\n", vol);
940 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
948 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
950 hr = IAudioClient_GetService(ac2, &IID_IChannelAudioVolume, (
void**)&cav2);
951 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
953 hr = IAudioClient_GetService(ac2, &IID_IAudioStreamVolume, (
void**)&asv2);
954 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
956 hr = IChannelAudioVolume_GetChannelVolume(cav2, 0, &vol);
957 ok(
hr ==
S_OK,
"CAV_GetChannelVolume failed: %08x\n",
hr);
958 ok(
fabsf(vol - 0.4f) < 0.05f,
"CAV_GetChannelVolume gave wrong volume: %f\n", vol);
960 hr = IAudioStreamVolume_GetChannelVolume(asv2, 0, &vol);
961 ok(
hr ==
S_OK,
"ASV_GetChannelVolume failed: %08x\n",
hr);
962 ok(vol == 1.f,
"ASV_GetChannelVolume gave wrong volume: %f\n", vol);
964 hr = IChannelAudioVolume_GetChannelCount(cav2, &
nch);
965 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
966 ok(
nch ==
fmt->nChannels,
"Got wrong channel count, expected %u: %u\n",
fmt->nChannels,
nch);
968 hr = IAudioStreamVolume_GetChannelCount(asv2, &
nch);
969 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
970 ok(
nch ==
fmt->nChannels,
"Got wrong channel count, expected %u: %u\n",
fmt->nChannels,
nch);
972 IAudioStreamVolume_Release(asv2);
973 IChannelAudioVolume_Release(cav2);
974 IAudioClient_Release(ac2);
976 skip(
"Unable to open the same device twice. Skipping session volume control tests\n");
978 hr = IChannelAudioVolume_SetChannelVolume(cav, 0, 1.f,
NULL);
979 ok(
hr ==
S_OK,
"CAV_SetChannelVolume failed: %08x\n",
hr);
981 hr = ISimpleAudioVolume_SetMasterVolume(sav, 1.f,
NULL);
982 ok(
hr ==
S_OK,
"SAV_SetMasterVolume failed: %08x\n",
hr);
985 ISimpleAudioVolume_Release(sav);
986 IChannelAudioVolume_Release(cav);
987 IAudioStreamVolume_Release(asv);
988 IAudioClient_Release(ac);
999 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
1001 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
1005 hr = IAudioClient_GetMixFormat(ac, &pwfx);
1006 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
1010 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
1014 hr = IAudioClient_GetService(ac, &IID_IAudioCaptureClient, (
void**)&
cc);
1015 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
1017 IAudioClient_Release(ac);
1022 ok(
hr ==
S_OK,
"CreateStreamOnHGlobal failed 0x%08x\n",
hr);
1027 ok(
hr ==
S_OK,
"CoMarshalInterface IAudioClient failed 0x%08x\n",
hr);
1029 IStream_Seek(pStream,
ullZero, STREAM_SEEK_SET,
NULL);
1031 ok(
hr ==
S_OK,
"CoUnmarshalInterface IAudioClient failed 0x%08x\n",
hr);
1033 IAudioClient_Release(acDest);
1035 IStream_Seek(pStream,
ullZero, STREAM_SEEK_SET,
NULL);
1039 ok(
hr ==
S_OK,
"CoMarshalInterface IAudioCaptureClient failed 0x%08x\n",
hr);
1041 IStream_Seek(pStream,
ullZero, STREAM_SEEK_SET,
NULL);
1043 ok(
hr ==
S_OK,
"CoUnmarshalInterface IAudioCaptureClient failed 0x%08x\n",
hr);
1045 IAudioCaptureClient_Release(ccDest);
1047 IStream_Release(pStream);
1049 IAudioClient_Release(ac);
1050 IAudioCaptureClient_Release(
cc);
1063 skip(
"mmdevapi not available: 0x%08x\n",
hr);
1068 ok(
hr ==
S_OK ||
hr == E_NOTFOUND,
"GetDefaultAudioEndpoint failed: 0x%08x\n",
hr);
1071 if (
hr == E_NOTFOUND)
1072 skip(
"No sound card available\n");
1074 skip(
"GetDefaultAudioEndpoint returns 0x%08x\n",
hr);
1085 IMMDevice_Release(
dev);
1089 IMMDeviceEnumerator_Release(
mme);
unsigned long long UINT64
@ AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY
#define AUDCLNT_STREAMFLAGS_EVENTCALLBACK
@ AUDCLNT_SHAREMODE_SHARED
@ AUDCLNT_SHAREMODE_EXCLUSIVE
#define AUDCLNT_STREAMFLAGS_NOPERSIST
#define HeapFree(x, y, z)
static void cleanup(void)
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
HRESULT WINAPI CoCreateGuid(GUID *pguid)
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
HRESULT WINAPI CoUnmarshalInterface(IStream *pStream, REFIID riid, LPVOID *ppv)
HRESULT WINAPI CoMarshalInterface(IStream *pStream, REFIID riid, IUnknown *pUnk, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
VOID WINAPI CoTaskMemFree(LPVOID ptr)
_Check_return_ __CRT_INLINE float __CRTDECL fabsf(_In_ float x)
static void test_capture(void)
static void test_simplevolume(void)
static void test_audioclient(void)
static const LARGE_INTEGER ullZero
static void test_marshal(void)
static void test_uninitialized(IAudioClient *ac)
static void test_channelvolume(void)
static void test_streamvolume(void)
static void test_volume_dependence(void)
static IMMDeviceEnumerator * mme
#define todo_wine_if(is_todo)
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
#define IsEqualGUID(rguid1, rguid2)
static int sum(int x_, int y_)
static unsigned __int64 next
union WAVEFORMATEXTENSIBLE::@3019 Samples
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)