38#include "mmdeviceapi.h"
40#include "audioclient.h"
41#include "audiopolicy.h"
45#include "endpointvolume.h"
48 { 8000, 8, 1}, { 8000, 8, 2}, { 8000, 16, 1}, { 8000, 16, 2},
49 {11025, 8, 1}, {11025, 8, 2}, {11025, 16, 1}, {11025, 16, 2},
50 {12000, 8, 1}, {12000, 8, 2}, {12000, 16, 1}, {12000, 16, 2},
51 {16000, 8, 1}, {16000, 8, 2}, {16000, 16, 1}, {16000, 16, 2},
52 {22050, 8, 1}, {22050, 8, 2}, {22050, 16, 1}, {22050, 16, 2},
53 {44100, 8, 1}, {44100, 8, 2}, {44100, 16, 1}, {44100, 16, 2},
54 {48000, 8, 1}, {48000, 8, 2}, {48000, 16, 1}, {48000, 16, 2},
55 {96000, 8, 1}, {96000, 8, 2}, {96000, 16, 1}, {96000, 16, 2}
58#define NULL_PTR_ERR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, RPC_X_NULL_REF_POINTER)
61#define D3D11_ERROR_4E MAKE_HRESULT(SEVERITY_ERROR, FACILITY_DIRECT3D11, 0x4e)
70#define PI 3.14159265358979323846L
73 static double phase = 0.;
86 for(
i = 0;
i < frames;
i++){
96 phase -=
floor(phase);
109 hr = IAudioClient_GetBufferSize(ac, &
num);
110 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized GetBufferSize call returns %08x\n",
hr);
112 hr = IAudioClient_GetStreamLatency(ac, &t1);
113 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized GetStreamLatency call returns %08x\n",
hr);
115 hr = IAudioClient_GetCurrentPadding(ac, &
num);
116 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized GetCurrentPadding call returns %08x\n",
hr);
118 hr = IAudioClient_Start(ac);
119 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized Start call returns %08x\n",
hr);
121 hr = IAudioClient_Stop(ac);
122 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized Stop call returns %08x\n",
hr);
124 hr = IAudioClient_Reset(ac);
125 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized Reset call returns %08x\n",
hr);
127 hr = IAudioClient_SetEventHandle(ac,
handle);
128 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized SetEventHandle call returns %08x\n",
hr);
130 hr = IAudioClient_GetService(ac, &IID_IAudioStreamVolume, (
void**)&unk);
131 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Uninitialized GetService call returns %08x\n",
hr);
146 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
148 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
158 hr = IAudioClient_QueryInterface(ac, &
IID_NULL, (
void**)&unk);
160 ok(!unk,
"QueryInterface(IID_NULL) returned non-null pointer %p\n", unk);
162 hr = IAudioClient_QueryInterface(ac, &
IID_IUnknown, (
void**)&unk);
163 ok(
hr ==
S_OK,
"QueryInterface(IID_IUnknown) returned %08x\n",
hr);
166 ref = IUnknown_Release(unk);
167 ok(
ref == 1,
"Released count is %u\n",
ref);
170 hr = IAudioClient_QueryInterface(ac, &IID_IAudioClient, (
void**)&unk);
171 ok(
hr ==
S_OK,
"QueryInterface(IID_IAudioClient) returned %08x\n",
hr);
174 ref = IUnknown_Release(unk);
175 ok(
ref == 1,
"Released count is %u\n",
ref);
178 hr = IAudioClient_GetDevicePeriod(ac,
NULL,
NULL);
179 ok(
hr ==
E_POINTER,
"Invalid GetDevicePeriod call returns %08x\n",
hr);
181 hr = IAudioClient_GetDevicePeriod(ac, &t1,
NULL);
182 ok(
hr ==
S_OK,
"Valid GetDevicePeriod call returns %08x\n",
hr);
184 hr = IAudioClient_GetDevicePeriod(ac,
NULL, &t2);
185 ok(
hr ==
S_OK,
"Valid GetDevicePeriod call returns %08x\n",
hr);
187 hr = IAudioClient_GetDevicePeriod(ac, &t1, &t2);
188 ok(
hr ==
S_OK,
"Valid GetDevicePeriod call returns %08x\n",
hr);
189 trace(
"Returned periods: %u.%04u ms %u.%04u ms\n",
190 (
UINT)(t1/10000), (
UINT)(t1 % 10000),
191 (
UINT)(t2/10000), (
UINT)(t2 % 10000));
193 hr = IAudioClient_GetMixFormat(ac,
NULL);
196 hr = IAudioClient_GetMixFormat(ac, &pwfx);
197 ok(
hr ==
S_OK,
"Valid GetMixFormat returns %08x\n",
hr);
201 trace(
"pwfx: %p\n", pwfx);
221 ok(
hr ==
S_OK,
"Valid IsFormatSupported(Shared) call returns %08x\n",
hr);
222 ok(pwfx2 ==
NULL,
"pwfx2 is non-null\n");
226 ok(
hr ==
E_POINTER,
"IsFormatSupported(NULL) call returns %08x\n",
hr);
229 ok(
hr ==
E_POINTER,
"IsFormatSupported(Shared,NULL) call returns %08x\n",
hr);
232 ok(
hr ==
S_OK ||
hr == AUDCLNT_E_UNSUPPORTED_FORMAT ||
hr == AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED,
233 "IsFormatSupported(Exclusive) call returns %08x\n",
hr);
238 ok(
hr ==
hexcl,
"IsFormatSupported(Exclusive) call returns %08x\n",
hr);
239 ok(pwfx2 ==
NULL,
"pwfx2 non-null on exclusive IsFormatSupported\n");
241 if (
hexcl != AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED)
244 hr = IAudioClient_IsFormatSupported(ac, 0xffffffff, pwfx,
NULL);
246 broken(
hr == AUDCLNT_E_UNSUPPORTED_FORMAT),
247 "IsFormatSupported(0xffffffff) call returns %08x\n",
hr);
252 hr = IAudioClient_Initialize(ac, 3, 0, 5000000, 0, pwfx,
NULL);
253 ok(
hr == AUDCLNT_E_NOT_INITIALIZED,
"Initialize with invalid sharemode returns %08x\n",
hr);
257 hr == AUDCLNT_E_INVALID_STREAM_FLAG,
"Initialize with invalid flags returns %08x\n",
hr);
266 ok(
hr ==
S_OK,
"Initialize with 0 buffer size returns %08x\n",
hr);
270 hr = IAudioClient_GetBufferSize(ac, &
num);
271 ok(
hr ==
S_OK,
"GetBufferSize from duration 0 returns %08x\n",
hr);
273 trace(
"Initialize(duration=0) GetBufferSize is %u\n",
num);
276 IAudioClient_Release(ac);
278 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
280 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
292 hr == AUDCLNT_E_UNSUPPORTED_FORMAT ,
"Initialize(dwChannelMask = 0xffff) returns %08x\n",
hr);
294 IAudioClient_Release(ac);
296 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
298 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
304 "IsFormatSupported(dwChannelMask = 0) call returns %08x\n",
hr);
310 ok(
hr ==
S_OK,
"Initialize(dwChannelMask = 0) returns %08x\n",
hr);
312 IAudioClient_Release(ac);
314 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
316 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
320 hr = IAudioClient_GetMixFormat(ac, &pwfx);
321 ok(
hr ==
S_OK,
"Valid GetMixFormat returns %08x\n",
hr);
323 skip(
"Skipping dwChannelMask tests\n");
326 ok(
hr ==
S_OK,
"Valid Initialize returns %08x\n",
hr);
330 hr = IAudioClient_GetStreamLatency(ac,
NULL);
333 hr = IAudioClient_GetStreamLatency(ac, &t2);
334 ok(
hr ==
S_OK,
"Valid GetStreamLatency call returns %08x\n",
hr);
335 trace(
"Returned latency: %u.%04u ms\n",
336 (
UINT)(t2/10000), (
UINT)(t2 % 10000));
339 "Latency < default period, delta %dus (%s vs %s)\n",
346 ok(
hr == AUDCLNT_E_ALREADY_INITIALIZED,
"Calling Initialize twice returns %08x\n",
hr);
348 hr = IAudioClient_SetEventHandle(ac,
NULL);
351 hr = IAudioClient_SetEventHandle(ac,
handle);
352 ok(
hr == AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED ||
356 ,
"SetEventHandle returns %08x\n",
hr);
358 hr = IAudioClient_Reset(ac);
359 ok(
hr ==
S_OK,
"Reset on an initialized stream returns %08x\n",
hr);
361 hr = IAudioClient_Reset(ac);
362 ok(
hr ==
S_OK,
"Reset on an already reset stream returns %08x\n",
hr);
364 hr = IAudioClient_Stop(ac);
365 ok(
hr ==
S_FALSE,
"Stop on a stopped stream returns %08x\n",
hr);
367 hr = IAudioClient_Start(ac);
368 ok(
hr ==
S_OK,
"Start on a stopped stream returns %08x\n",
hr);
370 hr = IAudioClient_Start(ac);
371 ok(
hr == AUDCLNT_E_NOT_STOPPED,
"Start twice returns %08x\n",
hr);
374 IAudioClient_Release(ac);
390 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
392 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
396 hr = IAudioClient_GetMixFormat(ac, &pwfx);
397 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
402 fmt.nBlockAlign =
fmt.nChannels *
fmt.wBitsPerSample / 8;
403 fmt.nAvgBytesPerSec=
fmt.nBlockAlign *
fmt.nSamplesPerSec;
406 hr = IAudioClient_IsFormatSupported(ac,
mode, &
fmt, &pwfx2);
413 : (
hr == AUDCLNT_E_UNSUPPORTED_FORMAT ||
hr ==
hexcl)),
414 "IsFormatSupported(%d, %ux%2ux%u) returns %08x\n",
mode,
415 fmt.nSamplesPerSec,
fmt.wBitsPerSample,
fmt.nChannels,
hr);
417 trace(
"IsSupported(%s, %ux%2ux%u)\n",
419 fmt.nSamplesPerSec,
fmt.wBitsPerSample,
fmt.nChannels);
425 ok(
hr ==
S_OK,
"Varying BitsPerSample %u\n",
fmt.wBitsPerSample);
434 "Suggestion %ux%2ux%u differs from GetMixFormat\n",
439 hr = IAudioClient_Initialize(ac,
mode, 0, 5000000, 0, &
fmt,
NULL);
441 trace(
"Initialize (%s, %ux%2ux%u) returns %08x unlike IsFormatSupported\n",
443 fmt.nSamplesPerSec,
fmt.wBitsPerSample,
fmt.nChannels,
hr);
446 "Initialize(shared, %ux%2ux%u) returns %08x\n",
447 fmt.nSamplesPerSec,
fmt.wBitsPerSample,
fmt.nChannels,
hr);
448 else if (hrs == AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED)
450 ok(hrs ==
hexcl && (
hr == AUDCLNT_E_ENDPOINT_CREATE_FAILED ||
hr == hrs),
451 "Initialize(noexcl., %ux%2ux%u) returns %08x(%08x)\n",
452 fmt.nSamplesPerSec,
fmt.wBitsPerSample,
fmt.nChannels,
hr, hrs);
458 :
hr == AUDCLNT_E_ENDPOINT_CREATE_FAILED ||
hr == AUDCLNT_E_UNSUPPORTED_FORMAT ||
460 ((
fmt.nChannels == 1 &&
fmt.wBitsPerSample == 16) ||
461 (
fmt.nSamplesPerSec == 12000 ||
fmt.nSamplesPerSec == 96000))),
462 "Initialize(exclus., %ux%2ux%u) returns %08x\n",
463 fmt.nSamplesPerSec,
fmt.wBitsPerSample,
fmt.nChannels,
hr);
474 IAudioClient_Release(ac);
490 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
492 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
496 hr = IAudioClient_GetMixFormat(ac, &pwfx);
497 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
501 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
505 hr = IAudioClient_GetService(ac, &IID_IAudioRenderClient, (
void**)&rc);
506 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
508 IAudioClient_Release(ac);
512 IAudioRenderClient_AddRef(rc);
513 ref = IAudioRenderClient_Release(rc);
514 ok(
ref != 0,
"RenderClient_Release gave wrong refcount: %u\n",
ref);
516 ref = IAudioClient_Release(ac);
517 ok(
ref != 0,
"Client_Release gave wrong refcount: %u\n",
ref);
519 ref = IAudioRenderClient_Release(rc);
520 ok(
ref == 0,
"RenderClient_Release gave wrong refcount: %u\n",
ref);
523 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
525 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
529 hr = IAudioClient_GetMixFormat(ac, &pwfx);
530 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
534 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
538 hr = IAudioClient_GetService(ac, &IID_ISimpleAudioVolume, (
void**)&sav);
539 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
541 ISimpleAudioVolume_AddRef(sav);
542 ref = ISimpleAudioVolume_Release(sav);
543 ok(
ref != 0,
"SimpleAudioVolume_Release gave wrong refcount: %u\n",
ref);
545 ref = IAudioClient_Release(ac);
546 ok(
ref != 0,
"Client_Release gave wrong refcount: %u\n",
ref);
548 ref = ISimpleAudioVolume_Release(sav);
549 ok(
ref == 0,
"SimpleAudioVolume_Release gave wrong refcount: %u\n",
ref);
552 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
554 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
558 hr = IAudioClient_GetMixFormat(ac, &pwfx);
559 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
563 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
567 hr = IAudioClient_GetService(ac, &IID_IAudioClock, (
void**)&acl);
568 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
570 IAudioClock_AddRef(acl);
571 ref = IAudioClock_Release(acl);
572 ok(
ref != 0,
"AudioClock_Release gave wrong refcount: %u\n",
ref);
574 ref = IAudioClient_Release(ac);
575 ok(
ref != 0,
"Client_Release gave wrong refcount: %u\n",
ref);
577 ref = IAudioClock_Release(acl);
578 ok(
ref == 0,
"AudioClock_Release gave wrong refcount: %u\n",
ref);
581 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
583 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
587 hr = IAudioClient_GetMixFormat(ac, &pwfx);
588 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
592 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
596 hr = IAudioClient_GetService(ac, &IID_IAudioStreamVolume, (
void**)&asv);
597 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
599 IAudioStreamVolume_AddRef(asv);
600 ref = IAudioStreamVolume_Release(asv);
601 ok(
ref != 0,
"AudioStreamVolume_Release gave wrong refcount: %u\n",
ref);
603 ref = IAudioClient_Release(ac);
604 ok(
ref != 0,
"Client_Release gave wrong refcount: %u\n",
ref);
606 ref = IAudioStreamVolume_Release(asv);
607 ok(
ref == 0,
"AudioStreamVolume_Release gave wrong refcount: %u\n",
ref);
618 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
620 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
624 hr = IAudioClient_GetMixFormat(ac, &pwfx);
625 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
630 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
637 hr = IAudioClient_Start(ac);
638 ok(
hr == AUDCLNT_E_EVENTHANDLE_NOT_SET ||
641 hr = IAudioClient_SetEventHandle(ac,
event);
642 ok(
hr ==
S_OK,
"SetEventHandle failed: %08x\n",
hr);
644 hr = IAudioClient_SetEventHandle(ac,
event);
651 hr = IAudioClient_Start(ac);
657 hr = IAudioClient_Stop(ac);
666 hr = IAudioClient_Reset(ac);
674 hr = IAudioClient_SetEventHandle(ac,
NULL);
681 hr = IAudioClient_Start(ac);
683 IAudioClient_Release(ac);
698 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
700 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
704 hr = IAudioClient_GetMixFormat(ac, &pwfx);
705 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
710 0, 5000000, 0, pwfx,
NULL);
711 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
725 hr = IAudioClient_GetDevicePeriod(ac, &defp, &minp);
726 ok(
hr ==
S_OK,
"GetDevicePeriod failed: %08x\n",
hr);
728 ok(defp == 100000 ||
broken(defp == 101587) || defp == 200000,
729 "Expected 10ms default period: %u\n", (
ULONG)defp);
730 ok(minp != 0,
"Minimum period is 0\n");
731 ok(minp <= defp,
"Minimum period is greater than default period\n");
733 hr = IAudioClient_GetService(ac, &IID_IAudioRenderClient, (
void**)&arc);
734 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
739 hr = IAudioClient_GetCurrentPadding(ac, &pad);
740 ok(
hr ==
S_OK,
"GetCurrentPadding failed: %08x\n",
hr);
741 ok(pad == written,
"GetCurrentPadding returned %u, should be %u\n", pad, written);
743 hr = IAudioRenderClient_GetBuffer(arc,
psize, &
buf);
744 ok(
hr ==
S_OK,
"GetBuffer failed: %08x\n",
hr);
745 ok(
buf !=
NULL,
"NULL buffer returned\n");
749 if(
buf[
i] != silence){
750 ok(0,
"buffer has data in it already, i: %u, value: %f\n",
i, *((
float*)
buf));
756 hr = IAudioRenderClient_GetBuffer(arc, 0, &
buf);
757 ok(
hr == AUDCLNT_E_OUT_OF_ORDER,
"GetBuffer 0 size failed: %08x\n",
hr);
761 hr = IAudioClient_Reset(ac);
762 ok(
hr == AUDCLNT_E_BUFFER_OPERATION_PENDING,
"Reset failed: %08x\n",
hr);
764 hr = IAudioRenderClient_ReleaseBuffer(arc,
psize,
766 ok(
hr ==
S_OK,
"ReleaseBuffer failed: %08x\n",
hr);
769 hr = IAudioClient_GetCurrentPadding(ac, &pad);
770 ok(
hr ==
S_OK,
"GetCurrentPadding failed: %08x\n",
hr);
771 ok(pad == written,
"GetCurrentPadding returned %u, should be %u\n", pad, written);
775 hr = IAudioRenderClient_GetBuffer(arc,
psize, &
buf);
776 ok(
hr ==
S_OK,
"GetBuffer failed: %08x\n",
hr);
777 ok(
buf !=
NULL,
"NULL buffer returned\n");
779 hr = IAudioRenderClient_ReleaseBuffer(arc,
psize,
781 ok(
hr ==
S_OK,
"ReleaseBuffer failed: %08x\n",
hr);
784 hr = IAudioClient_GetCurrentPadding(ac, &pad);
785 ok(
hr ==
S_OK,
"GetCurrentPadding failed: %08x\n",
hr);
786 ok(pad == written,
"GetCurrentPadding returned %u, should be %u\n", pad, written);
791 buf = (
void*)0xDEADF00D;
792 hr = IAudioRenderClient_GetBuffer(arc,
psize, &
buf);
793 ok(
hr == AUDCLNT_E_BUFFER_TOO_LARGE,
"GetBuffer gave wrong error: %08x\n",
hr);
796 hr = IAudioRenderClient_ReleaseBuffer(arc,
psize, 0);
797 ok(
hr == AUDCLNT_E_OUT_OF_ORDER,
"ReleaseBuffer gave wrong error: %08x\n",
hr);
801 hr = IAudioRenderClient_GetBuffer(arc,
psize, &
buf);
802 ok(
hr ==
S_OK,
"GetBuffer failed: %08x\n",
hr);
803 ok(
buf !=
NULL,
"NULL buffer returned\n");
805 hr = IAudioRenderClient_ReleaseBuffer(arc, 0, 0);
806 ok(
hr ==
S_OK,
"ReleaseBuffer 0 gave wrong error: %08x\n",
hr);
808 buf = (
void*)0xDEADF00D;
809 hr = IAudioRenderClient_GetBuffer(arc, 0, &
buf);
810 ok(
hr ==
S_OK,
"GetBuffer 0 size failed: %08x\n",
hr);
814 buf = (
void*)0xDEADF00D;
815 hr = IAudioRenderClient_GetBuffer(arc, 0, &
buf);
816 ok(
hr ==
S_OK,
"GetBuffer 0 size #2 failed: %08x\n",
hr);
819 hr = IAudioRenderClient_ReleaseBuffer(arc,
psize, 0);
820 ok(
hr == AUDCLNT_E_OUT_OF_ORDER,
"ReleaseBuffer not size 0 gave %08x\n",
hr);
822 hr = IAudioRenderClient_GetBuffer(arc,
psize, &
buf);
823 ok(
hr ==
S_OK,
"GetBuffer failed: %08x\n",
hr);
824 ok(
buf !=
NULL,
"NULL buffer returned\n");
826 hr = IAudioRenderClient_ReleaseBuffer(arc, 0, 0);
827 ok(
hr ==
S_OK,
"ReleaseBuffer 0 gave wrong error: %08x\n",
hr);
829 hr = IAudioClient_GetCurrentPadding(ac, &pad);
830 ok(
hr ==
S_OK,
"GetCurrentPadding failed: %08x\n",
hr);
831 ok(pad == written,
"GetCurrentPadding returned %u, should be %u\n", pad, written);
833 hr = IAudioRenderClient_GetBuffer(arc,
psize, &
buf);
834 ok(
hr ==
S_OK,
"GetBuffer failed: %08x\n",
hr);
835 ok(
buf !=
NULL,
"NULL buffer returned\n");
838 ok(
hr == AUDCLNT_E_INVALID_SIZE,
"ReleaseBuffer too large error: %08x\n",
hr);
844 ok(
hr ==
S_OK,
"ReleaseBuffer after error: %08x\n",
hr);
847 hr = IAudioRenderClient_ReleaseBuffer(arc, 0, 0);
848 ok(
hr ==
S_OK,
"ReleaseBuffer 0 gave wrong error: %08x\n",
hr);
850 hr = IAudioClient_GetCurrentPadding(ac, &pad);
851 ok(
hr ==
S_OK,
"GetCurrentPadding failed: %08x\n",
hr);
852 ok(pad == written,
"GetCurrentPadding returned %u, should be %u\n", pad, written);
856 IAudioRenderClient_Release(arc);
857 IAudioClient_Release(ac);
877 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
879 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
883 hr = IAudioClient_GetMixFormat(ac, &pwfx);
884 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
888 hr = IAudioClient_GetDevicePeriod(ac, &defp, &minp);
889 ok(
hr ==
S_OK,
"GetDevicePeriod failed: %08x\n",
hr);
890 ok(minp <= period,
"desired period %u too small for %u\n", (
ULONG)period, (
ULONG)minp);
893 trace(
"Testing shared mode\n");
896 0, duration, period, pwfx,
NULL);
908 0, duration, period, pwfx,
NULL);
910 ok(share ?
hr ==
S_OK :
hr ==
hexcl ||
hr == AUDCLNT_E_DEVICE_IN_USE,
"Initialize failed: %08x\n",
hr);
913 IAudioClient_Release(ac);
914 if(
hr == AUDCLNT_E_DEVICE_IN_USE)
915 skip(
"Device in use, no %s access\n", share ?
"shared" :
"exclusive");
923 hr = IAudioClient_GetStreamLatency(ac, &t2);
924 ok(
hr ==
S_OK,
"GetStreamLatency failed: %08x\n",
hr);
925 trace(
"Latency: %u.%04u ms\n", (
UINT)(t2/10000), (
UINT)(t2 % 10000));
928 "Latency < default period, delta %ldus\n", (
long)((t2-period)/10));
939 hr = IAudioClient_GetBufferSize(ac, &gbsize);
940 ok(
hr ==
S_OK,
"GetBufferSize failed: %08x\n",
hr);
945 trace(
"BufferSize %u estimated fragment %u x %u = %u\n", gbsize, fragment,
parts, fragment *
parts);
954 "BufferSize %u misfits fragment size %u at rate %u\n", gbsize, fragment, pwfx->
nSamplesPerSec);
964 hr = IAudioClient_GetService(ac, &IID_IAudioClock, (
void**)&acl);
965 ok(
hr ==
S_OK,
"GetService(IAudioClock) failed: %08x\n",
hr);
967 hr = IAudioClock_GetFrequency(acl, &freq);
968 ok(
hr ==
S_OK,
"GetFrequency failed: %08x\n",
hr);
969 trace(
"Clock Frequency %u\n", (
UINT)freq);
974 "Clock Frequency %u\n", (
UINT)freq);
977 "Clock Frequency %u\n", (
UINT)freq);
979 hr = IAudioClock_GetPosition(acl,
NULL,
NULL);
983 hr = IAudioClock_GetPosition(acl, &
pos, &pcpos0);
984 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
985 ok(
pos == 0,
"GetPosition returned non-zero pos before being started\n");
986 ok(pcpos0 != 0,
"GetPosition returned zero pcpos\n");
988 hr = IAudioClient_GetService(ac, &IID_IAudioRenderClient, (
void**)&arc);
989 ok(
hr ==
S_OK,
"GetService(IAudioRenderClient) failed: %08x\n",
hr);
991 hr = IAudioRenderClient_GetBuffer(arc, gbsize+1, &
data);
992 ok(
hr == AUDCLNT_E_BUFFER_TOO_LARGE,
"GetBuffer too large failed: %08x\n",
hr);
996 hr = IAudioRenderClient_GetBuffer(arc,
avail, &
data);
997 ok(
hr ==
S_OK,
"GetBuffer failed: %08x\n",
hr);
1002 ok(
hr ==
S_OK,
"ReleaseBuffer failed: %08x\n",
hr);
1005 hr = IAudioClient_GetCurrentPadding(ac, &pad);
1006 ok(
hr ==
S_OK,
"GetCurrentPadding failed: %08x\n",
hr);
1007 ok(pad ==
sum,
"padding %u prior to start\n", pad);
1009 hr = IAudioClock_GetPosition(acl, &
pos,
NULL);
1010 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
1011 ok(
pos == 0,
"GetPosition returned non-zero pos before being started\n");
1013 hr = IAudioClient_Start(ac);
1019 hr = IAudioClient_GetStreamLatency(ac, &t1);
1020 ok(
hr ==
S_OK,
"GetStreamLatency failed: %08x\n",
hr);
1021 ok(t1 == t2,
"Latency not constant, delta %ld\n", (
long)(t1-t2));
1023 hr = IAudioClock_GetPosition(acl, &
pos,
NULL);
1024 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
1027 ok(
pos*1000/freq <= slept*1.4,
"Position %u too far after playing %ums\n", (
UINT)
pos, slept);
1030 hr = IAudioClient_Stop(ac);
1033 hr = IAudioClock_GetPosition(acl, &
pos,
NULL);
1034 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
1038 ok(
pos*1000/freq <= slept*1.1,
"Position %u too far after stop %ums\n", (
UINT)
pos, slept);
1040 hr = IAudioClient_Start(ac);
1046 hr = IAudioClient_GetCurrentPadding(ac, &pad);
1047 ok(
hr ==
S_OK,
"GetCurrentPadding failed: %08x\n",
hr);
1048 trace(
"padding %u past sleep #2\n", pad);
1059 hr = IAudioClient_Stop(ac);
1062 hr = IAudioClient_GetCurrentPadding(ac, &pad);
1063 ok(
hr ==
S_OK,
"GetCurrentPadding failed: %08x\n",
hr);
1065 hr = IAudioClock_GetPosition(acl, &
pos,
NULL);
1066 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
1067 trace(
"padding %u position %u past stop #2\n", pad, (
UINT)
pos);
1072 ok(
pos*1000/freq <= slept*1.1,
"Position %u too far after playing %ums\n", (
UINT)
pos, slept);
1076 "Position %u after stop vs. %u padding\n", (
UINT)
pos, pad);
1081 hr = IAudioClock_GetPosition(acl, &
pos,
NULL);
1082 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
1086 hr = IAudioClient_Reset(ac);
1090 hr = IAudioClient_Reset(ac);
1091 ok(
hr ==
S_OK,
"Reset on an already reset stream returns %08x\n",
hr);
1093 hr = IAudioClock_GetPosition(acl, &
pos, &pcpos);
1094 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
1095 ok(
pos == 0,
"GetPosition returned non-zero pos after Reset\n");
1096 ok(pcpos > pcpos0,
"pcpos should increase\n");
1099 hr = IAudioRenderClient_GetBuffer(arc,
avail, &
data);
1100 ok(
hr ==
S_OK,
"GetBuffer failed: %08x\n",
hr);
1105 ok(
hr ==
S_OK,
"ReleaseBuffer failed: %08x\n",
hr);
1108 hr = IAudioClient_GetCurrentPadding(ac, &pad);
1109 ok(
hr ==
S_OK,
"GetCurrentPadding failed: %08x\n",
hr);
1110 ok(pad ==
sum,
"padding %u prior to start\n", pad);
1112 hr = IAudioClock_GetPosition(acl, &
pos,
NULL);
1113 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
1114 ok(
pos == 0,
"GetPosition returned non-zero pos after Reset\n");
1117 hr = IAudioClient_Start(ac);
1123 hr = IAudioClock_GetPosition(acl, &
pos,
NULL);
1124 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
1125 trace(
"position %u past %ums sleep #3\n", (
UINT)
pos, slept);
1129 ok(
pos*1000/freq <= slept*1.1,
"Position %u too far after playing %ums\n", (
UINT)
pos, slept);
1131 skip(
"Rerun with WINETEST_DEBUG=2 for GetPosition tests.\n");
1134 hr = IAudioClient_Reset(ac);
1135 ok(
hr == AUDCLNT_E_NOT_STOPPED,
"Reset while playing: %08x\n",
hr);
1137 hr = IAudioClient_Stop(ac);
1140 hr = IAudioClient_GetCurrentPadding(ac, &pad);
1141 ok(
hr ==
S_OK,
"GetCurrentPadding failed: %08x\n",
hr);
1143 hr = IAudioClock_GetPosition(acl, &
pos, &pcpos);
1144 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
1145 trace(
"padding %u position %u past stop #3\n", pad, (
UINT)
pos);
1147 ok(pcpos > pcpos0,
"pcpos should increase\n");
1150 ok(
pos*1000/freq <= slept*1.1,
"Position %u too far after stop %ums\n", (
UINT)
pos, slept);
1153 "Position %u after stop vs. %u padding\n", (
UINT)
pos, pad);
1157 hr = IAudioClient_Reset(ac);
1164 hr = IAudioClient_Reset(ac);
1165 ok(
hr ==
S_OK,
"Reset on an already reset stream returns %08x\n",
hr);
1167 hr = IAudioClient_Start(ac);
1172 hr = IAudioRenderClient_GetBuffer(arc,
avail, &
data);
1173 ok(
hr ==
S_OK,
"GetBuffer failed: %08x\n",
hr);
1177 hr = IAudioClient_Stop(ac);
1183 hr = IAudioClient_Reset(ac);
1184 ok(
hr == AUDCLNT_E_BUFFER_OPERATION_PENDING,
"Reset failed: %08x\n",
hr);
1186 hr = IAudioClient_Start(ac);
1191 hr = IAudioRenderClient_ReleaseBuffer(arc,
avail,
1193 ok(
hr ==
S_OK,
"ReleaseBuffer after stop+start failed: %08x\n",
hr);
1206 trace(
"hpctime %u after %ums\n",
1209 hr = IAudioClock_GetPosition(acl, &
pos, &pcpos);
1210 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
1214 for(
i=0;
i < 9;
i++) {
1218 hr = IAudioClock_GetPosition(acl, &
pos, &pcpos);
1219 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
1221 hr = IAudioClient_GetCurrentPadding(ac, &pad);
1222 ok(
hr ==
S_OK,
"GetCurrentPadding failed: %08x\n",
hr);
1225 trace(
"hpctime %u pcpos %u\n",
1227 (
ULONG)((pcpos-pcpos0)/10000));
1230 trace(
"padding %u position %u/%u slept %ums iteration %d\n", pad, (
UINT)
pos,
sum-pad, slept,
i);
1231 ok(pad ?
pos >
last :
pos >=
last,
"No position increase at iteration %d\n",
i);
1236 ok(
pos*1000/freq <= slept*1.1,
"Position %u too far after %ums\n", (
UINT)
pos, slept);
1239 "Position delta %ld not regular: %ld ms\n", (
long)(
pos-
last), (
long)((
pos-
last)*1000/freq));
1243 hr = IAudioClient_GetStreamLatency(ac, &t1);
1244 ok(
hr ==
S_OK,
"GetStreamLatency failed: %08x\n",
hr);
1245 ok(t1 == t2,
"Latency not constant, delta %ld\n", (
long)(t1-t2));
1249 hr = IAudioRenderClient_GetBuffer(arc,
avail, &
data);
1251 ok(
hr ==
S_OK ||
hr == AUDCLNT_E_BUFFER_TOO_LARGE,
1252 "GetBuffer large (%u) failed: %08x\n",
avail,
hr);
1261 avail = gbsize - pad;
1262 hr = IAudioRenderClient_GetBuffer(arc,
avail, &
data);
1269 hr = IAudioRenderClient_ReleaseBuffer(arc,
avail, 0);
1271 hr = IAudioRenderClient_ReleaseBuffer(arc,
avail,
1274 ok(
hr ==
S_OK,
"ReleaseBuffer failed: %08x\n",
hr);
1278 hr = IAudioClock_GetPosition(acl, &
pos,
NULL);
1279 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
1284 hr = IAudioClient_GetCurrentPadding(ac, &pad);
1285 ok(
hr ==
S_OK,
"GetCurrentPadding failed: %08x\n",
hr);
1287 hr = IAudioClock_GetPosition(acl, &
pos,
NULL);
1288 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
1289 trace(
"position %u past underrun, %u padding left, %u frames written\n", (
UINT)
pos, pad,
sum);
1293 ok(pad == 0,
"GetCurrentPadding returned %u, should be 0\n", pad);
1295 "Position %u at end vs. %u submitted frames\n", (
UINT)
pos,
sum);
1299 pos * pwfx->
nSamplesPerSec == (
sum-pad) * freq,
"GetCurrentPadding returned %u, should be 0\n", pad);
1303 "Position %u at end vs. %u submitted frames\n", (
UINT)
pos,
sum);
1306 hr = IAudioClient_GetStreamLatency(ac, &t1);
1307 ok(
hr ==
S_OK,
"GetStreamLatency failed: %08x\n",
hr);
1308 ok(t1 == t2,
"Latency not constant, delta %ld\n", (
long)(t1-t2));
1313 hr = IAudioClient_Stop(ac);
1318 IAudioClock_Release(acl);
1319 IAudioRenderClient_Release(arc);
1320 IAudioClient_Release(ac);
1335 ok(
hr ==
S_OK,
"CoCreateGuid failed: %08x\n",
hr);
1337 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
1338 NULL, (
void**)&ses1_ac1);
1339 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
1342 hr = IAudioClient_GetMixFormat(ses1_ac1, &pwfx);
1343 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
1346 0, 5000000, 0, pwfx, &ses1_guid);
1347 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
1350 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
1351 NULL, (
void**)&ses1_ac2);
1352 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
1355 skip(
"Unable to open the same device twice. Skipping session tests\n");
1357 ref = IAudioClient_Release(ses1_ac1);
1358 ok(
ref == 0,
"AudioClient wasn't released: %u\n",
ref);
1364 0, 5000000, 0, pwfx, &ses1_guid);
1365 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
1367 hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(
mme,
eCapture,
1370 hr = IMMDevice_Activate(cap_dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
1371 NULL, (
void**)&cap_ac);
1372 ok((
hr ==
S_OK)^(cap_ac ==
NULL),
"Activate %08x &out pointer\n",
hr);
1373 ok(
hr ==
S_OK,
"Activate failed: %08x\n",
hr);
1374 IMMDevice_Release(cap_dev);
1379 hr = IAudioClient_GetMixFormat(cap_ac, &cap_pwfx);
1380 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
1383 0, 5000000, 0, cap_pwfx, &ses1_guid);
1384 ok(
hr ==
S_OK,
"Initialize failed for capture in rendering session: %08x\n",
hr);
1388 hr = IAudioClient_GetService(cap_ac, &IID_IAudioSessionControl, (
void**)&cap_ctl);
1389 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
1393 skip(
"No capture session: %08x; skipping capture device in render session tests\n",
hr);
1395 hr = IAudioClient_GetService(ses1_ac1, &IID_IAudioSessionControl2, (
void**)&ses1_ctl);
1398 hr = IAudioClient_GetService(ses1_ac1, &IID_IAudioSessionControl, (
void**)&ses1_ctl);
1399 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
1401 hr = IAudioClient_GetService(ses1_ac1, &IID_IAudioSessionControl, (
void**)&ses1_ctl2);
1402 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
1403 ok(ses1_ctl == ses1_ctl2,
"Got different controls: %p %p\n", ses1_ctl, ses1_ctl2);
1404 ref = IAudioSessionControl2_Release(ses1_ctl2);
1405 ok(
ref != 0,
"AudioSessionControl was destroyed\n");
1407 hr = IAudioClient_GetService(ses1_ac2, &IID_IAudioSessionControl, (
void**)&ses1_ctl2);
1408 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
1410 hr = IAudioSessionControl2_GetState(ses1_ctl,
NULL);
1413 hr = IAudioSessionControl2_GetState(ses1_ctl, &
state);
1414 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1417 hr = IAudioSessionControl2_GetState(ses1_ctl2, &
state);
1418 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1422 hr = IAudioSessionControl2_GetState(cap_ctl, &
state);
1423 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1427 hr = IAudioClient_Start(ses1_ac1);
1430 hr = IAudioSessionControl2_GetState(ses1_ctl, &
state);
1431 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1434 hr = IAudioSessionControl2_GetState(ses1_ctl2, &
state);
1435 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1439 hr = IAudioSessionControl2_GetState(cap_ctl, &
state);
1440 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1444 hr = IAudioClient_Stop(ses1_ac1);
1447 hr = IAudioSessionControl2_GetState(ses1_ctl, &
state);
1448 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1451 hr = IAudioSessionControl2_GetState(ses1_ctl2, &
state);
1452 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1456 hr = IAudioSessionControl2_GetState(cap_ctl, &
state);
1457 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1460 hr = IAudioClient_Start(cap_ac);
1463 hr = IAudioSessionControl2_GetState(ses1_ctl, &
state);
1464 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1467 hr = IAudioSessionControl2_GetState(ses1_ctl2, &
state);
1468 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1471 hr = IAudioSessionControl2_GetState(cap_ctl, &
state);
1472 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1475 hr = IAudioClient_Stop(cap_ac);
1478 hr = IAudioSessionControl2_GetState(ses1_ctl, &
state);
1479 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1482 hr = IAudioSessionControl2_GetState(ses1_ctl2, &
state);
1483 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1486 hr = IAudioSessionControl2_GetState(cap_ctl, &
state);
1487 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1490 ref = IAudioSessionControl2_Release(cap_ctl);
1491 ok(
ref == 0,
"AudioSessionControl wasn't released: %u\n",
ref);
1493 ref = IAudioClient_Release(cap_ac);
1494 ok(
ref == 0,
"AudioClient wasn't released: %u\n",
ref);
1497 ref = IAudioSessionControl2_Release(ses1_ctl);
1498 ok(
ref == 0,
"AudioSessionControl wasn't released: %u\n",
ref);
1500 ref = IAudioClient_Release(ses1_ac1);
1501 ok(
ref == 0,
"AudioClient wasn't released: %u\n",
ref);
1503 ref = IAudioClient_Release(ses1_ac2);
1504 ok(
ref == 1,
"AudioClient had wrong refcount: %u\n",
ref);
1507 hr = IAudioSessionControl2_GetState(ses1_ctl2, &
state);
1508 ok(
hr ==
S_OK,
"GetState failed: %08x\n",
hr);
1511 ref = IAudioSessionControl2_Release(ses1_ctl2);
1512 ok(
ref == 0,
"AudioSessionControl wasn't released: %u\n",
ref);
1526 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
1528 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
1532 hr = IAudioClient_GetMixFormat(ac, &
fmt);
1533 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
1537 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
1540 hr = IAudioClient_GetService(ac, &IID_IAudioStreamVolume, (
void**)&asv);
1541 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
1544 IAudioClient_Release(ac);
1549 hr = IAudioStreamVolume_GetChannelCount(asv,
NULL);
1552 hr = IAudioStreamVolume_GetChannelCount(asv, &chans);
1553 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
1554 ok(chans ==
fmt->nChannels,
"GetChannelCount gave wrong number of channels: %d\n", chans);
1556 hr = IAudioStreamVolume_GetChannelVolume(asv,
fmt->nChannels,
NULL);
1559 hr = IAudioStreamVolume_GetChannelVolume(asv,
fmt->nChannels, &vol);
1562 hr = IAudioStreamVolume_GetChannelVolume(asv, 0,
NULL);
1565 hr = IAudioStreamVolume_GetChannelVolume(asv, 0, &vol);
1566 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
1567 ok(vol == 1.f,
"Channel volume was not 1: %f\n", vol);
1569 hr = IAudioStreamVolume_SetChannelVolume(asv,
fmt->nChannels, -1.f);
1572 hr = IAudioStreamVolume_SetChannelVolume(asv, 0, -1.f);
1575 hr = IAudioStreamVolume_SetChannelVolume(asv, 0, 2.f);
1578 hr = IAudioStreamVolume_SetChannelVolume(asv, 0, 0.2f);
1579 ok(
hr ==
S_OK,
"SetChannelVolume failed: %08x\n",
hr);
1581 hr = IAudioStreamVolume_GetChannelVolume(asv, 0, &vol);
1582 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
1583 ok(
fabsf(vol - 0.2f) < 0.05f,
"Channel volume wasn't 0.2: %f\n", vol);
1585 hr = IAudioStreamVolume_GetAllVolumes(asv, 0,
NULL);
1588 hr = IAudioStreamVolume_GetAllVolumes(asv,
fmt->nChannels,
NULL);
1592 ok(vols !=
NULL,
"HeapAlloc failed\n");
1594 hr = IAudioStreamVolume_GetAllVolumes(asv,
fmt->nChannels - 1, vols);
1597 hr = IAudioStreamVolume_GetAllVolumes(asv,
fmt->nChannels, vols);
1598 ok(
hr ==
S_OK,
"GetAllVolumes failed: %08x\n",
hr);
1599 ok(
fabsf(vols[0] - 0.2f) < 0.05f,
"Channel 0 volume wasn't 0.2: %f\n", vol);
1600 for(
i = 1;
i <
fmt->nChannels; ++
i)
1601 ok(vols[
i] == 1.f,
"Channel %d volume is not 1: %f\n",
i, vols[
i]);
1603 hr = IAudioStreamVolume_SetAllVolumes(asv, 0,
NULL);
1606 hr = IAudioStreamVolume_SetAllVolumes(asv,
fmt->nChannels,
NULL);
1609 hr = IAudioStreamVolume_SetAllVolumes(asv,
fmt->nChannels - 1, vols);
1612 hr = IAudioStreamVolume_SetAllVolumes(asv,
fmt->nChannels, vols);
1613 ok(
hr ==
S_OK,
"SetAllVolumes failed: %08x\n",
hr);
1616 IAudioStreamVolume_Release(asv);
1617 IAudioClient_Release(ac);
1630 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
1632 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
1636 hr = IAudioClient_GetMixFormat(ac, &
fmt);
1637 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
1641 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
1644 hr = IAudioClient_GetService(ac, &IID_IChannelAudioVolume, (
void**)&acv);
1645 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
1648 IAudioClient_Release(ac);
1653 hr = IChannelAudioVolume_GetChannelCount(acv,
NULL);
1656 hr = IChannelAudioVolume_GetChannelCount(acv, &chans);
1657 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
1658 ok(chans ==
fmt->nChannels,
"GetChannelCount gave wrong number of channels: %d\n", chans);
1660 hr = IChannelAudioVolume_GetChannelVolume(acv,
fmt->nChannels,
NULL);
1663 hr = IChannelAudioVolume_GetChannelVolume(acv,
fmt->nChannels, &vol);
1666 hr = IChannelAudioVolume_GetChannelVolume(acv, 0,
NULL);
1669 hr = IChannelAudioVolume_GetChannelVolume(acv, 0, &vol);
1670 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
1671 ok(vol == 1.f,
"Channel volume was not 1: %f\n", vol);
1673 hr = IChannelAudioVolume_SetChannelVolume(acv,
fmt->nChannels, -1.f,
NULL);
1676 hr = IChannelAudioVolume_SetChannelVolume(acv, 0, -1.f,
NULL);
1679 hr = IChannelAudioVolume_SetChannelVolume(acv, 0, 2.f,
NULL);
1682 hr = IChannelAudioVolume_SetChannelVolume(acv, 0, 0.2f,
NULL);
1683 ok(
hr ==
S_OK,
"SetChannelVolume failed: %08x\n",
hr);
1685 hr = IChannelAudioVolume_GetChannelVolume(acv, 0, &vol);
1686 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
1687 ok(
fabsf(vol - 0.2f) < 0.05f,
"Channel volume wasn't 0.2: %f\n", vol);
1689 hr = IChannelAudioVolume_GetAllVolumes(acv, 0,
NULL);
1692 hr = IChannelAudioVolume_GetAllVolumes(acv,
fmt->nChannels,
NULL);
1696 ok(vols !=
NULL,
"HeapAlloc failed\n");
1698 hr = IChannelAudioVolume_GetAllVolumes(acv,
fmt->nChannels - 1, vols);
1701 hr = IChannelAudioVolume_GetAllVolumes(acv,
fmt->nChannels, vols);
1702 ok(
hr ==
S_OK,
"GetAllVolumes failed: %08x\n",
hr);
1703 ok(
fabsf(vols[0] - 0.2f) < 0.05f,
"Channel 0 volume wasn't 0.2: %f\n", vol);
1704 for(
i = 1;
i <
fmt->nChannels; ++
i)
1705 ok(vols[
i] == 1.f,
"Channel %d volume is not 1: %f\n",
i, vols[
i]);
1707 hr = IChannelAudioVolume_SetAllVolumes(acv, 0,
NULL,
NULL);
1710 hr = IChannelAudioVolume_SetAllVolumes(acv,
fmt->nChannels,
NULL,
NULL);
1713 hr = IChannelAudioVolume_SetAllVolumes(acv,
fmt->nChannels - 1, vols,
NULL);
1716 hr = IChannelAudioVolume_SetAllVolumes(acv,
fmt->nChannels, vols,
NULL);
1717 ok(
hr ==
S_OK,
"SetAllVolumes failed: %08x\n",
hr);
1719 hr = IChannelAudioVolume_SetChannelVolume(acv, 0, 1.0f,
NULL);
1720 ok(
hr ==
S_OK,
"SetChannelVolume failed: %08x\n",
hr);
1723 IChannelAudioVolume_Release(acv);
1724 IAudioClient_Release(ac);
1737 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
1739 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
1743 hr = IAudioClient_GetMixFormat(ac, &
fmt);
1744 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
1748 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
1751 hr = IAudioClient_GetService(ac, &IID_ISimpleAudioVolume, (
void**)&sav);
1752 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
1755 IAudioClient_Release(ac);
1760 hr = ISimpleAudioVolume_GetMasterVolume(sav,
NULL);
1763 hr = ISimpleAudioVolume_GetMasterVolume(sav, &vol);
1764 ok(
hr ==
S_OK,
"GetMasterVolume failed: %08x\n",
hr);
1765 ok(vol == 1.f,
"Master volume wasn't 1: %f\n", vol);
1767 hr = ISimpleAudioVolume_SetMasterVolume(sav, -1.f,
NULL);
1770 hr = ISimpleAudioVolume_SetMasterVolume(sav, 2.f,
NULL);
1773 hr = ISimpleAudioVolume_SetMasterVolume(sav, 0.2f,
NULL);
1774 ok(
hr ==
S_OK,
"SetMasterVolume failed: %08x\n",
hr);
1776 hr = ISimpleAudioVolume_GetMasterVolume(sav, &vol);
1777 ok(
hr ==
S_OK,
"GetMasterVolume failed: %08x\n",
hr);
1778 ok(
fabsf(vol - 0.2f) < 0.05f,
"Master volume wasn't 0.2: %f\n", vol);
1780 hr = ISimpleAudioVolume_GetMute(sav,
NULL);
1784 hr = ISimpleAudioVolume_GetMute(sav, &mute);
1785 ok(
hr ==
S_OK,
"GetMute failed: %08x\n",
hr);
1786 ok(mute ==
FALSE,
"Session is already muted\n");
1788 hr = ISimpleAudioVolume_SetMute(sav,
TRUE,
NULL);
1789 ok(
hr ==
S_OK,
"SetMute failed: %08x\n",
hr);
1792 hr = ISimpleAudioVolume_GetMute(sav, &mute);
1793 ok(
hr ==
S_OK,
"GetMute failed: %08x\n",
hr);
1794 ok(mute ==
TRUE,
"Session should have been muted\n");
1796 hr = ISimpleAudioVolume_GetMasterVolume(sav, &vol);
1797 ok(
hr ==
S_OK,
"GetMasterVolume failed: %08x\n",
hr);
1798 ok(
fabsf(vol - 0.2f) < 0.05f,
"Master volume wasn't 0.2: %f\n", vol);
1800 hr = ISimpleAudioVolume_SetMasterVolume(sav, 1.f,
NULL);
1801 ok(
hr ==
S_OK,
"SetMasterVolume failed: %08x\n",
hr);
1804 hr = ISimpleAudioVolume_GetMute(sav, &mute);
1805 ok(
hr ==
S_OK,
"GetMute failed: %08x\n",
hr);
1806 ok(mute ==
TRUE,
"Session should have been muted\n");
1808 hr = ISimpleAudioVolume_SetMute(sav,
FALSE,
NULL);
1809 ok(
hr ==
S_OK,
"SetMute failed: %08x\n",
hr);
1811 ISimpleAudioVolume_Release(sav);
1812 IAudioClient_Release(ac);
1829 ok(
hr ==
S_OK,
"CoCreateGuid failed: %08x\n",
hr);
1831 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
1833 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
1837 hr = IAudioClient_GetMixFormat(ac, &
fmt);
1838 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
1842 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
1845 hr = IAudioClient_GetService(ac, &IID_ISimpleAudioVolume, (
void**)&sav);
1846 ok(
hr ==
S_OK,
"GetService (SimpleAudioVolume) failed: %08x\n",
hr);
1849 IAudioClient_Release(ac);
1854 hr = IAudioClient_GetService(ac, &IID_IChannelAudioVolume, (
void**)&cav);
1855 ok(
hr ==
S_OK,
"GetService (ChannelAudioVolume) failed: %08x\n",
hr);
1857 hr = IAudioClient_GetService(ac, &IID_IAudioStreamVolume, (
void**)&asv);
1858 ok(
hr ==
S_OK,
"GetService (AudioStreamVolume) failed: %08x\n",
hr);
1860 hr = IAudioStreamVolume_SetChannelVolume(asv, 0, 0.2f);
1861 ok(
hr ==
S_OK,
"ASV_SetChannelVolume failed: %08x\n",
hr);
1863 hr = IChannelAudioVolume_SetChannelVolume(cav, 0, 0.4f,
NULL);
1864 ok(
hr ==
S_OK,
"CAV_SetChannelVolume failed: %08x\n",
hr);
1866 hr = ISimpleAudioVolume_SetMasterVolume(sav, 0.6f,
NULL);
1867 ok(
hr ==
S_OK,
"SAV_SetMasterVolume failed: %08x\n",
hr);
1869 hr = IAudioStreamVolume_GetChannelVolume(asv, 0, &vol);
1870 ok(
hr ==
S_OK,
"ASV_GetChannelVolume failed: %08x\n",
hr);
1871 ok(
fabsf(vol - 0.2f) < 0.05f,
"ASV_GetChannelVolume gave wrong volume: %f\n", vol);
1873 hr = IChannelAudioVolume_GetChannelVolume(cav, 0, &vol);
1874 ok(
hr ==
S_OK,
"CAV_GetChannelVolume failed: %08x\n",
hr);
1875 ok(
fabsf(vol - 0.4f) < 0.05f,
"CAV_GetChannelVolume gave wrong volume: %f\n", vol);
1877 hr = ISimpleAudioVolume_GetMasterVolume(sav, &vol);
1878 ok(
hr ==
S_OK,
"SAV_GetMasterVolume failed: %08x\n",
hr);
1879 ok(
fabsf(vol - 0.6f) < 0.05f,
"SAV_GetMasterVolume gave wrong volume: %f\n", vol);
1881 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
1882 NULL, (
void**)&ac2);
1883 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
1888 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
1890 IAudioClient_Release(ac2);
1897 hr = IAudioClient_GetService(ac2, &IID_IChannelAudioVolume, (
void**)&cav2);
1898 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
1900 hr = IAudioClient_GetService(ac2, &IID_IAudioStreamVolume, (
void**)&asv2);
1901 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
1903 hr = IChannelAudioVolume_GetChannelVolume(cav2, 0, &vol);
1904 ok(
hr ==
S_OK,
"CAV_GetChannelVolume failed: %08x\n",
hr);
1905 ok(
fabsf(vol - 0.4f) < 0.05f,
"CAV_GetChannelVolume gave wrong volume: %f\n", vol);
1907 hr = IAudioStreamVolume_GetChannelVolume(asv2, 0, &vol);
1908 ok(
hr ==
S_OK,
"ASV_GetChannelVolume failed: %08x\n",
hr);
1909 ok(vol == 1.f,
"ASV_GetChannelVolume gave wrong volume: %f\n", vol);
1911 hr = IChannelAudioVolume_GetChannelCount(cav2, &
nch);
1912 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
1913 ok(
nch ==
fmt->nChannels,
"Got wrong channel count, expected %u: %u\n",
fmt->nChannels,
nch);
1915 hr = IAudioStreamVolume_GetChannelCount(asv2, &
nch);
1916 ok(
hr ==
S_OK,
"GetChannelCount failed: %08x\n",
hr);
1917 ok(
nch ==
fmt->nChannels,
"Got wrong channel count, expected %u: %u\n",
fmt->nChannels,
nch);
1919 IAudioStreamVolume_Release(asv2);
1920 IChannelAudioVolume_Release(cav2);
1921 IAudioClient_Release(ac2);
1923 skip(
"Unable to open the same device twice. Skipping session volume control tests\n");
1925 hr = IChannelAudioVolume_SetChannelVolume(cav, 0, 1.f,
NULL);
1926 ok(
hr ==
S_OK,
"CAV_SetChannelVolume failed: %08x\n",
hr);
1928 hr = ISimpleAudioVolume_SetMasterVolume(sav, 1.f,
NULL);
1929 ok(
hr ==
S_OK,
"SAV_SetMasterVolume failed: %08x\n",
hr);
1932 ISimpleAudioVolume_Release(sav);
1933 IChannelAudioVolume_Release(cav);
1934 IAudioStreamVolume_Release(asv);
1935 IAudioClient_Release(ac);
1951 hr = IMMDevice_Activate(
dev, &IID_IAudioSessionManager,
1952 CLSCTX_INPROC_SERVER,
NULL, (
void**)&sesm);
1953 ok((
hr ==
S_OK)^(sesm ==
NULL),
"Activate %08x &out pointer\n",
hr);
1954 ok(
hr ==
S_OK,
"Activate failed: %08x\n",
hr);
1956 hr = IAudioSessionManager_GetSimpleAudioVolume(sesm, &session_guid,
1958 ok(
hr ==
S_OK,
"GetSimpleAudioVolume failed: %08x\n",
hr);
1960 hr = ISimpleAudioVolume_SetMasterVolume(sav, 0.6f,
NULL);
1961 ok(
hr ==
S_OK,
"SetMasterVolume failed: %08x\n",
hr);
1964 ISimpleAudioVolume_Release(sav);
1965 IAudioSessionManager_Release(sesm);
1969 hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(
mme,
eCapture,
1977 hr = IMMDevice_Activate(cap_dev, &IID_IAudioSessionManager,
1978 CLSCTX_INPROC_SERVER,
NULL, (
void**)&cap_sesm);
1979 ok((
hr ==
S_OK)^(cap_sesm ==
NULL),
"Activate %08x &out pointer\n",
hr);
1980 ok(
hr ==
S_OK,
"Activate failed: %08x\n",
hr);
1982 hr = IAudioSessionManager_GetSimpleAudioVolume(cap_sesm, &session_guid,
1984 ok(
hr ==
S_OK,
"GetSimpleAudioVolume failed: %08x\n",
hr);
1987 hr = ISimpleAudioVolume_GetMasterVolume(cap_sav, &vol);
1988 ok(
hr ==
S_OK,
"GetMasterVolume failed: %08x\n",
hr);
1990 ISimpleAudioVolume_Release(cap_sav);
1991 IAudioSessionManager_Release(cap_sesm);
1993 hr = IMMDevice_Activate(cap_dev, &IID_IAudioClient,
1994 CLSCTX_INPROC_SERVER,
NULL, (
void**)&cap_ac);
1995 ok(
hr ==
S_OK,
"Activate failed: %08x\n",
hr);
1997 IMMDevice_Release(cap_dev);
1999 hr = IAudioClient_GetMixFormat(cap_ac, &cap_pwfx);
2000 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
2003 0, 5000000, 0, cap_pwfx, &session_guid);
2004 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
2009 hr = IAudioClient_GetService(cap_ac, &IID_ISimpleAudioVolume,
2011 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
2015 hr = ISimpleAudioVolume_GetMasterVolume(cap_sav, &vol);
2016 ok(
hr ==
S_OK,
"GetMasterVolume failed: %08x\n",
hr);
2018 ISimpleAudioVolume_Release(cap_sav);
2021 IAudioClient_Release(cap_ac);
2024 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
2026 ok((
hr ==
S_OK)^(ac ==
NULL),
"Activate %08x &out pointer\n",
hr);
2027 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
2031 hr = IAudioClient_GetMixFormat(ac, &
fmt);
2032 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
2036 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
2038 hr = IAudioClient_GetService(ac, &IID_ISimpleAudioVolume, (
void**)&sav);
2039 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
2042 hr = ISimpleAudioVolume_GetMasterVolume(sav, &vol);
2043 ok(
hr ==
S_OK,
"GetMasterVolume failed: %08x\n",
hr);
2044 ok(
fabs(vol - 0.6f) < 0.05f,
"Got wrong volume: %f\n", vol);
2046 ISimpleAudioVolume_Release(sav);
2050 IAudioClient_Release(ac);
2068 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
2070 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
2074 hr = IAudioClient_GetMixFormat(ac, &pwfx);
2075 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
2079 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
2083 hr = IAudioClient_GetDevicePeriod(ac, &defp,
NULL);
2084 ok(
hr ==
S_OK,
"GetDevicePeriod failed: %08x\n",
hr);
2091 hr = IAudioClient_SetEventHandle(ac,
event);
2092 ok(
hr ==
S_OK,
"SetEventHandle failed: %08x\n",
hr);
2094 hr = IAudioClient_GetService(ac, &IID_IAudioRenderClient, (
void**)&arc);
2095 ok(
hr ==
S_OK,
"GetService(IAudioRenderClient) failed: %08x\n",
hr);
2097 hr = IAudioClient_GetService(ac, &IID_IAudioClock, (
void**)&acl);
2098 ok(
hr ==
S_OK,
"GetService(IAudioClock) failed: %08x\n",
hr);
2100 hr = IAudioClock_GetFrequency(acl, &freq);
2101 ok(
hr ==
S_OK,
"GetFrequency failed: %08x\n",
hr);
2105 trace(
"Should play %ums continuous tone with fragment size %u.\n",
2106 (
ULONG)(defp/100), fragment);
2108 hr = IAudioClock_GetPosition(acl, &
pos, &pcpos0);
2109 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
2113 hr = IAudioRenderClient_GetBuffer(arc, fragment, &
data);
2114 ok(
hr ==
S_OK,
"GetBuffer failed: %08x\n",
hr);
2117 ok(
hr ==
S_OK,
"ReleaseBuffer failed: %08x\n",
hr);
2122 hr = IAudioClient_Start(ac);
2125 for(
i = 0;
i <= 99;
i++){
2130 Sleep((
i % 10) * defp / 120000);
2132 hr = IAudioClient_GetCurrentPadding(ac, &pad);
2133 ok(
hr ==
S_OK,
"GetCurrentPadding failed: %08x\n",
hr);
2136 if(pad <= fragment){
2137 hr = IAudioRenderClient_GetBuffer(arc, fragment, &
data);
2138 ok(
hr ==
S_OK,
"GetBuffer failed: %08x\n",
hr);
2140 hr = IAudioRenderClient_ReleaseBuffer(arc, fragment,
2142 ok(
hr ==
S_OK,
"ReleaseBuffer failed: %08x\n",
hr);
2148 hr = IAudioClient_Stop(ac);
2151 hr = IAudioClient_GetCurrentPadding(ac, &pad);
2152 ok(
hr ==
S_OK,
"GetCurrentPadding failed: %08x\n",
hr);
2154 hr = IAudioClock_GetPosition(acl, &
pos, &pcpos);
2155 ok(
hr ==
S_OK,
"GetPosition failed: %08x\n",
hr);
2159 trace(
"Released %u=%ux%u -%u frames at %u worth %ums in %ums\n",
2160 sum,
sum/fragment, fragment, pad,
2162 (
ULONG)((pcpos-pcpos0)/10000));
2165 "Position %u at end vs. %u-%u submitted frames\n", (
UINT)
pos,
sum, pad);
2167 hr = IAudioClient_Reset(ac);
2174 IAudioClient_Release(ac);
2175 IAudioClock_Release(acl);
2176 IAudioRenderClient_Release(arc);
2188 hr = IMMDevice_Activate(
dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
2190 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
2194 hr = IAudioClient_GetMixFormat(ac, &pwfx);
2195 ok(
hr ==
S_OK,
"GetMixFormat failed: %08x\n",
hr);
2199 ok(
hr ==
S_OK,
"Initialize failed: %08x\n",
hr);
2203 hr = IAudioClient_GetService(ac, &IID_IAudioRenderClient, (
void**)&rc);
2204 ok(
hr ==
S_OK,
"GetService failed: %08x\n",
hr);
2206 IAudioClient_Release(ac);
2211 ok(
hr ==
S_OK,
"CreateStreamOnHGlobal failed 0x%08x\n",
hr);
2216 ok(
hr ==
S_OK,
"CoMarshalInterface IAudioClient failed 0x%08x\n",
hr);
2218 IStream_Seek(pStream,
ullZero, STREAM_SEEK_SET,
NULL);
2220 ok(
hr ==
S_OK,
"CoUnmarshalInterface IAudioClient failed 0x%08x\n",
hr);
2222 IAudioClient_Release(acDest);
2224 IStream_Seek(pStream,
ullZero, STREAM_SEEK_SET,
NULL);
2228 ok(
hr ==
S_OK,
"CoMarshalInterface IAudioRenderClient failed 0x%08x\n",
hr);
2230 IStream_Seek(pStream,
ullZero, STREAM_SEEK_SET,
NULL);
2232 ok(
hr ==
S_OK,
"CoUnmarshalInterface IAudioRenderClient failed 0x%08x\n",
hr);
2234 IAudioRenderClient_Release(rcDest);
2237 IStream_Release(pStream);
2239 IAudioClient_Release(ac);
2240 IAudioRenderClient_Release(rc);
2248 float mindb, maxdb, increment,
volume;
2251 hr = IMMDevice_Activate(
dev, &IID_IAudioEndpointVolume,
2252 CLSCTX_INPROC_SERVER,
NULL, (
void**)&aev);
2253 ok(
hr ==
S_OK,
"Activation failed with %08x\n",
hr);
2257 hr = IAudioEndpointVolume_GetVolumeRange(aev, &mindb,
NULL,
NULL);
2258 ok(
hr ==
E_POINTER,
"GetVolumeRange should have failed with E_POINTER: 0x%08x\n",
hr);
2260 hr = IAudioEndpointVolume_GetVolumeRange(aev, &mindb, &maxdb, &increment);
2261 ok(
hr ==
S_OK,
"GetVolumeRange failed: 0x%08x\n",
hr);
2262 trace(
"got range: [%f,%f]/%f\n", mindb, maxdb, increment);
2264 hr = IAudioEndpointVolume_SetMasterVolumeLevel(aev, mindb - increment,
NULL);
2267 hr = IAudioEndpointVolume_GetMasterVolumeLevel(aev, &
volume);
2268 ok(
hr ==
S_OK,
"GetMasterVolumeLevel failed: 0x%08x\n",
hr);
2270 hr = IAudioEndpointVolume_SetMasterVolumeLevel(aev,
volume,
NULL);
2271 ok(
hr ==
S_OK,
"SetMasterVolumeLevel failed: 0x%08x\n",
hr);
2273 hr = IAudioEndpointVolume_GetMute(aev, &mute);
2274 ok(
hr ==
S_OK,
"GetMute failed: %08x\n",
hr);
2276 hr = IAudioEndpointVolume_SetMute(aev, mute,
NULL);
2279 IAudioEndpointVolume_Release(aev);
2290 skip(
"mmdevapi not available: 0x%08x\n",
hr);
2295 ok(
hr ==
S_OK ||
hr == E_NOTFOUND,
"GetDefaultAudioEndpoint failed: 0x%08x\n",
hr);
2298 if (
hr == E_NOTFOUND)
2299 skip(
"No sound card available\n");
2301 skip(
"GetDefaultAudioEndpoint returns 0x%08x\n",
hr);
2310 trace(
"Output to a MS-DOS console is particularly slow and disturbs timing.\n");
2311 trace(
"Please redirect output to a file.\n");
2325 IMMDevice_Release(
dev);
2329 IMMDeviceEnumerator_Release(
mme);
std::map< E_STRING, PART_TEST > parts
unsigned long long UINT64
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
@ AUDCLNT_BUFFERFLAGS_SILENT
#define AUDCLNT_STREAMFLAGS_EVENTCALLBACK
@ AudioSessionStateActive
@ AudioSessionStateInactive
@ AUDCLNT_SHAREMODE_SHARED
@ AUDCLNT_SHAREMODE_EXCLUSIVE
enum _AudioSessionState AudioSessionState
enum _AUDCLNT_SHAREMODE AUDCLNT_SHAREMODE
#define AUDCLNT_STREAMFLAGS_NOPERSIST
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
#define HeapFree(x, y, z)
#define ERROR_INVALID_NAME
static void cleanup(void)
BOOL WINAPI QueryPerformanceFrequency(OUT PLARGE_INTEGER lpFrequency)
BOOL WINAPI QueryPerformanceCounter(OUT PLARGE_INTEGER lpPerformanceCount)
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 GLint GLint GLint GLint GLint y
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLdouble GLdouble GLdouble r
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLuint GLsizei bufsize
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
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 GLint GLint j
VOID WINAPI CoTaskMemFree(LPVOID ptr)
_Check_return_ __CRT_INLINE float __CRTDECL fabsf(_In_ float x)
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)
#define ERROR_FILE_NOT_FOUND
static void test_simplevolume(void)
static void test_formats(AUDCLNT_SHAREMODE mode)
static DWORD wave_generate_tone(PWAVEFORMATEX pwfx, BYTE *data, UINT32 frames)
static void test_audioclient(void)
static const LARGE_INTEGER ullZero
static void test_marshal(void)
static void test_session(void)
static void test_references(void)
static void test_uninitialized(IAudioClient *ac)
static void test_channelvolume(void)
static void test_streamvolume(void)
static IMMDeviceEnumerator * mme
static void test_session_creation(void)
static void test_event(void)
static void test_worst_case(void)
static void test_padding(void)
static void test_endpointvolume(void)
static const unsigned int win_formats[][4]
static void test_volume_dependence(void)
static void test_clock(void)
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
_Must_inspect_result_ _Out_ LPSIZE psize
#define IsEqualGUID(rguid1, rguid2)
static int sum(int x_, int y_)
union WAVEFORMATEXTENSIBLE::@3111 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)
#define ERROR_BAD_PATHNAME
#define HRESULT_FROM_WIN32(x)