/* * Copyright 2009 Maarten Lankhorst * * 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 */ #include "config.h" #include #define CINTERFACE #define COBJMACROS #include "windef.h" #include "winbase.h" #include "wine/debug.h" #include "ole2.h" #include "mmdeviceapi.h" #include "mmdevapi.h" WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi); typedef struct MMDevEnumImpl { IMMDeviceEnumeratorVtbl *lpVtbl; LONG ref; } MMDevEnumImpl; static MMDevEnumImpl *MMDevEnumerator; static IMMDeviceEnumeratorVtbl MMDevEnumVtbl; HRESULT MMDevEnum_Create(REFIID riid, void **ppv) { MMDevEnumImpl *This = MMDevEnumerator; if (!This) { This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This)); *ppv = NULL; if (!This) return E_OUTOFMEMORY; This->ref = 1; This->lpVtbl = &MMDevEnumVtbl; MMDevEnumerator = This; } return IUnknown_QueryInterface((IUnknown*)This, riid, ppv); } void MMDevEnum_Free(void) { HeapFree(GetProcessHeap(), 0, MMDevEnumerator); MMDevEnumerator = NULL; } static HRESULT WINAPI MMDevEnum_QueryInterface(IMMDeviceEnumerator *iface, REFIID riid, void **ppv) { MMDevEnumImpl *This = (MMDevEnumImpl*)iface; if (!ppv) return E_POINTER; if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IMMDeviceEnumerator)) *ppv = This; else *ppv = NULL; if (!*ppv) return E_NOINTERFACE; IUnknown_AddRef((IUnknown*)*ppv); return S_OK; } static ULONG WINAPI MMDevEnum_AddRef(IMMDeviceEnumerator *iface) { MMDevEnumImpl *This = (MMDevEnumImpl*)iface; LONG ref = InterlockedIncrement(&This->ref); TRACE("Refcount now %i\n", ref); return ref; } static ULONG WINAPI MMDevEnum_Release(IMMDeviceEnumerator *iface) { MMDevEnumImpl *This = (MMDevEnumImpl*)iface; LONG ref = InterlockedDecrement(&This->ref); if (!ref) MMDevEnum_Free(); TRACE("Refcount now %i\n", ref); return ref; } static HRESULT WINAPI MMDevEnum_EnumAudioEndpoints(IMMDeviceEnumerator *iface, EDataFlow flow, DWORD mask, IMMDeviceCollection **devices) { MMDevEnumImpl *This = (MMDevEnumImpl*)iface; TRACE("(%p)->(%u,%u,%p)\n", This, flow, mask, devices); if (!devices) return E_POINTER; *devices = NULL; if (flow >= EDataFlow_enum_count) return E_INVALIDARG; if (mask & ~DEVICE_STATEMASK_ALL) return E_INVALIDARG; FIXME("stub\n"); return E_NOTFOUND; } static HRESULT WINAPI MMDevEnum_GetDefaultAudioEndpoint(IMMDeviceEnumerator *iface, EDataFlow flow, ERole role, IMMDevice **device) { MMDevEnumImpl *This = (MMDevEnumImpl*)iface; TRACE("(%p)->(%u,%u,%p)\n", This, flow, role, device); FIXME("stub\n"); return E_NOTFOUND; } static HRESULT WINAPI MMDevEnum_GetDevice(IMMDeviceEnumerator *iface, const WCHAR *name, IMMDevice **device) { MMDevEnumImpl *This = (MMDevEnumImpl*)iface; TRACE("(%p)->(%s,%p)\n", This, debugstr_w(name), device); FIXME("stub\n"); return E_NOTIMPL; } static HRESULT WINAPI MMDevEnum_RegisterEndpointNotificationCallback(IMMDeviceEnumerator *iface, IMMNotificationClient *client) { MMDevEnumImpl *This = (MMDevEnumImpl*)iface; TRACE("(%p)->(%p)\n", This, client); FIXME("stub\n"); return E_NOTIMPL; } static HRESULT WINAPI MMDevEnum_UnregisterEndpointNotificationCallback(IMMDeviceEnumerator *iface, IMMNotificationClient *client) { MMDevEnumImpl *This = (MMDevEnumImpl*)iface; TRACE("(%p)->(%p)\n", This, client); FIXME("stub\n"); return E_NOTIMPL; } static IMMDeviceEnumeratorVtbl MMDevEnumVtbl = { MMDevEnum_QueryInterface, MMDevEnum_AddRef, MMDevEnum_Release, MMDevEnum_EnumAudioEndpoints, MMDevEnum_GetDefaultAudioEndpoint, MMDevEnum_GetDevice, MMDevEnum_RegisterEndpointNotificationCallback, MMDevEnum_UnregisterEndpointNotificationCallback };