From d53dc08ec5c9ab39e97d5e33c71f30658c663e3b Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Sun, 21 Feb 2010 14:24:42 +0100 Subject: [PATCH] mmdevapi: Implement MMDeviceCollection methods. --- dlls/mmdevapi/devenum.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/dlls/mmdevapi/devenum.c b/dlls/mmdevapi/devenum.c index b711db273df..cbe4ab08450 100644 --- a/dlls/mmdevapi/devenum.c +++ b/dlls/mmdevapi/devenum.c @@ -468,20 +468,45 @@ static ULONG WINAPI MMDevCol_Release(IMMDeviceCollection *iface) static HRESULT WINAPI MMDevCol_GetCount(IMMDeviceCollection *iface, UINT *numdevs) { MMDevColImpl *This = (MMDevColImpl*)iface; + DWORD i; TRACE("(%p)->(%p)\n", This, numdevs); if (!numdevs) return E_POINTER; + *numdevs = 0; + for (i = 0; i < MMDevice_count; ++i) + { + MMDevice *cur = MMDevice_head[i]; + if ((cur->flow == This->flow || This->flow == eAll) + && (cur->state & This->state)) + ++(*numdevs); + } return S_OK; } -static HRESULT WINAPI MMDevCol_Item(IMMDeviceCollection *iface, UINT i, IMMDevice **dev) +static HRESULT WINAPI MMDevCol_Item(IMMDeviceCollection *iface, UINT n, IMMDevice **dev) { MMDevColImpl *This = (MMDevColImpl*)iface; - TRACE("(%p)->(%u, %p)\n", This, i, dev); + DWORD i = 0, j = 0; + + TRACE("(%p)->(%u, %p)\n", This, n, dev); if (!dev) return E_POINTER; + + for (j = 0; j < MMDevice_count; ++j) + { + MMDevice *cur = MMDevice_head[j]; + if ((cur->flow == This->flow || This->flow == eAll) + && (cur->state & This->state) + && i++ == n) + { + *dev = (IMMDevice *)cur; + IMMDevice_AddRef(*dev); + return S_OK; + } + } + WARN("Could not obtain item %u\n", n); *dev = NULL; return E_INVALIDARG; }