Commit 5e9ec192 authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Alexandre Julliard

mmdevapi: Add an empty IMMDeviceCollection implementation.

parent 056588ab
......@@ -42,6 +42,101 @@ typedef struct MMDevEnumImpl
static MMDevEnumImpl *MMDevEnumerator;
static const IMMDeviceEnumeratorVtbl MMDevEnumVtbl;
typedef struct MMDevColImpl
{
const IMMDeviceCollectionVtbl *lpVtbl;
LONG ref;
MMDevEnumImpl *parent;
EDataFlow flow;
DWORD state;
} MMDevColImpl;
static const IMMDeviceCollectionVtbl MMDevColVtbl;
static HRESULT MMDevCol_Create(IMMDeviceCollection **ppv, MMDevEnumImpl *parent, EDataFlow flow, DWORD state)
{
MMDevColImpl *This;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
*ppv = NULL;
if (!This)
return E_OUTOFMEMORY;
This->lpVtbl = &MMDevColVtbl;
This->ref = 1;
This->parent = parent;
This->flow = flow;
This->state = state;
*ppv = (IMMDeviceCollection*)This;
return S_OK;
}
static void MMDevCol_Destroy(MMDevColImpl *This)
{
HeapFree(GetProcessHeap(), 0, This);
}
static HRESULT WINAPI MMDevCol_QueryInterface(IMMDeviceCollection *iface, REFIID riid, void **ppv)
{
MMDevColImpl *This = (MMDevColImpl*)iface;
if (!ppv)
return E_POINTER;
if (IsEqualIID(riid, &IID_IUnknown)
|| IsEqualIID(riid, &IID_IMMDeviceCollection))
*ppv = This;
else
*ppv = NULL;
if (!*ppv)
return E_NOINTERFACE;
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI MMDevCol_AddRef(IMMDeviceCollection *iface)
{
MMDevColImpl *This = (MMDevColImpl*)iface;
LONG ref = InterlockedIncrement(&This->ref);
TRACE("Refcount now %i\n", ref);
return ref;
}
static ULONG WINAPI MMDevCol_Release(IMMDeviceCollection *iface)
{
MMDevColImpl *This = (MMDevColImpl*)iface;
LONG ref = InterlockedDecrement(&This->ref);
TRACE("Refcount now %i\n", ref);
if (!ref)
MMDevCol_Destroy(This);
return ref;
}
static HRESULT WINAPI MMDevCol_GetCount(IMMDeviceCollection *iface, UINT *numdevs)
{
MMDevColImpl *This = (MMDevColImpl*)iface;
TRACE("(%p)->(%p)\n", This, numdevs);
if (!numdevs)
return E_POINTER;
*numdevs = 0;
return S_OK;
}
static HRESULT WINAPI MMDevCol_Item(IMMDeviceCollection *iface, UINT i, IMMDevice **dev)
{
MMDevColImpl *This = (MMDevColImpl*)iface;
TRACE("(%p)->(%u, %p)\n", This, i, dev);
if (!dev)
return E_POINTER;
*dev = NULL;
return E_INVALIDARG;
}
static const IMMDeviceCollectionVtbl MMDevColVtbl =
{
MMDevCol_QueryInterface,
MMDevCol_AddRef,
MMDevCol_Release,
MMDevCol_GetCount,
MMDevCol_Item
};
HRESULT MMDevEnum_Create(REFIID riid, void **ppv)
{
MMDevEnumImpl *This = MMDevEnumerator;
......@@ -111,8 +206,7 @@ static HRESULT WINAPI MMDevEnum_EnumAudioEndpoints(IMMDeviceEnumerator *iface, E
return E_INVALIDARG;
if (mask & ~DEVICE_STATEMASK_ALL)
return E_INVALIDARG;
FIXME("stub\n");
return E_NOTFOUND;
return MMDevCol_Create(devices, This, flow, mask);
}
static HRESULT WINAPI MMDevEnum_GetDefaultAudioEndpoint(IMMDeviceEnumerator *iface, EDataFlow flow, ERole role, IMMDevice **device)
......
......@@ -45,6 +45,9 @@ static void test_collection(IMMDeviceEnumerator *mme, IMMDeviceCollection *col)
IUnknown_Release(col);
ok(ref == 2, "Invalid reference count %u on collection\n", ref);
hr = IUnknown_QueryInterface(col, &IID_IUnknown, NULL);
ok(hr == E_POINTER, "Null ppv returns %08x\n", hr);
hr = IUnknown_QueryInterface(col, &IID_IUnknown, (void**)&unk);
ok(hr == S_OK, "Cannot query for IID_IUnknown: 0x%08x\n", hr);
if (hr == S_OK)
......@@ -137,7 +140,7 @@ START_TEST(mmdevenum)
ok(hr == E_POINTER, "Invalid pointer returned: 0x%08x\n", hr);
hr = IMMDeviceEnumerator_EnumAudioEndpoints(mme, eAll, DEVICE_STATEMASK_ALL, &col);
todo_wine ok(hr == S_OK, "Valid EnumAudioEndpoints returned 0x%08x\n", hr);
ok(hr == S_OK, "Valid EnumAudioEndpoints returned 0x%08x\n", hr);
if (hr == S_OK)
{
ok(!!col, "Returned null pointer\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment