2010-02-21 11:53:11 +01:00
|
|
|
/*
|
2010-03-20 15:24:53 +01:00
|
|
|
* Copyright 2010 Maarten Lankhorst for CodeWeavers
|
2010-02-21 11:53:11 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* This test is for audio playback specific mechanisms
|
|
|
|
* Tests:
|
|
|
|
* - IAudioClient with eRender and IAudioRenderClient
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#ifdef STANDALONE
|
|
|
|
#include "initguid.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "unknwn.h"
|
|
|
|
#include "uuids.h"
|
|
|
|
#include "mmdeviceapi.h"
|
|
|
|
#include "audioclient.h"
|
|
|
|
|
2011-01-10 21:10:44 +01:00
|
|
|
static IMMDevice *dev = NULL;
|
|
|
|
|
2010-02-21 11:53:11 +01:00
|
|
|
static void test_uninitialized(IAudioClient *ac)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
UINT32 num;
|
|
|
|
REFERENCE_TIME t1;
|
|
|
|
|
|
|
|
HANDLE handle = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
|
|
IUnknown *unk;
|
|
|
|
|
|
|
|
hr = IAudioClient_GetBufferSize(ac, &num);
|
|
|
|
ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized GetBufferSize call returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_GetStreamLatency(ac, &t1);
|
|
|
|
ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized GetStreamLatency call returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_GetCurrentPadding(ac, &num);
|
|
|
|
ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized GetCurrentPadding call returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_Start(ac);
|
|
|
|
ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized Start call returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_Stop(ac);
|
|
|
|
ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized Stop call returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_Reset(ac);
|
|
|
|
ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized Reset call returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_SetEventHandle(ac, handle);
|
|
|
|
ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized SetEventHandle call returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_GetService(ac, &IID_IAudioStreamVolume, (void**)&unk);
|
|
|
|
ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Uninitialized GetService call returns %08x\n", hr);
|
|
|
|
|
|
|
|
CloseHandle(handle);
|
|
|
|
}
|
|
|
|
|
2011-01-10 21:10:44 +01:00
|
|
|
static void test_audioclient(void)
|
2010-02-21 11:53:11 +01:00
|
|
|
{
|
2011-01-10 21:10:44 +01:00
|
|
|
IAudioClient *ac;
|
2010-02-21 11:53:11 +01:00
|
|
|
IUnknown *unk;
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG ref;
|
|
|
|
WAVEFORMATEX *pwfx, *pwfx2;
|
|
|
|
REFERENCE_TIME t1, t2;
|
2011-01-10 21:10:44 +01:00
|
|
|
HANDLE handle;
|
2010-02-21 11:53:11 +01:00
|
|
|
|
2011-01-10 21:10:44 +01:00
|
|
|
hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
|
|
|
|
NULL, (void**)&ac);
|
|
|
|
ok(hr == S_OK, "Activation failed with %08x\n", hr);
|
|
|
|
if(hr != S_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
handle = CreateEventW(NULL, FALSE, FALSE, NULL);
|
2010-02-21 11:53:11 +01:00
|
|
|
|
|
|
|
hr = IAudioClient_QueryInterface(ac, &IID_IUnknown, NULL);
|
|
|
|
ok(hr == E_POINTER, "QueryInterface(NULL) returned %08x\n", hr);
|
|
|
|
|
|
|
|
unk = (void*)(LONG_PTR)0x12345678;
|
|
|
|
hr = IAudioClient_QueryInterface(ac, &IID_NULL, (void**)&unk);
|
|
|
|
ok(hr == E_NOINTERFACE, "QueryInterface(IID_NULL) returned %08x\n", hr);
|
|
|
|
ok(!unk, "QueryInterface(IID_NULL) returned non-null pointer %p\n", unk);
|
|
|
|
|
|
|
|
hr = IAudioClient_QueryInterface(ac, &IID_IUnknown, (void**)&unk);
|
|
|
|
ok(hr == S_OK, "QueryInterface(IID_IUnknown) returned %08x\n", hr);
|
|
|
|
if (unk)
|
|
|
|
{
|
|
|
|
ref = IUnknown_Release(unk);
|
|
|
|
ok(ref == 1, "Released count is %u\n", ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IAudioClient_QueryInterface(ac, &IID_IAudioClient, (void**)&unk);
|
|
|
|
ok(hr == S_OK, "QueryInterface(IID_IAudioClient) returned %08x\n", hr);
|
|
|
|
if (unk)
|
|
|
|
{
|
|
|
|
ref = IUnknown_Release(unk);
|
|
|
|
ok(ref == 1, "Released count is %u\n", ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IAudioClient_GetDevicePeriod(ac, NULL, NULL);
|
|
|
|
ok(hr == E_POINTER, "Invalid GetDevicePeriod call returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_GetDevicePeriod(ac, &t1, NULL);
|
2010-04-19 11:52:49 +02:00
|
|
|
ok(hr == S_OK, "Valid GetDevicePeriod call returns %08x\n", hr);
|
2010-02-21 11:53:11 +01:00
|
|
|
|
|
|
|
hr = IAudioClient_GetDevicePeriod(ac, NULL, &t2);
|
2010-04-19 11:52:49 +02:00
|
|
|
ok(hr == S_OK, "Valid GetDevicePeriod call returns %08x\n", hr);
|
2010-02-21 11:53:11 +01:00
|
|
|
|
|
|
|
hr = IAudioClient_GetDevicePeriod(ac, &t1, &t2);
|
2010-04-19 11:52:49 +02:00
|
|
|
ok(hr == S_OK, "Valid GetDevicePeriod call returns %08x\n", hr);
|
2010-02-21 11:53:11 +01:00
|
|
|
trace("Returned periods: %u.%05u ms %u.%05u ms\n",
|
|
|
|
(UINT)(t1/10000), (UINT)(t1 % 10000),
|
|
|
|
(UINT)(t2/10000), (UINT)(t2 % 10000));
|
|
|
|
|
|
|
|
hr = IAudioClient_GetMixFormat(ac, NULL);
|
|
|
|
ok(hr == E_POINTER, "GetMixFormat returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_GetMixFormat(ac, &pwfx);
|
2010-04-19 11:52:49 +02:00
|
|
|
ok(hr == S_OK, "Valid GetMixFormat returns %08x\n", hr);
|
|
|
|
|
2010-02-21 11:53:11 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
2010-07-29 19:16:17 +02:00
|
|
|
trace("pwfx: %p\n", pwfx);
|
|
|
|
trace("Tag: %04x\n", pwfx->wFormatTag);
|
|
|
|
trace("bits: %u\n", pwfx->wBitsPerSample);
|
|
|
|
trace("chan: %u\n", pwfx->nChannels);
|
|
|
|
trace("rate: %u\n", pwfx->nSamplesPerSec);
|
|
|
|
trace("align: %u\n", pwfx->nBlockAlign);
|
|
|
|
trace("extra: %u\n", pwfx->cbSize);
|
|
|
|
ok(pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE, "wFormatTag is %x\n", pwfx->wFormatTag);
|
|
|
|
if (pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
|
|
|
|
{
|
|
|
|
WAVEFORMATEXTENSIBLE *pwfxe = (void*)pwfx;
|
|
|
|
trace("Res: %u\n", pwfxe->Samples.wReserved);
|
|
|
|
trace("Mask: %x\n", pwfxe->dwChannelMask);
|
|
|
|
trace("Alg: %s\n",
|
|
|
|
IsEqualGUID(&pwfxe->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)?"PCM":
|
|
|
|
(IsEqualGUID(&pwfxe->SubFormat,
|
|
|
|
&KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)?"FLOAT":"Other"));
|
|
|
|
}
|
|
|
|
|
2010-02-21 11:53:11 +01:00
|
|
|
hr = IAudioClient_IsFormatSupported(ac, AUDCLNT_SHAREMODE_SHARED, pwfx, &pwfx2);
|
|
|
|
ok(hr == S_OK, "Valid IsFormatSupported(Shared) call returns %08x\n", hr);
|
|
|
|
ok(pwfx2 == NULL, "pwfx2 is non-null\n");
|
|
|
|
CoTaskMemFree(pwfx2);
|
|
|
|
|
|
|
|
hr = IAudioClient_IsFormatSupported(ac, AUDCLNT_SHAREMODE_SHARED, NULL, NULL);
|
|
|
|
ok(hr == E_POINTER, "IsFormatSupported(NULL) call returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_IsFormatSupported(ac, AUDCLNT_SHAREMODE_SHARED, pwfx, NULL);
|
|
|
|
ok(hr == E_POINTER, "IsFormatSupported(Shared,NULL) call returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_IsFormatSupported(ac, AUDCLNT_SHAREMODE_EXCLUSIVE, pwfx, NULL);
|
|
|
|
ok(hr == S_OK || hr == AUDCLNT_E_UNSUPPORTED_FORMAT, "IsFormatSupported(Exclusive) call returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_IsFormatSupported(ac, AUDCLNT_SHAREMODE_EXCLUSIVE, pwfx, &pwfx2);
|
|
|
|
ok(hr == S_OK || hr == AUDCLNT_E_UNSUPPORTED_FORMAT, "IsFormatSupported(Exclusive) call returns %08x\n", hr);
|
|
|
|
ok(pwfx2 == NULL, "pwfx2 non-null on exclusive IsFormatSupported\n");
|
|
|
|
|
|
|
|
hr = IAudioClient_IsFormatSupported(ac, 0xffffffff, pwfx, NULL);
|
2010-11-11 00:22:05 +01:00
|
|
|
ok(hr == E_INVALIDARG ||
|
|
|
|
hr == AUDCLNT_E_UNSUPPORTED_FORMAT,
|
|
|
|
"IsFormatSupported(0xffffffff) call returns %08x\n", hr);
|
2010-02-21 11:53:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
test_uninitialized(ac);
|
|
|
|
|
|
|
|
hr = IAudioClient_Initialize(ac, 3, 0, 5000000, 0, pwfx, NULL);
|
2010-04-19 11:52:49 +02:00
|
|
|
ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Initialize with invalid sharemode returns %08x\n", hr);
|
2010-02-21 11:53:11 +01:00
|
|
|
|
|
|
|
hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0xffffffff, 5000000, 0, pwfx, NULL);
|
2010-04-19 11:52:49 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Initialize with invalid flags returns %08x\n", hr);
|
2010-02-21 11:53:11 +01:00
|
|
|
|
|
|
|
/* It seems that if length > 2s or periodicity != 0 the length is ignored and call succeeds
|
2010-03-20 15:24:53 +01:00
|
|
|
* Since we can only initialize successfully once, skip those tests.
|
2010-02-21 11:53:11 +01:00
|
|
|
*/
|
|
|
|
hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 5000000, 0, NULL, NULL);
|
2010-04-19 11:52:49 +02:00
|
|
|
ok(hr == E_POINTER, "Initialize with null format returns %08x\n", hr);
|
2010-02-21 11:53:11 +01:00
|
|
|
|
|
|
|
hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 5000000, 0, pwfx, NULL);
|
2010-04-19 11:52:49 +02:00
|
|
|
ok(hr == S_OK, "Valid Initialize returns %08x\n", hr);
|
2010-02-21 11:53:11 +01:00
|
|
|
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
skip("Cannot initialize %08x, remainder of tests is useless\n", hr);
|
|
|
|
CoTaskMemFree(pwfx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-17 22:06:47 +01:00
|
|
|
hr = IAudioClient_GetStreamLatency(ac, NULL);
|
|
|
|
ok(hr == E_POINTER, "GetStreamLatency(NULL) call returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_GetStreamLatency(ac, &t1);
|
|
|
|
ok(hr == S_OK, "Valid GetStreamLatency call returns %08x\n", hr);
|
|
|
|
trace("Returned latency: %u.%05u ms\n",
|
|
|
|
(UINT)(t1/10000), (UINT)(t1 % 10000));
|
|
|
|
|
2010-02-21 11:53:11 +01:00
|
|
|
hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 5000000, 0, pwfx, NULL);
|
|
|
|
ok(hr == AUDCLNT_E_ALREADY_INITIALIZED, "Calling Initialize twice returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_SetEventHandle(ac, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "SetEventHandle(NULL) returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_SetEventHandle(ac, handle);
|
2010-03-05 07:00:00 +01:00
|
|
|
ok(hr == AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED ||
|
2010-11-10 00:07:08 +01:00
|
|
|
broken(hr == HRESULT_FROM_WIN32(ERROR_INVALID_NAME)) ||
|
|
|
|
broken(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) /* Some 2k8 */ ||
|
|
|
|
broken(hr == HRESULT_FROM_WIN32(ERROR_BAD_PATHNAME)) /* Some Vista */
|
2010-03-05 07:00:00 +01:00
|
|
|
, "SetEventHandle returns %08x\n", hr);
|
2010-02-21 11:53:11 +01:00
|
|
|
|
2010-03-17 22:06:47 +01:00
|
|
|
hr = IAudioClient_Reset(ac);
|
|
|
|
ok(hr == S_OK, "Reset on a resetted stream returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_Stop(ac);
|
|
|
|
ok(hr == S_FALSE, "Stop on a stopped stream returns %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_Start(ac);
|
|
|
|
ok(hr == S_OK, "Start on a stopped stream returns %08x\n", hr);
|
|
|
|
|
2011-01-10 21:10:44 +01:00
|
|
|
IAudioClient_Release(ac);
|
|
|
|
|
2010-02-21 11:53:11 +01:00
|
|
|
CloseHandle(handle);
|
|
|
|
CoTaskMemFree(pwfx);
|
|
|
|
}
|
|
|
|
|
2011-01-10 21:10:44 +01:00
|
|
|
static void test_references(void)
|
|
|
|
{
|
|
|
|
IAudioClient *ac;
|
|
|
|
IAudioRenderClient *rc;
|
|
|
|
ISimpleAudioVolume *sav;
|
|
|
|
IAudioClock *acl;
|
|
|
|
WAVEFORMATEX *pwfx;
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG ref;
|
|
|
|
|
|
|
|
/* IAudioRenderClient */
|
|
|
|
hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
|
|
|
|
NULL, (void**)&ac);
|
|
|
|
ok(hr == S_OK, "Activation failed with %08x\n", hr);
|
|
|
|
if(hr != S_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hr = IAudioClient_GetMixFormat(ac, &pwfx);
|
|
|
|
ok(hr == S_OK, "GetMixFormat failed: %08x\n", hr);
|
|
|
|
if(hr != S_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 5000000,
|
|
|
|
0, pwfx, NULL);
|
|
|
|
ok(hr == S_OK, "Initialize failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_GetService(ac, &IID_IAudioRenderClient, (void**)&rc);
|
|
|
|
ok(hr == S_OK, "GetService failed: %08x\n", hr);
|
|
|
|
|
|
|
|
IAudioRenderClient_AddRef(rc);
|
|
|
|
ref = IAudioRenderClient_Release(rc);
|
|
|
|
ok(ref != 0, "RenderClient_Release gave wrong refcount: %u\n", ref);
|
|
|
|
|
|
|
|
ref = IAudioClient_Release(ac);
|
|
|
|
ok(ref != 0, "Client_Release gave wrong refcount: %u\n", ref);
|
|
|
|
|
|
|
|
ref = IAudioRenderClient_Release(rc);
|
|
|
|
ok(ref == 0, "RenderClient_Release gave wrong refcount: %u\n", ref);
|
|
|
|
|
|
|
|
/* ISimpleAudioVolume */
|
|
|
|
hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
|
|
|
|
NULL, (void**)&ac);
|
|
|
|
ok(hr == S_OK, "Activation failed with %08x\n", hr);
|
|
|
|
if(hr != S_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hr = IAudioClient_GetMixFormat(ac, &pwfx);
|
|
|
|
ok(hr == S_OK, "GetMixFormat failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 5000000,
|
|
|
|
0, pwfx, NULL);
|
|
|
|
ok(hr == S_OK, "Initialize failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_GetService(ac, &IID_ISimpleAudioVolume, (void**)&sav);
|
|
|
|
ok(hr == S_OK, "GetService failed: %08x\n", hr);
|
|
|
|
|
|
|
|
ISimpleAudioVolume_AddRef(sav);
|
|
|
|
ref = ISimpleAudioVolume_Release(sav);
|
|
|
|
ok(ref != 0, "SimpleAudioVolume_Release gave wrong refcount: %u\n", ref);
|
|
|
|
|
|
|
|
ref = IAudioClient_Release(ac);
|
|
|
|
ok(ref != 0, "Client_Release gave wrong refcount: %u\n", ref);
|
|
|
|
|
|
|
|
ref = ISimpleAudioVolume_Release(sav);
|
|
|
|
ok(ref == 0, "SimpleAudioVolume_Release gave wrong refcount: %u\n", ref);
|
|
|
|
|
|
|
|
/* IAudioClock */
|
|
|
|
hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
|
|
|
|
NULL, (void**)&ac);
|
|
|
|
ok(hr == S_OK, "Activation failed with %08x\n", hr);
|
|
|
|
if(hr != S_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hr = IAudioClient_GetMixFormat(ac, &pwfx);
|
|
|
|
ok(hr == S_OK, "GetMixFormat failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 5000000,
|
|
|
|
0, pwfx, NULL);
|
|
|
|
ok(hr == S_OK, "Initialize failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_GetService(ac, &IID_IAudioClock, (void**)&acl);
|
|
|
|
ok(hr == S_OK, "GetService failed: %08x\n", hr);
|
|
|
|
|
|
|
|
IAudioClock_AddRef(acl);
|
|
|
|
ref = IAudioClock_Release(acl);
|
|
|
|
ok(ref != 0, "AudioClock_Release gave wrong refcount: %u\n", ref);
|
|
|
|
|
|
|
|
ref = IAudioClient_Release(ac);
|
|
|
|
ok(ref != 0, "Client_Release gave wrong refcount: %u\n", ref);
|
|
|
|
|
|
|
|
ref = IAudioClock_Release(acl);
|
|
|
|
ok(ref == 0, "AudioClock_Release gave wrong refcount: %u\n", ref);
|
|
|
|
}
|
|
|
|
|
2011-01-10 21:10:50 +01:00
|
|
|
static void test_event(void)
|
|
|
|
{
|
|
|
|
HANDLE event;
|
|
|
|
HRESULT hr;
|
|
|
|
IAudioClient *ac;
|
|
|
|
WAVEFORMATEX *pwfx;
|
|
|
|
|
|
|
|
hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
|
|
|
|
NULL, (void**)&ac);
|
|
|
|
ok(hr == S_OK, "Activation failed with %08x\n", hr);
|
|
|
|
if(hr != S_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hr = IAudioClient_GetMixFormat(ac, &pwfx);
|
|
|
|
ok(hr == S_OK, "GetMixFormat failed: %08x\n", hr);
|
|
|
|
if(hr != S_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED,
|
|
|
|
AUDCLNT_STREAMFLAGS_EVENTCALLBACK, 5000000,
|
|
|
|
0, pwfx, NULL);
|
|
|
|
ok(hr == S_OK, "Initialize failed: %08x\n", hr);
|
|
|
|
|
|
|
|
event = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
|
|
ok(event != NULL, "CreateEvent failed\n");
|
|
|
|
|
|
|
|
hr = IAudioClient_Start(ac);
|
|
|
|
ok(hr == AUDCLNT_E_EVENTHANDLE_NOT_SET, "Start failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_SetEventHandle(ac, event);
|
|
|
|
ok(hr == S_OK, "SetEventHandle failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_Start(ac);
|
|
|
|
ok(hr == S_OK, "Start failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IAudioClient_Stop(ac);
|
|
|
|
ok(hr == S_OK, "Start failed: %08x\n", hr);
|
|
|
|
|
|
|
|
/* test releasing a playing stream */
|
|
|
|
hr = IAudioClient_Start(ac);
|
|
|
|
ok(hr == S_OK, "Start failed: %08x\n", hr);
|
|
|
|
IAudioClient_Release(ac);
|
|
|
|
|
|
|
|
CloseHandle(event);
|
|
|
|
}
|
|
|
|
|
2010-02-21 11:53:11 +01:00
|
|
|
START_TEST(render)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IMMDeviceEnumerator *mme = NULL;
|
|
|
|
|
|
|
|
CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
|
|
|
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&mme);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
skip("mmdevapi not available: 0x%08x\n", hr);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(mme, eRender, eMultimedia, &dev);
|
|
|
|
ok(hr == S_OK || hr == E_NOTFOUND, "GetDefaultAudioEndpoint failed: 0x%08x\n", hr);
|
|
|
|
if (hr != S_OK || !dev)
|
|
|
|
{
|
|
|
|
if (hr == E_NOTFOUND)
|
|
|
|
skip("No sound card available\n");
|
|
|
|
else
|
|
|
|
skip("GetDefaultAudioEndpoint returns 0x%08x\n", hr);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-01-10 21:10:44 +01:00
|
|
|
test_audioclient();
|
|
|
|
test_references();
|
2011-01-10 21:10:50 +01:00
|
|
|
test_event();
|
2011-01-10 21:10:44 +01:00
|
|
|
|
2010-02-21 11:53:11 +01:00
|
|
|
IMMDevice_Release(dev);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (mme)
|
|
|
|
IMMDeviceEnumerator_Release(mme);
|
|
|
|
CoUninitialize();
|
|
|
|
}
|