25#include "endpointvolume.h"
27#include "mmdeviceapi.h"
28#include "audioclient.h"
29#include "audiopolicy.h"
34DEFINE_GUID(
GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
50 IMMDeviceEnumerator_AddRef(
mme);
51 ref = IMMDeviceEnumerator_Release(
mme);
52 ok(
ref == 2,
"Reference count on parent is %u\n",
ref);
54 ref = IMMDeviceCollection_AddRef(col);
55 IMMDeviceCollection_Release(col);
56 ok(
ref == 2,
"Invalid reference count %u on collection\n",
ref);
61 hr = IMMDeviceCollection_QueryInterface(col, &
IID_IUnknown, (
void**)&unk);
62 ok(
hr ==
S_OK,
"Cannot query for IID_IUnknown: 0x%08x\n",
hr);
65 ok((
IUnknown*)col == unk,
"Pointers are not identical %p/%p/%p\n", col, unk,
mme);
66 IUnknown_Release(unk);
69 hr = IMMDeviceCollection_QueryInterface(col, &IID_IMMDeviceCollection, (
void**)&col2);
70 ok(
hr ==
S_OK,
"Cannot query for IID_IMMDeviceCollection: 0x%08x\n",
hr);
72 IMMDeviceCollection_Release(col2);
74 hr = IMMDeviceCollection_QueryInterface(col, &IID_IMMDeviceEnumerator, (
void**)&mme2);
77 IMMDeviceEnumerator_Release(mme2);
79 hr = IMMDeviceCollection_GetCount(col,
NULL);
82 hr = IMMDeviceCollection_GetCount(col, &numdev);
83 ok(
hr ==
S_OK,
"GetCount returned 0x%08x\n",
hr);
86 hr = IMMDeviceCollection_Item(col, numdev, &
dev);
88 ok(
dev ==
NULL,
"Returned non-null device\n");
92 hr = IMMDeviceCollection_Item(col, 0,
NULL);
95 hr = IMMDeviceCollection_Item(col, 0, &
dev);
96 ok(
hr ==
S_OK,
"Valid Item returned 0x%08x\n",
hr);
102 if (IMMDevice_GetId(
dev, &
id) ==
S_OK)
110 hr = IMMDeviceEnumerator_GetDevice(
mme,
id, &dev2);
111 ok(
hr ==
S_OK,
"GetDevice failed: %08x\n",
hr);
113 IMMDevice_Release(dev2);
119 IMMDevice_Release(
dev);
121 IMMDeviceCollection_Release(col);
127 ok(0,
"Unexpected QueryInterface call\n");
133 ok(0,
"Unexpected AddRef call\n");
139 ok(0,
"Unexpected Release call\n");
146 ok(0,
"Unexpected OnDeviceStateChanged call\n");
151 const WCHAR *device_id)
153 ok(0,
"Unexpected OnDeviceAdded call\n");
158 const WCHAR *device_id)
160 ok(0,
"Unexpected OnDeviceRemoved call\n");
167 ok(0,
"Unexpected OnDefaultDeviceChanged call\n");
172 const WCHAR *device_id,
const PROPERTYKEY
key)
174 ok(0,
"Unexpected OnPropertyValueChanged call\n");
194 static const WCHAR not_a_deviceW[] = {
'n',
'o',
't',
'a',
'd',
'e',
'v',
'i',
'c',
'e',0};
207 skip(
"mmdevapi not available: 0x%08x\n",
hr);
212 ref = IMMDeviceEnumerator_AddRef(
mme);
213 ok(
ref == 3,
"Invalid reference count after incrementing: %u\n",
ref);
214 IMMDeviceEnumerator_Release(
mme);
221 IUnknown_Release(unk);
224 hr =
CoCreateInstance(&CLSID_MMDeviceEnumerator,
NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (
void**)&mme2);
225 ok(
hr ==
S_OK,
"CoCreateInstance failed: 0x%08x\n",
hr);
226 IMMDeviceEnumerator_Release(mme2);
227 ok(
mme == mme2,
"Pointers are not equal!\n");
230 ok(
hr ==
E_POINTER,
"Null pointer on QueryInterface returned %08x\n",
hr);
232 hr = IMMDeviceEnumerator_QueryInterface(
mme, &
GUID_NULL, (
void**)&unk);
233 ok(!unk,
"Unk not reset to null after invalid QI\n");
236 hr = IMMDeviceEnumerator_GetDevice(
mme, not_a_deviceW,
NULL);
242 hr = IMMDeviceEnumerator_GetDevice(
mme, not_a_deviceW, &
dev);
246 hr = IMMDeviceEnumerator_EnumAudioEndpoints(
mme, 0xffff, DEVICE_STATEMASK_ALL, &col);
248 ok(col ==
NULL,
"Collection pointer non-null on failure\n");
250 hr = IMMDeviceEnumerator_EnumAudioEndpoints(
mme,
eAll, DEVICE_STATEMASK_ALL+1, &col);
253 hr = IMMDeviceEnumerator_EnumAudioEndpoints(
mme,
eAll, DEVICE_STATEMASK_ALL,
NULL);
256 hr = IMMDeviceEnumerator_EnumAudioEndpoints(
mme,
eAll, DEVICE_STATEMASK_ALL, &col);
257 ok(
hr ==
S_OK,
"Valid EnumAudioEndpoints returned 0x%08x\n",
hr);
260 ok(!!col,
"Returned null pointer\n");
265 hr = IMMDeviceEnumerator_RegisterEndpointNotificationCallback(
mme,
NULL);
266 ok(
hr ==
E_POINTER,
"RegisterEndpointNotificationCallback failed: %08x\n",
hr);
268 hr = IMMDeviceEnumerator_RegisterEndpointNotificationCallback(
mme, &
notif);
269 ok(
hr ==
S_OK,
"RegisterEndpointNotificationCallback failed: %08x\n",
hr);
271 hr = IMMDeviceEnumerator_RegisterEndpointNotificationCallback(
mme, &
notif);
272 ok(
hr ==
S_OK,
"RegisterEndpointNotificationCallback failed: %08x\n",
hr);
274 hr = IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(
mme,
NULL);
275 ok(
hr ==
E_POINTER,
"UnregisterEndpointNotificationCallback failed: %08x\n",
hr);
278 ok(
hr == E_NOTFOUND,
"UnregisterEndpointNotificationCallback failed: %08x\n",
hr);
280 hr = IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(
mme, &
notif);
281 ok(
hr ==
S_OK,
"UnregisterEndpointNotificationCallback failed: %08x\n",
hr);
283 hr = IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(
mme, &
notif);
284 ok(
hr ==
S_OK,
"UnregisterEndpointNotificationCallback failed: %08x\n",
hr);
286 hr = IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(
mme, &
notif);
287 ok(
hr == E_NOTFOUND,
"UnregisterEndpointNotificationCallback failed: %08x\n",
hr);
289 IMMDeviceEnumerator_Release(
mme);
#define WideCharToMultiByte
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
VOID WINAPI CoTaskMemFree(LPVOID ptr)
static HRESULT WINAPI notif_OnDeviceAdded(IMMNotificationClient *iface, const WCHAR *device_id)
static void test_collection(IMMDeviceEnumerator *mme, IMMDeviceCollection *col)
static HRESULT WINAPI notif_OnPropertyValueChanged(IMMNotificationClient *iface, const WCHAR *device_id, const PROPERTYKEY key)
static IMMNotificationClientVtbl notif_vtbl
static HRESULT WINAPI notif_OnDeviceStateChanged(IMMNotificationClient *iface, const WCHAR *device_id, DWORD new_state)
static HRESULT WINAPI notif_QueryInterface(IMMNotificationClient *iface, const GUID *riid, void **obj)
static HRESULT WINAPI notif_OnDeviceRemoved(IMMNotificationClient *iface, const WCHAR *device_id)
static ULONG WINAPI notif_AddRef(IMMNotificationClient *iface)
static IMMNotificationClient notif
static HRESULT WINAPI notif_OnDefaultDeviceChanged(IMMNotificationClient *iface, EDataFlow flow, ERole role, const WCHAR *device_id)
static ULONG WINAPI notif_Release(IMMNotificationClient *iface)
enum _EDataFlow EDataFlow
static IMMDeviceEnumerator * mme
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)