1 /// C declarations of WASAPI that libsoundio uses
2 module soundio.headers.wasapiheader;
3 extern(Windows): @nogc: nothrow: __gshared:
4 
5 import core.sys.windows.windows;
6 
7 enum DEVICE_STATE_ACTIVE =      0x00000001;
8 enum DEVICE_STATE_DISABLED =    0x00000002;
9 enum DEVICE_STATE_NOTPRESENT =  0x00000004;
10 enum DEVICE_STATE_UNPLUGGED =   0x00000008;
11 enum DEVICE_STATEMASK_ALL =     0x0000000f;
12 
13 enum AUDCLNT_STREAMFLAGS_CROSSPROCESS             = 0x00010000;
14 enum AUDCLNT_STREAMFLAGS_LOOPBACK                 = 0x00020000;
15 enum AUDCLNT_STREAMFLAGS_EVENTCALLBACK            = 0x00040000;
16 enum AUDCLNT_STREAMFLAGS_NOPERSIST                = 0x00080000;
17 enum AUDCLNT_STREAMFLAGS_RATEADJUST               = 0x00100000;
18 enum AUDCLNT_STREAMFLAGS_PREVENT_LOOPBACK_CAPTURE = 0x01000000;
19 enum AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY      = 0x08000000;
20 enum AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM           = 0x80000000;
21 enum AUDCLNT_SESSIONFLAGS_EXPIREWHENUNOWNED       = 0x10000000;
22 enum AUDCLNT_SESSIONFLAGS_DISPLAY_HIDE            = 0x20000000;
23 enum AUDCLNT_SESSIONFLAGS_DISPLAY_HIDEWHENEXPIRED = 0x40000000;
24 
25 // Error codes
26 enum FACILITY_AUDCLNT = 2185;
27 int AUDCLNT_ERR(int n) {return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, n);}
28 int AUDCLNT_SUCCESS(int n) {return MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_AUDCLNT, n);}
29 enum AUDCLNT_E_NOT_INITIALIZED =              AUDCLNT_ERR(0x001);
30 enum AUDCLNT_E_ALREADY_INITIALIZED =          AUDCLNT_ERR(0x002);
31 enum AUDCLNT_E_WRONG_ENDPOINT_TYPE =          AUDCLNT_ERR(0x003);
32 enum AUDCLNT_E_DEVICE_INVALIDATED =           AUDCLNT_ERR(0x004);
33 enum AUDCLNT_E_NOT_STOPPED =                  AUDCLNT_ERR(0x005);
34 enum AUDCLNT_E_BUFFER_TOO_LARGE =             AUDCLNT_ERR(0x006);
35 enum AUDCLNT_E_OUT_OF_ORDER =                 AUDCLNT_ERR(0x007);
36 enum AUDCLNT_E_UNSUPPORTED_FORMAT =           AUDCLNT_ERR(0x008);
37 enum AUDCLNT_E_INVALID_SIZE =                 AUDCLNT_ERR(0x009);
38 enum AUDCLNT_E_DEVICE_IN_USE =                AUDCLNT_ERR(0x00a);
39 enum AUDCLNT_E_BUFFER_OPERATION_PENDING =     AUDCLNT_ERR(0x00b);
40 enum AUDCLNT_E_THREAD_NOT_REGISTERED =        AUDCLNT_ERR(0x00c);
41 enum AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED =   AUDCLNT_ERR(0x00e);
42 enum AUDCLNT_E_ENDPOINT_CREATE_FAILED =       AUDCLNT_ERR(0x00f);
43 enum AUDCLNT_E_SERVICE_NOT_RUNNING =          AUDCLNT_ERR(0x010);
44 enum AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED =     AUDCLNT_ERR(0x011);
45 enum AUDCLNT_E_EXCLUSIVE_MODE_ONLY =          AUDCLNT_ERR(0x012);
46 enum AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL = AUDCLNT_ERR(0x013);
47 enum AUDCLNT_E_EVENTHANDLE_NOT_SET =          AUDCLNT_ERR(0x014);
48 enum AUDCLNT_E_INCORRECT_BUFFER_SIZE =        AUDCLNT_ERR(0x015);
49 enum AUDCLNT_E_BUFFER_SIZE_ERROR =            AUDCLNT_ERR(0x016);
50 enum AUDCLNT_E_CPUUSAGE_EXCEEDED =            AUDCLNT_ERR(0x017);
51 enum AUDCLNT_E_BUFFER_ERROR =                 AUDCLNT_ERR(0x018);
52 enum AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED =      AUDCLNT_ERR(0x019);
53 enum AUDCLNT_E_INVALID_DEVICE_PERIOD =        AUDCLNT_ERR(0x020);
54 enum AUDCLNT_E_INVALID_STREAM_FLAG =          AUDCLNT_ERR(0x021);
55 enum AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE = AUDCLNT_ERR(0x022);
56 enum AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES =     AUDCLNT_ERR(0x023);
57 enum AUDCLNT_E_OFFLOAD_MODE_ONLY =            AUDCLNT_ERR(0x024);
58 enum AUDCLNT_E_NONOFFLOAD_MODE_ONLY =         AUDCLNT_ERR(0x025);
59 enum AUDCLNT_E_RESOURCES_INVALIDATED =        AUDCLNT_ERR(0x026);
60 enum AUDCLNT_E_RAW_MODE_UNSUPPORTED =         AUDCLNT_ERR(0x027);
61 enum AUDCLNT_E_ENGINE_PERIODICITY_LOCKED =    AUDCLNT_ERR(0x028);
62 enum AUDCLNT_E_ENGINE_FORMAT_LOCKED =         AUDCLNT_ERR(0x029);
63 enum AUDCLNT_E_HEADTRACKING_ENABLED =         AUDCLNT_ERR(0x030);
64 enum AUDCLNT_E_HEADTRACKING_UNSUPPORTED =     AUDCLNT_ERR(0x040);
65 enum AUDCLNT_S_BUFFER_EMPTY =                 AUDCLNT_SUCCESS(0x001);
66 enum AUDCLNT_S_THREAD_ALREADY_REGISTERED =    AUDCLNT_SUCCESS(0x002);
67 enum AUDCLNT_S_POSITION_STALLED =             AUDCLNT_SUCCESS(0x003);
68 
69 enum AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY	= 0x1;
70 enum AUDCLNT_BUFFERFLAGS_SILENT	= 0x2;
71 enum AUDCLNT_BUFFERFLAGS_TIMESTAMP_ERROR	= 0x4;
72 
73 // IUnknown
74 struct IUnknown {
75     IUnknownVtable* lpVtbl;
76 }
77 
78 struct IUnknownVtable {
79     private alias This_ = IUnknown*;
80     extern(Windows): @nogc: nothrow:
81     HRESULT function(This_, REFIID riid, void **ppvObject) QueryInterface;
82     ULONG function(This_, ) AddRef;
83     ULONG function(This_, ) Release;
84 }
85 
86 ULONG IUnknown_AddRef(T)(T* x) {return x.lpVtbl.AddRef(x);}
87 ULONG IUnknown_Release(T)(T* x) {return x.lpVtbl.Release(x);}
88 
89 // MMNotificationClient /////////////////////////////////////////////////////////////
90 struct IMMNotificationClient {
91     IMMNotificationClientVtbl* lpVtbl;
92 }
93 
94 struct IMMNotificationClientVtbl {
95     private alias THIS_ = IMMNotificationClient*;
96     extern(Windows): @nogc: nothrow:
97     HRESULT function(THIS_ client, REFIID riid, void** ppv) QueryInterface;
98     uint function(THIS_ client) AddRef;
99     uint function(THIS_ client) Release;
100     HRESULT function(THIS_ client, LPCWSTR wid, DWORD state) OnDeviceStateChanged;
101     HRESULT function(THIS_ client, LPCWSTR wid) OnDeviceAdded;
102     HRESULT function(THIS_ client, LPCWSTR wid) OnDeviceRemoved;
103     HRESULT function(THIS_ client, EDataFlow flow, ERole role, LPCWSTR wid) OnDefaultDeviceChange;
104     HRESULT function(THIS_ client, LPCWSTR wid, const(PROPERTYKEY) key) OnPropertyValueChanged;
105 }
106 
107 // MMDevice /////////////////////////////////////////////////////////////
108 struct IMMDevice {
109     IMMDeviceVtable* lpVtbl;
110 }
111 
112 struct IMMDeviceVtable {
113     extern(Windows): @nogc: nothrow:
114     alias This_ = IMMDevice*;
115     HRESULT function(This_, REFIID riid, void **ppvObject) QueryInterface;
116     ULONG function(This_, ) AddRef;
117     ULONG function(This_, ) Release;
118     HRESULT function(This_, REFIID iid, DWORD dwClsCtx, PROPVARIANT *pActivationParams, void **ppInterface) Activate;
119     HRESULT function(This_, DWORD stgmAccess, IPropertyStore **ppProperties) OpenPropertyStore;
120     HRESULT function(This_, LPWSTR *ppstrId) GetId;
121     HRESULT function(This_, DWORD *pdwState) GetState;
122 }
123 HRESULT IMMDevice_QueryInterface(T)(T* this_, REFIID riid, void **ppvObject) {return this_.lpVtbl.QueryInterface(this_,riid, ppvObject);}
124 ULONG IMMDevice_AddRef(T)(T* this_, ) {return this_.lpVtbl.AddRef(this_,);}
125 ULONG IMMDevice_Release(T)(T* this_, ) {return this_.lpVtbl.Release(this_,);}
126 HRESULT IMMDevice_Activate(T)(T* this_, REFIID iid, DWORD dwClsCtx, PROPVARIANT *pActivationParams, void **ppInterface) {return this_.lpVtbl.Activate(this_,iid, dwClsCtx, pActivationParams, ppInterface);}
127 HRESULT IMMDevice_OpenPropertyStore(T)(T* this_, DWORD stgmAccess, IPropertyStore **ppProperties) {return this_.lpVtbl.OpenPropertyStore(this_,stgmAccess, ppProperties);}
128 HRESULT IMMDevice_GetId(T)(T* this_, LPWSTR *ppstrId) {return this_.lpVtbl.GetId(this_,ppstrId);}
129 HRESULT IMMDevice_GetState(T)(T* this_, DWORD *pdwState) {return this_.lpVtbl.GetState(this_,pdwState);}
130 
131 // MMDeviceEnumerator /////////////////////////////////////////////////////////////
132 struct IMMDeviceEnumerator {
133     IMMDeviceEnumeratorVtable* lpVtbl;
134 }
135 
136 struct IMMDeviceEnumeratorVtable {
137     extern(Windows): @nogc: nothrow:
138     alias This_ = IMMDeviceEnumerator*;
139     HRESULT function(This_, REFIID riid, void **ppvObject) QueryInterface;
140     ULONG function(This_, ) AddRef;
141     ULONG function(This_, ) Release;
142     HRESULT function(This_, EDataFlow dataFlow, DWORD dwStateMask, IMMDeviceCollection **ppDevices) EnumAudioEndpoints;
143     HRESULT function(This_, EDataFlow dataFlow, ERole role, IMMDevice **ppEndpoint) GetDefaultAudioEndpoint;
144     HRESULT function(This_, LPCWSTR pwstrId, IMMDevice **ppDevice) GetDevice;
145     HRESULT function(This_, IMMNotificationClient *pClient) RegisterEndpointNotificationCallback;
146     HRESULT function(This_, IMMNotificationClient *pClient) UnregisterEndpointNotificationCallback;
147 }
148 HRESULT IMMDeviceEnumerator_QueryInterface(T)(T* this_, REFIID riid, void **ppvObject) {return this_.lpVtbl.QueryInterface(this_,riid, ppvObject);}
149 ULONG IMMDeviceEnumerator_AddRef(T)(T* this_, ) {return this_.lpVtbl.AddRef(this_,);}
150 ULONG IMMDeviceEnumerator_Release(T)(T* this_, ) {return this_.lpVtbl.Release(this_,);}
151 HRESULT IMMDeviceEnumerator_EnumAudioEndpoints(T)(T* this_, EDataFlow dataFlow, DWORD dwStateMask, IMMDeviceCollection **ppDevices) {return this_.lpVtbl.EnumAudioEndpoints(this_,dataFlow, dwStateMask, ppDevices);}
152 HRESULT IMMDeviceEnumerator_GetDefaultAudioEndpoint(T)(T* this_, EDataFlow dataFlow, ERole role, IMMDevice **ppEndpoint) {return this_.lpVtbl.GetDefaultAudioEndpoint(this_,dataFlow, role, ppEndpoint);}
153 HRESULT IMMDeviceEnumerator_GetDevice(T)(T* this_, LPCWSTR pwstrId, IMMDevice **ppDevice) {return this_.lpVtbl.GetDevice(this_,pwstrId, ppDevice);}
154 HRESULT IMMDeviceEnumerator_RegisterEndpointNotificationCallback(T)(T* this_, IMMNotificationClient *pClient) {return this_.lpVtbl.RegisterEndpointNotificationCallback(this_,pClient);}
155 HRESULT IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(T)(T* this_, IMMNotificationClient *pClient) {return this_.lpVtbl.UnregisterEndpointNotificationCallback(this_,pClient);}
156 
157 struct IAudioSessionEvents;
158 struct AudioSessionState;
159 
160 // AudioClockAdjustment //////////////////////////////////
161 struct IAudioClockAdjustment {
162     IAudioClockAdjustmentVtable* lpVtbl;
163 }
164 
165 struct IAudioClockAdjustmentVtable {
166     private alias This_ = IAudioClockAdjustment*;
167     extern(Windows): @nogc: nothrow:
168     HRESULT function(This_, REFIID riid, void **ppvObject) QueryInterface;
169     ULONG function(This_, ) AddRef;
170     ULONG function(This_, ) Release;
171     // there's more, not translated yet
172 }
173 
174 // SimpleAudioVolume /////////////////////////////////////
175 struct ISimpleAudioVolume {
176     ISimpleAudioVolumeVtable* lpVtbl;
177 }
178 
179 struct ISimpleAudioVolumeVtable {
180     extern(Windows): @nogc: nothrow:
181     alias This_ = ISimpleAudioVolume*;
182     HRESULT function(This_, REFIID riid, void **ppvObject) QueryInterface;
183     ULONG function(This_, ) AddRef;
184     ULONG function(This_, ) Release;
185     HRESULT function(This_, float fLevel, LPCGUID EventContext) SetMasterVolume;
186     HRESULT function(This_, float *pfLevel) GetMasterVolume;
187     HRESULT function(This_, BOOL bMute, LPCGUID EventContext) SetMute;
188     HRESULT function(This_, BOOL *pbMute) GetMute;
189 }
190 HRESULT ISimpleAudioVolume_QueryInterface(T)(T* this_, REFIID riid, void **ppvObject) {return this_.lpVtbl.QueryInterface(this_,riid, ppvObject);}
191 ULONG ISimpleAudioVolume_AddRef(T)(T* this_, ) {return this_.lpVtbl.AddRef(this_,);}
192 ULONG ISimpleAudioVolume_Release(T)(T* this_, ) {return this_.lpVtbl.Release(this_,);}
193 HRESULT ISimpleAudioVolume_SetMasterVolume(T)(T* this_, float fLevel, LPCGUID EventContext) {return this_.lpVtbl.SetMasterVolume(this_,fLevel, EventContext);}
194 HRESULT ISimpleAudioVolume_GetMasterVolume(T)(T* this_, float *pfLevel) {return this_.lpVtbl.GetMasterVolume(this_,pfLevel);}
195 HRESULT ISimpleAudioVolume_SetMute(T)(T* this_, BOOL bMute, LPCGUID EventContext) {return this_.lpVtbl.SetMute(this_,bMute, EventContext);}
196 HRESULT ISimpleAudioVolume_GetMute(T)(T* this_, BOOL *pbMute) {return this_.lpVtbl.GetMute(this_,pbMute);}
197 
198 // AudioRenderClient //////////////////////////////////////
199 struct IAudioRenderClient {
200     IAudioRenderClientVtable* lpVtbl;
201 }
202 
203 struct IAudioRenderClientVtable {
204     extern(Windows): @nogc: nothrow:
205     alias This_ = IAudioRenderClient*;
206     HRESULT function(This_, REFIID riid, void **ppvObject) QueryInterface;
207     ULONG function(This_, ) AddRef;
208     ULONG function(This_, ) Release;
209     HRESULT function(This_, UINT32 NumFramesRequested, BYTE **ppData) GetBuffer;
210     HRESULT function(This_, UINT32 NumFramesWritten, DWORD dwFlags) ReleaseBuffer;
211 }
212 HRESULT IAudioRenderClient_QueryInterface(T)(T* this_, REFIID riid, void **ppvObject) {return this_.lpVtbl.QueryInterface(this_,riid, ppvObject);}
213 ULONG IAudioRenderClient_AddRef(T)(T* this_, ) {return this_.lpVtbl.AddRef(this_,);}
214 ULONG IAudioRenderClient_Release(T)(T* this_, ) {return this_.lpVtbl.Release(this_,);}
215 HRESULT IAudioRenderClient_GetBuffer(T)(T* this_, UINT32 NumFramesRequested, BYTE **ppData) {return this_.lpVtbl.GetBuffer(this_,NumFramesRequested, ppData);}
216 HRESULT IAudioRenderClient_ReleaseBuffer(T)(T* this_, UINT32 NumFramesWritten, DWORD dwFlags) {return this_.lpVtbl.ReleaseBuffer(this_,NumFramesWritten, dwFlags);}
217 
218 // MMDeviceCollection //////////////////////////////////////
219 struct IMMDeviceCollection {
220     IMMDeviceCollectionVtable* lpVtbl;
221 }
222 
223 struct IMMDeviceCollectionVtable {
224     extern(Windows): @nogc: nothrow:
225     alias This_ = IMMDeviceCollection*;
226     HRESULT function(This_, REFIID riid, void **ppvObject) QueryInterface;
227     ULONG function(This_, ) AddRef;
228     ULONG function(This_, ) Release;
229     HRESULT function(This_, UINT *pcDevices) GetCount;
230     HRESULT function(This_, UINT nDevice, IMMDevice **ppDevice) Item;
231 }
232 HRESULT IMMDeviceCollection_QueryInterface(T)(T* this_, REFIID riid, void **ppvObject) {return this_.lpVtbl.QueryInterface(this_,riid, ppvObject);}
233 ULONG IMMDeviceCollection_AddRef(T)(T* this_, ) {return this_.lpVtbl.AddRef(this_,);}
234 ULONG IMMDeviceCollection_Release(T)(T* this_, ) {return this_.lpVtbl.Release(this_,);}
235 HRESULT IMMDeviceCollection_GetCount(T)(T* this_, UINT *pcDevices) {return this_.lpVtbl.GetCount(this_,pcDevices);}
236 HRESULT IMMDeviceCollection_Item(T)(T* this_, UINT nDevice, IMMDevice **ppDevice) {return this_.lpVtbl.Item(this_,nDevice, ppDevice);}
237 
238 // AudioCaptureClient ////////////////////////////////
239 struct IAudioCaptureClient {
240     IAudioCaptureClientVtable* lpVtbl;
241 }
242 
243 struct IAudioCaptureClientVtable {
244     extern(Windows): @nogc: nothrow:
245     alias This_ = IAudioCaptureClient*;
246     HRESULT function(This_, REFIID riid, void **ppvObject) QueryInterface;
247     ULONG function(This_, ) AddRef;
248     ULONG function(This_, ) Release;
249     HRESULT function(This_, BYTE **ppData, UINT32 *pNumFramesToRead, DWORD *pdwFlags, UINT64 *pu64DevicePosition, UINT64 *pu64QPCPosition) GetBuffer;
250     HRESULT function(This_, UINT32 NumFramesRead) ReleaseBuffer;
251     HRESULT function(This_, UINT32 *pNumFramesInNextPacket) GetNextPacketSize;
252 }
253 HRESULT IAudioCaptureClient_QueryInterface(T)(T* this_, REFIID riid, void **ppvObject) {return this_.lpVtbl.QueryInterface(this_,riid, ppvObject);}
254 ULONG IAudioCaptureClient_AddRef(T)(T* this_, ) {return this_.lpVtbl.AddRef(this_,);}
255 ULONG IAudioCaptureClient_Release(T)(T* this_, ) {return this_.lpVtbl.Release(this_,);}
256 HRESULT IAudioCaptureClient_GetBuffer(T)(T* this_, BYTE **ppData, UINT32 *pNumFramesToRead, DWORD *pdwFlags, UINT64 *pu64DevicePosition, UINT64 *pu64QPCPosition) {return this_.lpVtbl.GetBuffer(this_,ppData, pNumFramesToRead, pdwFlags, pu64DevicePosition, pu64QPCPosition);}
257 HRESULT IAudioCaptureClient_ReleaseBuffer(T)(T* this_, UINT32 NumFramesRead) {return this_.lpVtbl.ReleaseBuffer(this_,NumFramesRead);}
258 HRESULT IAudioCaptureClient_GetNextPacketSize(T)(T* this_, UINT32 *pNumFramesInNextPacket) {return this_.lpVtbl.GetNextPacketSize(this_,pNumFramesInNextPacket);}
259 
260 // PropertyStore //////////////////////////////
261 struct IPropertyStore {
262     IPropertyStoreVtable* lpVtbl;
263 }
264 
265 struct IPropertyStoreVtable {
266     extern(Windows): @nogc: nothrow:
267     alias This_ = IPropertyStore*;
268     HRESULT function(This_, REFIID riid, void **ppvObject) QueryInterface;
269     ULONG function(This_, ) AddRef;
270     ULONG function(This_, ) Release;
271     HRESULT function(This_, DWORD *cProps) GetCount;
272     HRESULT function(This_, DWORD iProp, PROPERTYKEY *pkey) GetAt;
273     HRESULT function(This_, PROPERTYKEY* key, PROPVARIANT *pv) GetValue;
274     HRESULT function(This_, PROPERTYKEY* key, PROPVARIANT* propvar) SetValue;
275     HRESULT function(This_, ) Commit;
276 }
277 HRESULT IPropertyStore_QueryInterface(T)(T* this_, REFIID riid, void **ppvObject) {return this_.lpVtbl.QueryInterface(this_,riid, ppvObject);}
278 ULONG IPropertyStore_AddRef(T)(T* this_, ) {return this_.lpVtbl.AddRef(this_,);}
279 ULONG IPropertyStore_Release(T)(T* this_, ) {return this_.lpVtbl.Release(this_,);}
280 HRESULT IPropertyStore_GetCount(T)(T* this_, DWORD *cProps) {return this_.lpVtbl.GetCount(this_,cProps);}
281 HRESULT IPropertyStore_GetAt(T)(T* this_, DWORD iProp, PROPERTYKEY *pkey) {return this_.lpVtbl.GetAt(this_,iProp, pkey);}
282 HRESULT IPropertyStore_GetValue(T)(T* this_, PROPERTYKEY* key, PROPVARIANT *pv) {return this_.lpVtbl.GetValue(this_,key, pv);}
283 HRESULT IPropertyStore_SetValue(T)(T* this_, PROPERTYKEY* key, PROPVARIANT* propvar) {return this_.lpVtbl.SetValue(this_,key, propvar);}
284 HRESULT IPropertyStore_Commit(T)(T* this_, ) {return this_.lpVtbl.Commit(this_,);}
285 
286 // MMEndpoint //////////////////////////////
287 struct IMMEndpoint {
288     IMMEndpointVtable* lpVtbl;
289 }
290 
291 struct IMMEndpointVtable {
292     extern(Windows): @nogc: nothrow:
293     alias This_ = IMMEndpoint*;
294     HRESULT function(This_, REFIID riid, void **ppvObject) QueryInterface;
295     ULONG function(This_, ) AddRef;
296     ULONG function(This_, ) Release;
297     HRESULT function(This_, EDataFlow *pDataFlow) GetDataFlow;
298 }
299 HRESULT IMMEndpoint_QueryInterface(T)(T* this_, REFIID riid, void **ppvObject) {return this_.lpVtbl.QueryInterface(this_,riid, ppvObject);}
300 ULONG IMMEndpoint_AddRef(T)(T* this_, ) {return this_.lpVtbl.AddRef(this_,);}
301 ULONG IMMEndpoint_Release(T)(T* this_, ) {return this_.lpVtbl.Release(this_,);}
302 HRESULT IMMEndpoint_GetDataFlow(T)(T* this_, EDataFlow *pDataFlow) {return this_.lpVtbl.GetDataFlow(this_,pDataFlow);}
303 
304 // Audio Client //////////////////////////////
305 struct IAudioClient {
306     IAudioClientVtable* lpVtbl;
307 }
308 
309 struct IAudioClientVtable {
310     extern(Windows): @nogc: nothrow:
311     alias This_ = IAudioClient*;
312     HRESULT function(This_, REFIID riid, void **ppvObject) QueryInterface;
313     ULONG function(This_, ) AddRef;
314     ULONG function(This_, ) Release;
315     HRESULT function(This_, AUDCLNT_SHAREMODE ShareMode, DWORD StreamFlags, REFERENCE_TIME hnsBufferDuration, REFERENCE_TIME hnsPeriodicity, WAVEFORMATEX *pFormat, LPCGUID AudioSessionGuid) Initialize;
316     HRESULT function(This_, UINT32 *pNumBufferFrames) GetBufferSize;
317     HRESULT function(This_, REFERENCE_TIME *phnsLatency) GetStreamLatency;
318     HRESULT function(This_, UINT32 *pNumPaddingFrames) GetCurrentPadding;
319     HRESULT function(This_, AUDCLNT_SHAREMODE ShareMode, WAVEFORMATEX *pFormat, WAVEFORMATEX **ppClosestMatch) IsFormatSupported;
320     HRESULT function(This_, WAVEFORMATEX **ppDeviceFormat) GetMixFormat;
321     HRESULT function(This_, REFERENCE_TIME *phnsDefaultDevicePeriod, REFERENCE_TIME *phnsMinimumDevicePeriod) GetDevicePeriod;
322     HRESULT function(This_, ) Start;
323     HRESULT function(This_, ) Stop;
324     HRESULT function(This_, ) Reset;
325     HRESULT function(This_, HANDLE eventHandle) SetEventHandle;
326     HRESULT function(This_, REFIID riid, void **ppv) GetService;
327 }
328 HRESULT IAudioClient_QueryInterface(T)(T* this_, REFIID riid, void **ppvObject) {return this_.lpVtbl.QueryInterface(this_,riid, ppvObject);}
329 ULONG IAudioClient_AddRef(T)(T* this_, ) {return this_.lpVtbl.AddRef(this_,);}
330 ULONG IAudioClient_Release(T)(T* this_, ) {return this_.lpVtbl.Release(this_,);}
331 HRESULT IAudioClient_Initialize(T)(T* this_, AUDCLNT_SHAREMODE ShareMode, DWORD StreamFlags, REFERENCE_TIME hnsBufferDuration, REFERENCE_TIME hnsPeriodicity, WAVEFORMATEX *pFormat, LPCGUID AudioSessionGuid) {return this_.lpVtbl.Initialize(this_,ShareMode, StreamFlags, hnsBufferDuration, hnsPeriodicity, pFormat, AudioSessionGuid);}
332 HRESULT IAudioClient_GetBufferSize(T)(T* this_, UINT32 *pNumBufferFrames) {return this_.lpVtbl.GetBufferSize(this_,pNumBufferFrames);}
333 HRESULT IAudioClient_GetStreamLatency(T)(T* this_, REFERENCE_TIME *phnsLatency) {return this_.lpVtbl.GetStreamLatency(this_,phnsLatency);}
334 HRESULT IAudioClient_GetCurrentPadding(T)(T* this_, UINT32 *pNumPaddingFrames) {return this_.lpVtbl.GetCurrentPadding(this_,pNumPaddingFrames);}
335 HRESULT IAudioClient_IsFormatSupported(T)(T* this_, AUDCLNT_SHAREMODE ShareMode, WAVEFORMATEX *pFormat, WAVEFORMATEX **ppClosestMatch) {return this_.lpVtbl.IsFormatSupported(this_,ShareMode, pFormat, ppClosestMatch);}
336 HRESULT IAudioClient_GetMixFormat(T)(T* this_, WAVEFORMATEX **ppDeviceFormat) {return this_.lpVtbl.GetMixFormat(this_,ppDeviceFormat);}
337 HRESULT IAudioClient_GetDevicePeriod(T)(T* this_, REFERENCE_TIME *phnsDefaultDevicePeriod, REFERENCE_TIME *phnsMinimumDevicePeriod) {return this_.lpVtbl.GetDevicePeriod(this_,phnsDefaultDevicePeriod, phnsMinimumDevicePeriod);}
338 HRESULT IAudioClient_Start(T)(T* this_, ) {return this_.lpVtbl.Start(this_,);}
339 HRESULT IAudioClient_Stop(T)(T* this_, ) {return this_.lpVtbl.Stop(this_,);}
340 HRESULT IAudioClient_Reset(T)(T* this_, ) {return this_.lpVtbl.Reset(this_,);}
341 HRESULT IAudioClient_SetEventHandle(T)(T* this_, HANDLE eventHandle) {return this_.lpVtbl.SetEventHandle(this_,eventHandle);}
342 HRESULT IAudioClient_GetService(T)(T* this_, REFIID riid, void **ppv) {return this_.lpVtbl.GetService(this_,riid, ppv);}
343 
344 // AudioSessionControl ///////////////////////
345 struct IAudioSessionControl {
346     IAudioSessionControlVtable* lpVtbl;
347 }
348 
349 struct IAudioSessionControlVtable {
350     extern(Windows): @nogc: nothrow:
351     alias This_ = IAudioSessionControl*;
352     HRESULT function(This_, REFIID riid, void **ppvObject) QueryInterface;
353     ULONG function(This_, ) AddRef;
354     ULONG function(This_, ) Release;
355     HRESULT function(This_, AudioSessionState *pRetVal) GetState;
356     HRESULT function(This_, LPWSTR *pRetVal) GetDisplayName;
357     HRESULT function(This_, LPCWSTR Value, LPCGUID EventContext) SetDisplayName;
358     HRESULT function(This_, LPWSTR *pRetVal) GetIconPath;
359     HRESULT function(This_, LPCWSTR Value, LPCGUID EventContext) SetIconPath;
360     HRESULT function(This_, GUID *pRetVal) GetGroupingParam;
361     HRESULT function(This_, LPCGUID Override, LPCGUID EventContext) SetGroupingParam;
362     HRESULT function(This_, IAudioSessionEvents *NewNotifications) RegisterAudioSessionNotification;
363     HRESULT function(This_, IAudioSessionEvents *NewNotifications) UnregisterAudioSessionNotification;
364 }
365 HRESULT IAudioSessionControl_QueryInterface(T)(T* this_, REFIID riid, void **ppvObject) {return this_.lpVtbl.QueryInterface(this_,riid, ppvObject);}
366 ULONG IAudioSessionControl_AddRef(T)(T* this_, ) {return this_.lpVtbl.AddRef(this_,);}
367 ULONG IAudioSessionControl_Release(T)(T* this_, ) {return this_.lpVtbl.Release(this_,);}
368 HRESULT IAudioSessionControl_GetState(T)(T* this_, AudioSessionState *pRetVal) {return this_.lpVtbl.GetState(this_,pRetVal);}
369 HRESULT IAudioSessionControl_GetDisplayName(T)(T* this_, LPWSTR *pRetVal) {return this_.lpVtbl.GetDisplayName(this_,pRetVal);}
370 HRESULT IAudioSessionControl_SetDisplayName(T)(T* this_, LPCWSTR Value, LPCGUID EventContext) {return this_.lpVtbl.SetDisplayName(this_,Value, EventContext);}
371 HRESULT IAudioSessionControl_GetIconPath(T)(T* this_, LPWSTR *pRetVal) {return this_.lpVtbl.GetIconPath(this_,pRetVal);}
372 HRESULT IAudioSessionControl_SetIconPath(T)(T* this_, LPCWSTR Value, LPCGUID EventContext) {return this_.lpVtbl.SetIconPath(this_,Value, EventContext);}
373 HRESULT IAudioSessionControl_GetGroupingParam(T)(T* this_, GUID *pRetVal) {return this_.lpVtbl.GetGroupingParam(this_,pRetVal);}
374 HRESULT IAudioSessionControl_SetGroupingParam(T)(T* this_, LPCGUID Override, LPCGUID EventContext) {return this_.lpVtbl.SetGroupingParam(this_,Override, EventContext);}
375 HRESULT IAudioSessionControl_RegisterAudioSessionNotification(T)(T* this_, IAudioSessionEvents *NewNotifications) {return this_.lpVtbl.RegisterAudioSessionNotification(this_,NewNotifications);}
376 HRESULT IAudioSessionControl_UnregisterAudioSessionNotification(T)(T* this_, IAudioSessionEvents *NewNotifications) {return this_.lpVtbl.UnregisterAudioSessionNotification(this_,NewNotifications);}
377 
378 // PropVariant /////////////////////////
379 HRESULT PropVariantClear(PROPVARIANT* pvar);
380 pragma(inline, true) void PropVariantInit(PROPVARIANT* pvar ) {
381     import core.stdc..string: memset;
382     memset(pvar, 0, PROPVARIANT.sizeof);
383 }
384 
385 struct BLOB {
386     ULONG cbSize;
387     BYTE *pBlobData;
388 }
389 
390 struct PROPVARIANT {
391     ushort vt; // VARTYPE
392     ushort wReserved1;
393     ushort wReserved2;
394     ushort wReserved3;
395     union {
396         CHAR cVal;
397         UCHAR bVal;
398         SHORT iVal;
399         USHORT uiVal;
400         LONG lVal;
401         ULONG ulVal;
402         INT intVal;
403         UINT uintVal;
404         LARGE_INTEGER hVal;
405         ULARGE_INTEGER uhVal;
406         FLOAT fltVal;
407         // ... many more omitted
408         LPWSTR pwszVal;
409         BLOB blob;
410     }
411 }
412 static assert(PROPVARIANT.sizeof == (size_t.sizeof == 4) ? 16 : 24);
413 static assert(PROPVARIANT.pwszVal.offsetof == 8);
414 
415 alias REFERENCE_TIME = long;
416 
417 struct PROPERTYKEY {
418     GUID fmtid;
419     DWORD pid;
420 }
421 
422 PROPERTYKEY PKEY_Device_FriendlyName = PROPERTYKEY(
423     GUID(0xa45c254e, 0xdf1c, 0x4efd, [0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0]),
424     14
425 );
426 
427 PROPERTYKEY PKEY_AudioEngine_DeviceFormat = PROPERTYKEY(
428     GUID(0xf19f064d, 0x82c, 0x4e27, [0xbc, 0x73, 0x68, 0x82, 0xa1, 0xbb, 0x8e, 0x4c]),
429     0
430 );
431 
432 enum WAVE_FORMAT_EXTENSIBLE = 0xFFFE;
433 
434 struct WAVEFORMATEX {
435     align(2):
436     WORD  wFormatTag;
437     WORD  nChannels;
438     DWORD nSamplesPerSec;
439     DWORD nAvgBytesPerSec;
440     WORD  nBlockAlign;
441     WORD  wBitsPerSample;
442     WORD  cbSize;
443 }
444 static assert(WAVEFORMATEX.sizeof == 18);
445 
446 struct WAVEFORMATEXTENSIBLE {
447     WAVEFORMATEX    Format;
448     union USamples {
449         WORD wValidBitsPerSample;
450         WORD wSamplesPerBlock;
451         WORD wReserved;
452     }
453     USamples Samples;
454     DWORD           dwChannelMask;
455     GUID            SubFormat;
456 }
457 
458 static assert(WAVEFORMATEXTENSIBLE.sizeof == 40);
459 
460 alias AUDCLNT_SHAREMODE = int; // C enum
461 enum {
462     AUDCLNT_SHAREMODE_SHARED,
463     AUDCLNT_SHAREMODE_EXCLUSIVE
464 }
465 
466 alias EDataFlow = int;
467 enum {
468     eRender	= 0,
469     eCapture = ( eRender + 1 ) ,
470     eAll = ( eCapture + 1 ) ,
471     EDataFlow_enum_count	= ( eAll + 1 )
472 }
473 alias ERole = int;
474 enum {
475     eConsole	= 0,
476     eMultimedia	= ( eConsole + 1 ) ,
477     eCommunications	= ( eMultimedia + 1 ) ,
478     ERole_enum_count	= ( eCommunications + 1 )
479 }
480 
481 // ksmedia.h
482 enum SPEAKER_FRONT_LEFT            = 0x1;
483 enum SPEAKER_FRONT_RIGHT           = 0x2;
484 enum SPEAKER_FRONT_CENTER          = 0x4;
485 enum SPEAKER_LOW_FREQUENCY         = 0x8;
486 enum SPEAKER_BACK_LEFT             = 0x10;
487 enum SPEAKER_BACK_RIGHT            = 0x20;
488 enum SPEAKER_FRONT_LEFT_OF_CENTER  = 0x40;
489 enum SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80;
490 enum SPEAKER_BACK_CENTER           = 0x100;
491 enum SPEAKER_SIDE_LEFT             = 0x200;
492 enum SPEAKER_SIDE_RIGHT            = 0x400;
493 enum SPEAKER_TOP_CENTER            = 0x800;
494 enum SPEAKER_TOP_FRONT_LEFT        = 0x1000;
495 enum SPEAKER_TOP_FRONT_CENTER      = 0x2000;
496 enum SPEAKER_TOP_FRONT_RIGHT       = 0x4000;
497 enum SPEAKER_TOP_BACK_LEFT         = 0x8000;
498 enum SPEAKER_TOP_BACK_CENTER       = 0x10000;
499 enum SPEAKER_TOP_BACK_RIGHT        = 0x20000;