1use shared::guiddef::{GUID, LPCGUID, LPGUID};
8use shared::minwindef::{DWORD, LPDWORD, LPLONG, LPVOID};
9use shared::windef::HWND;
10use shared::winerror::{E_FAIL, S_OK};
11use um::mmsystem::{LPCWAVEFORMATEX, LPWAVEFORMATEX};
12use um::unknwnbase::{IUnknown, IUnknownVtbl, LPUNKNOWN};
13use um::winnt::{HRESULT, LONG};
14DEFINE_GUID!{CLSID_DirectSound,
15 0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}
16DEFINE_GUID!{CLSID_DirectSound8,
17 0x3901cc3f, 0x84b5, 0x4fa4, 0xba, 0x35, 0xaa, 0x81, 0x72, 0xb8, 0xa0, 0x9b}
18DEFINE_GUID!{CLSID_DirectSoundCapture,
19 0xb0210780, 0x89cd, 0x11d0, 0xaf, 0x08, 0x00, 0xa0, 0xc9, 0x25, 0xcd, 0x16}
20DEFINE_GUID!{CLSID_DirectSoundCapture8,
21 0xe4bcac13, 0x7f99, 0x4908, 0x9a, 0x8e, 0x74, 0xe3, 0xbf, 0x24, 0xb6, 0xe1}
22DEFINE_GUID!{CLSID_DirectSoundFullDuplex,
23 0xfea4300c, 0x7959, 0x4147, 0xb2, 0x6a, 0x23, 0x77, 0xb9, 0xe7, 0xa9, 0x1d}
24DEFINE_GUID!{DSDEVID_DefaultPlayback,
25 0xdef00000, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03}
26DEFINE_GUID!{DSDEVID_DefaultCapture,
27 0xdef00001, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03}
28DEFINE_GUID!{DSDEVID_DefaultVoicePlayback,
29 0xdef00002, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03}
30DEFINE_GUID!{DSDEVID_DefaultVoiceCapture,
31 0xdef00003, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03}
32STRUCT!{struct DSCAPS {
33 dwSize: DWORD,
34 dwFlags: DWORD,
35 dwMinSecondarySampleRate: DWORD,
36 dwMaxSecondarySampleRate: DWORD,
37 dwPrimaryBuffers: DWORD,
38 dwMaxHwMixingAllBuffers: DWORD,
39 dwMaxHwMixingStaticBuffers: DWORD,
40 dwMaxHwMixingStreamingBuffers: DWORD,
41 dwFreeHwMixingAllBuffers: DWORD,
42 dwFreeHwMixingStaticBuffers: DWORD,
43 dwFreeHwMixingStreamingBuffers: DWORD,
44 dwMaxHw3DAllBuffers: DWORD,
45 dwMaxHw3DStaticBuffers: DWORD,
46 dwMaxHw3DStreamingBuffers: DWORD,
47 dwFreeHw3DAllBuffers: DWORD,
48 dwFreeHw3DStaticBuffers: DWORD,
49 dwFreeHw3DStreamingBuffers: DWORD,
50 dwTotalHwMemBytes: DWORD,
51 dwFreeHwMemBytes: DWORD,
52 dwMaxContigFreeHwMemBytes: DWORD,
53 dwUnlockTransferRateHwBuffers: DWORD,
54 dwPlayCpuOverheadSwBuffers: DWORD,
55 dwReserved1: DWORD,
56 dwReserved2: DWORD,
57}}
58pub type LPDSCAPS = *mut DSCAPS;
59STRUCT!{struct DSBCAPS {
60 dwSize: DWORD,
61 dwFlags: DWORD,
62 dwBufferBytes: DWORD,
63 dwUnlockTransferRate: DWORD,
64 dwPlayCpuOverhead: DWORD,
65}}
66pub type LPDSBCAPS = *mut DSBCAPS;
67STRUCT!{struct DSBUFFERDESC {
68 dwSize: DWORD,
69 dwFlags: DWORD,
70 dwBufferBytes: DWORD,
71 dwReserved: DWORD,
72 lpwfxFormat: LPWAVEFORMATEX,
73 guid3DAlgorithm: GUID,
74}}
75pub type LPCDSBUFFERDESC = *const DSBUFFERDESC;
76RIDL!{#[uuid(0x279afa85, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60)]
77interface IDirectSoundBuffer(IDirectSoundBufferVtbl): IUnknown(IUnknownVtbl) {
78 fn GetCaps(
79 pDSBufferCaps: LPDSBCAPS,
80 ) -> HRESULT,
81 fn GetCurrentPosition(
82 pdwCurrentPlayCursor: LPDWORD,
83 pdwCurrentWriteCursor: LPDWORD,
84 ) -> HRESULT,
85 fn GetFormat(
86 pwfxFormat: LPWAVEFORMATEX,
87 dwSizeAllocated: DWORD,
88 pdwSizeWritten: LPDWORD,
89 ) -> HRESULT,
90 fn GetVolume(
91 plVolume: LPLONG,
92 ) -> HRESULT,
93 fn GetPan(
94 plPan: LPLONG,
95 ) -> HRESULT,
96 fn GetFrequency(
97 pdwFrequency: LPDWORD,
98 ) -> HRESULT,
99 fn GetStatus(
100 pdwStatus: LPDWORD,
101 ) -> HRESULT,
102 fn Initialize(
103 pDirectSound: LPDIRECTSOUND,
104 pcDSBufferDesc: LPCDSBUFFERDESC,
105 ) -> HRESULT,
106 fn Lock(
107 dwOffset: DWORD,
108 dwBytes: DWORD,
109 ppvAudioPtr1: *mut LPVOID,
110 pdwAudioBytes1: LPDWORD,
111 ppvAudioPtr2: *mut LPVOID,
112 pdwAudioBytes2: LPDWORD,
113 dwFlags: DWORD,
114 ) -> HRESULT,
115 fn Play(
116 dwReserved1: DWORD,
117 dwPriority: DWORD,
118 dwFlags: DWORD,
119 ) -> HRESULT,
120 fn SetCurrentPosition(
121 dwNewPosition: DWORD,
122 ) -> HRESULT,
123 fn SetFormat(
124 pcfxFormat: LPCWAVEFORMATEX,
125 ) -> HRESULT,
126 fn SetVolume(
127 lVolume: LONG,
128 ) -> HRESULT,
129 fn SetPan(
130 lPan: LONG,
131 ) -> HRESULT,
132 fn SetFrequency(
133 dwFrequency: DWORD,
134 ) -> HRESULT,
135 fn Stop() -> HRESULT,
136 fn Unlock(
137 pvAudioPtr1: LPVOID,
138 dwAudioBytes1: DWORD,
139 pvAudioPtr2: LPVOID,
140 dwAudioBytes2: DWORD,
141 ) -> HRESULT,
142 fn Restore() -> HRESULT,
143}}
144pub type LPDIRECTSOUNDBUFFER = *mut IDirectSoundBuffer;
145DEFINE_GUID!{IID_IReferenceClock,
146 0x56a86897, 0x0ad4, 0x11ce, 0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}
147DEFINE_GUID!{IID_IDirectSound,
148 0x279afa83, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60}
149RIDL!{#[uuid(0x279afa83, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60)]
150interface IDirectSound(IDirectSoundVtbl): IUnknown(IUnknownVtbl) {
151 fn CreateSoundBuffer(
152 pcDSBufferDesc: LPCDSBUFFERDESC,
153 ppDSBuffer: *mut LPDIRECTSOUNDBUFFER,
154 pUnkOuter: LPUNKNOWN,
155 ) -> HRESULT,
156 fn GetCaps(
157 pDSCaps: LPDSCAPS,
158 ) -> HRESULT,
159 fn DuplicateSoundBuffer(
160 pDSBufferOriginal: LPDIRECTSOUNDBUFFER,
161 ppDSBufferDuplicate: *mut LPDIRECTSOUNDBUFFER,
162 ) -> HRESULT,
163 fn SetCooperativeLevel(
164 hWnd: HWND,
165 dwLevel: DWORD,
166 ) -> HRESULT,
167 fn Compact() -> HRESULT,
168 fn GetSpeakerConfig(
169 pdwSpeakerConfig: LPDWORD,
170 ) -> HRESULT,
171 fn SetSpeakerConfig(
172 dwSpeakerConfig: DWORD,
173 ) -> HRESULT,
174 fn Initialize(
175 pcGuidDevice: LPCGUID,
176 ) -> HRESULT,
177}}
178pub type LPDIRECTSOUND = *mut IDirectSound;
179DEFINE_GUID!{IID_IDirectSound8,
180 0xc50a7e93, 0xf395, 0x4834, 0x9e, 0xf6, 0x7f, 0xa9, 0x9d, 0xe5, 0x09, 0x66}
181DEFINE_GUID!{IID_IDirectSoundBuffer,
182 0x279afa85, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60}
183DEFINE_GUID!{IID_IDirectSoundBuffer8,
184 0x6825a449, 0x7524, 0x4d82, 0x92, 0x0f, 0x50, 0xe3, 0x6a, 0xb3, 0xab, 0x1e}
185DEFINE_GUID!{GUID_All_Objects,
186 0xaa114de5, 0xc262, 0x4169, 0xa1, 0xc8, 0x23, 0xd6, 0x98, 0xcc, 0x73, 0xb5}
187DEFINE_GUID!{IID_IDirectSound3DListener,
188 0x279afa84, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60}
189DEFINE_GUID!{IID_IDirectSound3DBuffer,
190 0x279afa86, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60}
191DEFINE_GUID!{IID_IDirectSoundCapture,
192 0xb0210781, 0x89cd, 0x11d0, 0xaf, 0x08, 0x00, 0xa0, 0xc9, 0x25, 0xcd, 0x16}
193DEFINE_GUID!{IID_IDirectSoundCaptureBuffer,
194 0xb0210782, 0x89cd, 0x11d0, 0xaf, 0x08, 0x00, 0xa0, 0xc9, 0x25, 0xcd, 0x16}
195DEFINE_GUID!{IID_IDirectSoundCaptureBuffer8,
196 0x00990df4, 0x0dbb, 0x4872, 0x83, 0x3e, 0x6d, 0x30, 0x3e, 0x80, 0xae, 0xb6}
197DEFINE_GUID!{IID_IDirectSoundNotify,
198 0xb0210783, 0x89cd, 0x11d0, 0xaf, 0x08, 0x00, 0xa0, 0xc9, 0x25, 0xcd, 0x16}
199DEFINE_GUID!{IID_IKsPropertySet,
200 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93}
201DEFINE_GUID!{IID_IDirectSoundFXGargle,
202 0xd616f352, 0xd622, 0x11ce, 0xaa, 0xc5, 0x00, 0x20, 0xaf, 0x0b, 0x99, 0xa3}
203DEFINE_GUID!{IID_IDirectSoundFXChorus,
204 0x880842e3, 0x145f, 0x43e6, 0xa9, 0x34, 0xa7, 0x18, 0x06, 0xe5, 0x05, 0x47}
205DEFINE_GUID!{IID_IDirectSoundFXFlanger,
206 0x903e9878, 0x2c92, 0x4072, 0x9b, 0x2c, 0xea, 0x68, 0xf5, 0x39, 0x67, 0x83}
207DEFINE_GUID!{IID_IDirectSoundFXEcho,
208 0x8bd28edf, 0x50db, 0x4e92, 0xa2, 0xbd, 0x44, 0x54, 0x88, 0xd1, 0xed, 0x42}
209DEFINE_GUID!{IID_IDirectSoundFXDistortion,
210 0x8ecf4326, 0x455f, 0x4d8b, 0xbd, 0xa9, 0x8d, 0x5d, 0x3e, 0x9e, 0x3e, 0x0b}
211DEFINE_GUID!{IID_IDirectSoundFXCompressor,
212 0x4bbd1154, 0x62f6, 0x4e2c, 0xa1, 0x5c, 0xd3, 0xb6, 0xc4, 0x17, 0xf7, 0xa0}
213DEFINE_GUID!{IID_IDirectSoundFXParamEq,
214 0xc03ca9fe, 0xfe90, 0x4204, 0x80, 0x78, 0x82, 0x33, 0x4c, 0xd1, 0x77, 0xda}
215DEFINE_GUID!{IID_IDirectSoundFXI3DL2Reverb,
216 0x4b166a6a, 0x0d66, 0x43f3, 0x80, 0xe3, 0xee, 0x62, 0x80, 0xde, 0xe1, 0xa4}
217DEFINE_GUID!{IID_IDirectSoundFXWavesReverb,
218 0x46858c3a, 0x0dc6, 0x45e3, 0xb7, 0x60, 0xd4, 0xee, 0xf1, 0x6c, 0xb3, 0x25}
219DEFINE_GUID!{IID_IDirectSoundCaptureFXAec,
220 0xad74143d, 0x903d, 0x4ab7, 0x80, 0x66, 0x28, 0xd3, 0x63, 0x03, 0x6d, 0x65}
221DEFINE_GUID!{IID_IDirectSoundCaptureFXNoiseSuppress,
222 0xed311e41, 0xfbae, 0x4175, 0x96, 0x25, 0xcd, 0x08, 0x54, 0xf6, 0x93, 0xca}
223DEFINE_GUID!{IID_IDirectSoundFullDuplex,
224 0xedcb4c7a, 0xdaab, 0x4216, 0xa4, 0x2e, 0x6c, 0x50, 0x59, 0x6d, 0xdc, 0x1d}
225pub const DS_OK: HRESULT = S_OK;
226pub const DSERR_GENERIC: HRESULT = E_FAIL;
227pub const DSSCL_NORMAL: DWORD = 0x00000001;
228pub const DSSCL_PRIORITY: DWORD = 0x00000002;
229pub const DSSCL_EXCLUSIVE: DWORD = 0x00000003;
230pub const DSSCL_WRITEPRIMARY: DWORD = 0x00000004;
231pub const DSBCAPS_PRIMARYBUFFER: DWORD = 0x00000001;
232pub const DSBCAPS_STATIC: DWORD = 0x00000002;
233pub const DSBCAPS_LOCHARDWARE: DWORD = 0x00000004;
234pub const DSBCAPS_LOCSOFTWARE: DWORD = 0x00000008;
235pub const DSBCAPS_CTRL3D: DWORD = 0x00000010;
236pub const DSBCAPS_CTRLFREQUENCY: DWORD = 0x00000020;
237pub const DSBCAPS_CTRLPAN: DWORD = 0x00000040;
238pub const DSBCAPS_CTRLVOLUME: DWORD = 0x00000080;
239pub const DSBCAPS_CTRLPOSITIONNOTIFY: DWORD = 0x00000100;
240pub const DSBCAPS_CTRLFX: DWORD = 0x00000200;
241pub const DSBCAPS_STICKYFOCUS: DWORD = 0x00004000;
242pub const DSBCAPS_GLOBALFOCUS: DWORD = 0x00008000;
243pub const DSBCAPS_GETCURRENTPOSITION2: DWORD = 0x00010000;
244pub const DSBCAPS_MUTE3DATMAXDISTANCE: DWORD = 0x00020000;
245pub const DSBCAPS_LOCDEFER: DWORD = 0x00040000;
246pub const DSBCAPS_TRUEPLAYPOSITION: DWORD = 0x00080000;
247pub const DSBPLAY_LOOPING: DWORD = 0x00000001;
248pub const DSBPLAY_LOCHARDWARE: DWORD = 0x00000002;
249pub const DSBPLAY_LOCSOFTWARE: DWORD = 0x00000004;
250pub const DSBPLAY_TERMINATEBY_TIME: DWORD = 0x00000008;
251pub const DSBPLAY_TERMINATEBY_DISTANCE: DWORD = 0x000000010;
252pub const DSBPLAY_TERMINATEBY_PRIORITY: DWORD = 0x000000020;
253extern "system" {
254 pub fn DirectSoundCreate(
255 pcGuidDevice: LPCGUID,
256 ppDS: *mut LPDIRECTSOUND,
257 pUnkOuter: LPUNKNOWN,
258 ) -> HRESULT;
259 pub fn GetDeviceID(
303 pGuidSrc: LPCGUID,
304 pGuidDest: LPGUID,
305 ) -> HRESULT;
306}
307DEFINE_GUID!{DS3DALG_NO_VIRTUALIZATION,
308 0xc241333f, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x00, 0xc0, 0x4f, 0xc2, 0x8a, 0xca}
309DEFINE_GUID!{DS3DALG_HRTF_FULL,
310 0xc2413340, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x00, 0xc0, 0x4f, 0xc2, 0x8a, 0xca}
311DEFINE_GUID!{DS3DALG_HRTF_LIGHT,
312 0xc2413342, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x00, 0xc0, 0x4f, 0xc2, 0x8a, 0xca}
313DEFINE_GUID!{GUID_DSFX_STANDARD_GARGLE,
314 0xdafd8210, 0x5711, 0x4b91, 0x9f, 0xe3, 0xf7, 0x5b, 0x7a, 0xe2, 0x79, 0xbf}
315DEFINE_GUID!{GUID_DSFX_STANDARD_CHORUS,
316 0xefe6629c, 0x81f7, 0x4281, 0xbd, 0x91, 0xc9, 0xd6, 0x04, 0xa9, 0x5a, 0xf6}
317DEFINE_GUID!{GUID_DSFX_STANDARD_FLANGER,
318 0xefca3d92, 0xdfd8, 0x4672, 0xa6, 0x03, 0x74, 0x20, 0x89, 0x4b, 0xad, 0x98}
319DEFINE_GUID!{GUID_DSFX_STANDARD_ECHO,
320 0xef3e932c, 0xd40b, 0x4f51, 0x8c, 0xcf, 0x3f, 0x98, 0xf1, 0xb2, 0x9d, 0x5d}
321DEFINE_GUID!{GUID_DSFX_STANDARD_DISTORTION,
322 0xef114c90, 0xcd1d, 0x484e, 0x96, 0xe5, 0x09, 0xcf, 0xaf, 0x91, 0x2a, 0x21}
323DEFINE_GUID!{GUID_DSFX_STANDARD_COMPRESSOR,
324 0xef011f79, 0x4000, 0x406d, 0x87, 0xaf, 0xbf, 0xfb, 0x3f, 0xc3, 0x9d, 0x57}
325DEFINE_GUID!{GUID_DSFX_STANDARD_PARAMEQ,
326 0x120ced89, 0x3bf4, 0x4173, 0xa1, 0x32, 0x3c, 0xb4, 0x06, 0xcf, 0x32, 0x31}
327DEFINE_GUID!{GUID_DSFX_STANDARD_I3DL2REVERB,
328 0xef985e71, 0xd5c7, 0x42d4, 0xba, 0x4d, 0x2d, 0x07, 0x3e, 0x2e, 0x96, 0xf4}
329DEFINE_GUID!{GUID_DSFX_WAVES_REVERB,
330 0x87fc0268, 0x9a55, 0x4360, 0x95, 0xaa, 0x00, 0x4a, 0x1d, 0x9d, 0xe2, 0x6c}
331DEFINE_GUID!{GUID_DSCFX_CLASS_AEC,
332 0xbf963d80, 0xc559, 0x11d0, 0x8a, 0x2b, 0x00, 0xa0, 0xc9, 0x25, 0x5a, 0xc1}
333DEFINE_GUID!{GUID_DSCFX_MS_AEC,
334 0xcdebb919, 0x379a, 0x488a, 0x87, 0x65, 0xf5, 0x3c, 0xfd, 0x36, 0xde, 0x40}
335DEFINE_GUID!{GUID_DSCFX_SYSTEM_AEC,
336 0x1c22c56d, 0x9879, 0x4f5b, 0xa3, 0x89, 0x27, 0x99, 0x6d, 0xdc, 0x28, 0x10}
337DEFINE_GUID!{GUID_DSCFX_CLASS_NS,
338 0xe07f903f, 0x62fd, 0x4e60, 0x8c, 0xdd, 0xde, 0xa7, 0x23, 0x66, 0x65, 0xb5}
339DEFINE_GUID!{GUID_DSCFX_MS_NS,
340 0x11c5c73b, 0x66e9, 0x4ba1, 0xa0, 0xba, 0xe8, 0x14, 0xc6, 0xee, 0xd9, 0x2d}
341DEFINE_GUID!{GUID_DSCFX_SYSTEM_NS,
342 0x5ab0882e, 0x7274, 0x4516, 0x87, 0x7d, 0x4e, 0xee, 0x99, 0xba, 0x4f, 0xd0}