1 #ifndef __WINE_DSOUND_H
2 #define __WINE_DSOUND_H
4 #include "winbase.h" /* for CRITICAL_SECTION */
6 #include "d3d.h" /*FIXME: Need to break out d3dtypes.h */
8 DEFINE_GUID(CLSID_DirectSound
, 0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0);
10 DEFINE_GUID(IID_IDirectSound
, 0x279AFA83,0x4981,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60);
11 DEFINE_GUID(IID_IDirectSoundBuffer
, 0x279AFA85,0x4981,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60);
12 DEFINE_GUID(IID_IDirectSoundNotify
, 0xB0210783,0x89cd,0x11d0,0xAF,0x08,0x00,0xA0,0xC9,0x25,0xCD,0x16);
13 DEFINE_GUID(IID_IDirectSound3DListener
, 0x279AFA84,0x4981,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60);
14 DEFINE_GUID(IID_IDirectSound3DBuffer
, 0x279AFA86,0x4981,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60);
15 DEFINE_GUID(IID_IDirectSoundCapture
, 0xB0210781,0x89CD,0x11D0,0xAF,0x08,0x00,0xA0,0xC9,0x25,0xCD,0x16);
16 DEFINE_GUID(IID_IDirectSoundCaptureBuffer
,0xB0210782,0x89CD,0x11D0,0xAF,0x08,0x00,0xA0,0xC9,0x25,0xCD,0x16);
17 DEFINE_GUID(IID_IKsPropertySet
, 0x31EFAC30,0x515C,0x11D0,0xA9,0xAA,0x00,0xAA,0x00,0x61,0xBE,0x93);
21 typedef struct IDirectSound IDirectSound
,*LPDIRECTSOUND
;
22 typedef struct IDirectSoundNotify IDirectSoundNotify
,*LPDIRECTSOUNDNOTIFY
;
23 typedef struct IDirectSoundBuffer IDirectSoundBuffer
,*LPDIRECTSOUNDBUFFER
,**LPLPDIRECTSOUNDBUFFER
;
24 typedef struct IDirectSound3DListener IDirectSound3DListener
,*LPDIRECTSOUND3DLISTENER
,**LPLPDIRECTSOUND3DLISTENER
;
25 typedef struct IDirectSound3DBuffer IDirectSound3DBuffer
,*LPDIRECTSOUND3DBUFFER
,**LPLPDIRECTSOUND3DBUFFER
;
28 #define MAKE_DSHRESULT(code) MAKE_HRESULT(1,_FACDS,code)
31 #define DSERR_ALLOCATED MAKE_DSHRESULT(10)
32 #define DSERR_CONTROLUNAVAIL MAKE_DSHRESULT(30)
33 #define DSERR_INVALIDPARAM E_INVALIDARG
34 #define DSERR_INVALIDCALL MAKE_DSHRESULT(50)
35 #define DSERR_GENERIC E_FAIL
36 #define DSERR_PRIOLEVELNEEDED MAKE_DSHRESULT(70)
37 #define DSERR_OUTOFMEMORY E_OUTOFMEMORY
38 #define DSERR_BADFORMAT MAKE_DSHRESULT(100)
39 #define DSERR_UNSUPPORTED E_NOTIMPL
40 #define DSERR_NODRIVER MAKE_DSHRESULT(120)
41 #define DSERR_ALREADYINITIALIZED MAKE_DSHRESULT(130)
42 #define DSERR_NOAGGREGATION CLASS_E_NOAGGREGATION
43 #define DSERR_BUFFERLOST MAKE_DSHRESULT(150)
44 #define DSERR_OTHERAPPHASPRIO MAKE_DSHRESULT(160)
45 #define DSERR_UNINITIALIZED MAKE_DSHRESULT(170)
47 #define DSCAPS_PRIMARYMONO 0x00000001
48 #define DSCAPS_PRIMARYSTEREO 0x00000002
49 #define DSCAPS_PRIMARY8BIT 0x00000004
50 #define DSCAPS_PRIMARY16BIT 0x00000008
51 #define DSCAPS_CONTINUOUSRATE 0x00000010
52 #define DSCAPS_EMULDRIVER 0x00000020
53 #define DSCAPS_CERTIFIED 0x00000040
54 #define DSCAPS_SECONDARYMONO 0x00000100
55 #define DSCAPS_SECONDARYSTEREO 0x00000200
56 #define DSCAPS_SECONDARY8BIT 0x00000400
57 #define DSCAPS_SECONDARY16BIT 0x00000800
59 #define DSSCL_NORMAL 1
60 #define DSSCL_PRIORITY 2
61 #define DSSCL_EXCLUSIVE 3
62 #define DSSCL_WRITEPRIMARY 4
64 typedef struct _DSCAPS
68 DWORD dwMinSecondarySampleRate
;
69 DWORD dwMaxSecondarySampleRate
;
70 DWORD dwPrimaryBuffers
;
71 DWORD dwMaxHwMixingAllBuffers
;
72 DWORD dwMaxHwMixingStaticBuffers
;
73 DWORD dwMaxHwMixingStreamingBuffers
;
74 DWORD dwFreeHwMixingAllBuffers
;
75 DWORD dwFreeHwMixingStaticBuffers
;
76 DWORD dwFreeHwMixingStreamingBuffers
;
77 DWORD dwMaxHw3DAllBuffers
;
78 DWORD dwMaxHw3DStaticBuffers
;
79 DWORD dwMaxHw3DStreamingBuffers
;
80 DWORD dwFreeHw3DAllBuffers
;
81 DWORD dwFreeHw3DStaticBuffers
;
82 DWORD dwFreeHw3DStreamingBuffers
;
83 DWORD dwTotalHwMemBytes
;
84 DWORD dwFreeHwMemBytes
;
85 DWORD dwMaxContigFreeHwMemBytes
;
86 DWORD dwUnlockTransferRateHwBuffers
;
87 DWORD dwPlayCpuOverheadSwBuffers
;
92 #define DSBPLAY_LOOPING 0x00000001
94 #define DSBSTATUS_PLAYING 0x00000001
95 #define DSBSTATUS_BUFFERLOST 0x00000002
96 #define DSBSTATUS_LOOPING 0x00000004
99 #define DSBLOCK_FROMWRITECURSOR 0x00000001
100 #define DSBLOCK_ENTIREBUFFER 0x00000002
102 #define DSBCAPS_PRIMARYBUFFER 0x00000001
103 #define DSBCAPS_STATIC 0x00000002
104 #define DSBCAPS_LOCHARDWARE 0x00000004
105 #define DSBCAPS_LOCSOFTWARE 0x00000008
106 #define DSBCAPS_CTRL3D 0x00000010
107 #define DSBCAPS_CTRLFREQUENCY 0x00000020
108 #define DSBCAPS_CTRLPAN 0x00000040
109 #define DSBCAPS_CTRLVOLUME 0x00000080
110 #define DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100
111 #define DSBCAPS_CTRLDEFAULT 0x000000E0 /* Pan + volume + frequency. */
112 #define DSBCAPS_CTRLALL 0x000001F0 /* All control capabilities */
113 #define DSBCAPS_STICKYFOCUS 0x00004000
114 #define DSBCAPS_GLOBALFOCUS 0x00008000
115 #define DSBCAPS_GETCURRENTPOSITION2 0x00010000 /* More accurate play cursor under emulation*/
116 #define DSBCAPS_MUTE3DATMAXDISTANCE 0x00020000
118 #define DSBPAN_LEFT -10000
119 #define DSBPAN_RIGHT 10000
120 #define DSBVOLUME_MAX 0
121 #define DSBVOLUME_MIN -10000
122 #define DSBFREQUENCY_MIN 100
123 #define DSBFREQUENCY_MAX 100000
124 #define DSBFREQUENCY_ORIGINAL 0
126 typedef struct _DSBCAPS
131 DWORD dwUnlockTransferRate
;
132 DWORD dwPlayCpuOverhead
;
133 } DSBCAPS
,*LPDSBCAPS
;
135 #define DSSCL_NORMAL 1
136 #define DSSCL_PRIORITY 2
137 #define DSSCL_EXCLUSIVE 3
138 #define DSSCL_WRITEPRIMARY 4
140 typedef struct _DSBUFFERDESC
146 LPWAVEFORMATEX lpwfxFormat
;
147 } DSBUFFERDESC
,*LPDSBUFFERDESC
;
149 typedef struct _DSBPOSITIONNOTIFY
153 } DSBPOSITIONNOTIFY
,*LPDSBPOSITIONNOTIFY
;
155 typedef const DSBPOSITIONNOTIFY
*LPCDSBPOSITIONNOTIFY
;
157 #define DSSPEAKER_HEADPHONE 1
158 #define DSSPEAKER_MONO 2
159 #define DSSPEAKER_QUAD 3
160 #define DSSPEAKER_STEREO 4
161 #define DSSPEAKER_SURROUND 5
163 #define DSSPEAKER_GEOMETRY_MIN 0x00000005 /* 5 degrees */
164 #define DSSPEAKER_GEOMETRY_NARROW 0x0000000A /* 10 degrees */
165 #define DSSPEAKER_GEOMETRY_WIDE 0x00000014 /* 20 degrees */
166 #define DSSPEAKER_GEOMETRY_MAX 0x000000B4 /* 180 degrees */
169 typedef LPVOID
* LPLPVOID
;
171 typedef BOOL (CALLBACK
*LPDSENUMCALLBACKW
)(LPGUID
,LPWSTR
,LPWSTR
,LPVOID
);
172 typedef BOOL (CALLBACK
*LPDSENUMCALLBACKA
)(LPGUID
,LPSTR
,LPSTR
,LPVOID
);
174 extern HRESULT WINAPI
DirectSoundCreate(REFGUID lpGUID
,LPDIRECTSOUND
* ppDS
,IUnknown
*pUnkOuter
);
176 #define STDMETHOD(xfn) HRESULT (CALLBACK *fn##xfn)
177 #define STDMETHOD_(ret,xfn) ret (CALLBACK *fn##xfn)
182 #define THIS LPDIRECTSOUND this
183 typedef struct tagLPDIRECTSOUND_VTABLE
185 /*** IUnknown methods ***/
186 STDMETHOD(QueryInterface
) (THIS_ REFIID riid
, LPVOID
* ppvObj
) PURE
;
187 STDMETHOD_(ULONG
,AddRef
) (THIS
) PURE
;
188 STDMETHOD_(ULONG
,Release
) (THIS
) PURE
;
189 /*** IDirectSound methods ***/
191 STDMETHOD( CreateSoundBuffer
)(THIS_ LPDSBUFFERDESC
, LPLPDIRECTSOUNDBUFFER
, IUnknown FAR
*) PURE
;
192 STDMETHOD( GetCaps
)(THIS_ LPDSCAPS
) PURE
;
193 STDMETHOD( DuplicateSoundBuffer
)(THIS_ LPDIRECTSOUNDBUFFER
, LPLPDIRECTSOUNDBUFFER
) PURE
;
194 STDMETHOD( SetCooperativeLevel
)(THIS_ HWND
, DWORD
) PURE
;
195 STDMETHOD( Compact
)(THIS
) PURE
;
196 STDMETHOD( GetSpeakerConfig
)(THIS_ LPDWORD
) PURE
;
197 STDMETHOD( SetSpeakerConfig
)(THIS_ DWORD
) PURE
;
198 STDMETHOD( Initialize
)(THIS_ LPGUID
) PURE
;
199 } *LPDIRECTSOUND_VTABLE
;
201 struct IDirectSound
{
202 LPDIRECTSOUND_VTABLE lpvtbl
;
206 LPDIRECTSOUNDBUFFER
*buffers
;
207 LPDIRECTSOUNDBUFFER primary
;
208 LPDIRECTSOUND3DLISTENER listener
;
209 WAVEFORMATEX wfx
; /* current main waveformat */
213 #define THIS LPDIRECTSOUNDBUFFER this
214 typedef struct tagLPDIRECTSOUNDBUFFER_VTABLE
216 /*** IUnknown methods ***/
217 STDMETHOD(QueryInterface
) (THIS_ REFIID riid
, LPVOID
* ppvObj
) PURE
;
218 STDMETHOD_(ULONG
,AddRef
) (THIS
) PURE
;
219 STDMETHOD_(ULONG
,Release
) (THIS
) PURE
;
220 /*** IDirectSoundBuffer methods ***/
222 STDMETHOD( GetCaps
)(THIS_ LPDSBCAPS
) PURE
;
223 STDMETHOD(GetCurrentPosition16
)(THIS_ LPDWORD
,LPDWORD
) PURE
;
224 STDMETHOD( GetFormat
)(THIS_ LPWAVEFORMATEX
, DWORD
, LPDWORD
) PURE
;
225 STDMETHOD( GetVolume
)(THIS_ LPLONG
) PURE
;
226 STDMETHOD( GetPan
)(THIS_ LPLONG
) PURE
;
227 STDMETHOD( GetFrequency
)(THIS_ LPDWORD
) PURE
;
228 STDMETHOD( GetStatus
)(THIS_ LPDWORD
) PURE
;
229 STDMETHOD( Initialize
)(THIS_ LPDIRECTSOUND
, LPDSBUFFERDESC
) PURE
;
230 STDMETHOD( Lock
)(THIS_ DWORD
,DWORD
,LPVOID
,LPDWORD
,LPVOID
,LPDWORD
,DWORD
) PURE
;
231 STDMETHOD( Play
)(THIS_ DWORD
,DWORD
,DWORD
) PURE
;
232 STDMETHOD(SetCurrentPosition
)(THIS_ DWORD
) PURE
;
233 STDMETHOD( SetFormat
)(THIS_ LPWAVEFORMATEX
) PURE
;
234 STDMETHOD( SetVolume
)(THIS_ LONG
) PURE
;
235 STDMETHOD( SetPan
)(THIS_ LONG
) PURE
;
236 STDMETHOD( SetFrequency
)(THIS_ DWORD
) PURE
;
237 STDMETHOD( Stop
)(THIS
) PURE
;
238 STDMETHOD( Unlock
)(THIS_ LPVOID
,DWORD
,LPVOID
,DWORD
) PURE
;
239 STDMETHOD( Restore
)(THIS
) PURE
;
240 } *LPDIRECTSOUNDBUFFER_VTABLE
;
242 struct IDirectSoundBuffer
{
243 LPDIRECTSOUNDBUFFER_VTABLE lpvtbl
;
247 LPDIRECTSOUND3DBUFFER ds3db
;
248 DWORD playflags
,playing
;
249 DWORD playpos
,writepos
,buflen
;
250 DWORD nAvgBytesPerSec
;
254 LONG lVolAdjust
,rVolAdjust
;
255 LPDIRECTSOUNDBUFFER parent
; /* for duplicates */
256 LPDIRECTSOUND dsound
;
258 LPDSBPOSITIONNOTIFY notifies
;
260 CRITICAL_SECTION lock
;
264 #define WINE_NOBUFFER 0x80000000
266 #define DSBPN_OFFSETSTOP -1
268 #define THIS LPDIRECTSOUNDNOTIFY this
269 typedef struct IDirectSoundNotify_VTable
{
270 /* IUnknown methods */
271 STDMETHOD(QueryInterface
) (THIS_ REFIID
, LPVOID
*) PURE
;
272 STDMETHOD_(ULONG
,AddRef
) (THIS
) PURE
;
273 STDMETHOD_(ULONG
,Release
) (THIS
) PURE
;
275 /* IDirectSoundNotify methods */
276 STDMETHOD(SetNotificationPositions
) (THIS_ DWORD
, LPCDSBPOSITIONNOTIFY
) PURE
;
277 } *LPDIRECTSOUNDNOTIFY_VTABLE
,IDirectSoundNotify_VTable
;
279 struct IDirectSoundNotify
{
280 LPDIRECTSOUNDNOTIFY_VTABLE lpvtbl
;
282 LPDIRECTSOUNDBUFFER dsb
;
286 #define DS3DMODE_NORMAL 0x00000000
287 #define DS3DMODE_HEADRELATIVE 0x00000001
288 #define DS3DMODE_DISABLE 0x00000002
290 #define DS3D_IMMEDIATE 0x00000000
291 #define DS3D_DEFERRED 0x00000001
293 #define DS3D_MINDISTANCEFACTOR 0.0f
294 #define DS3D_MAXDISTANCEFACTOR 10.0f
295 #define DS3D_DEFAULTDISTANCEFACTOR 1.0f
297 #define DS3D_MINROLLOFFFACTOR 0.0f
298 #define DS3D_MAXROLLOFFFACTOR 10.0f
299 #define DS3D_DEFAULTROLLOFFFACTOR 1.0f
301 #define DS3D_MINDOPPLERFACTOR 0.0f
302 #define DS3D_MAXDOPPLERFACTOR 10.0f
303 #define DS3D_DEFAULTDOPPLERFACTOR 1.0f
305 #define DS3D_DEFAULTMINDISTANCE 1.0f
306 #define DS3D_DEFAULTMAXDISTANCE 1000000000.0f
308 #define DS3D_MINCONEANGLE 0
309 #define DS3D_MAXCONEANGLE 360
310 #define DS3D_DEFAULTCONEANGLE 360
312 #define DS3D_DEFAULTCONEOUTSIDEVOLUME 0
314 typedef struct _DS3DLISTENER
{
318 D3DVECTOR vOrientFront
;
319 D3DVECTOR vOrientTop
;
320 D3DVALUE flDistanceFactor
;
321 D3DVALUE flRolloffFactor
;
322 D3DVALUE flDopplerFactor
;
323 } DS3DLISTENER
, *LPDS3DLISTENER
;
325 typedef const DS3DLISTENER
*LPCDS3DLISTENER
;
327 #define THIS LPDIRECTSOUND3DLISTENER this
328 typedef struct IDirectSound3DListener_VTable
330 /* IUnknown methods */
331 STDMETHOD(QueryInterface
) (THIS_ REFIID
, LPVOID FAR
*) PURE
;
332 STDMETHOD_(ULONG
,AddRef
) (THIS
) PURE
;
333 STDMETHOD_(ULONG
,Release
) (THIS
) PURE
;
335 /* IDirectSound3DListener methods */
336 STDMETHOD(GetAllParameters
) (THIS_ LPDS3DLISTENER
) PURE
;
337 STDMETHOD(GetDistanceFactor
) (THIS_ LPD3DVALUE
) PURE
;
338 STDMETHOD(GetDopplerFactor
) (THIS_ LPD3DVALUE
) PURE
;
339 STDMETHOD(GetOrientation
) (THIS_ LPD3DVECTOR
, LPD3DVECTOR
) PURE
;
340 STDMETHOD(GetPosition
) (THIS_ LPD3DVECTOR
) PURE
;
341 STDMETHOD(GetRolloffFactor
) (THIS_ LPD3DVALUE
) PURE
;
342 STDMETHOD(GetVelocity
) (THIS_ LPD3DVECTOR
) PURE
;
343 STDMETHOD(SetAllParameters
) (THIS_ LPCDS3DLISTENER
, DWORD
) PURE
;
344 STDMETHOD(SetDistanceFactor
) (THIS_ D3DVALUE
, DWORD
) PURE
;
345 STDMETHOD(SetDopplerFactor
) (THIS_ D3DVALUE
, DWORD
) PURE
;
346 STDMETHOD(SetOrientation
) (THIS_ D3DVALUE
, D3DVALUE
, D3DVALUE
, D3DVALUE
, D3DVALUE
, D3DVALUE
, DWORD
) PURE
;
347 STDMETHOD(SetPosition
) (THIS_ D3DVALUE
, D3DVALUE
, D3DVALUE
, DWORD
) PURE
;
348 STDMETHOD(SetRolloffFactor
) (THIS_ D3DVALUE
, DWORD
) PURE
;
349 STDMETHOD(SetVelocity
) (THIS_ D3DVALUE
, D3DVALUE
, D3DVALUE
, DWORD
) PURE
;
350 STDMETHOD(CommitDeferredSettings
) (THIS
) PURE
;
351 } *LPDIRECTSOUND3DLISTENER_VTABLE
, IDirectSound3DListener_VTable
;
353 struct IDirectSound3DListener
{
354 LPDIRECTSOUND3DLISTENER_VTABLE lpvtbl
;
356 LPDIRECTSOUNDBUFFER dsb
;
358 CRITICAL_SECTION lock
;
362 typedef struct _DS3DBUFFER
{
366 DWORD dwInsideConeAngle
;
367 DWORD dwOutsideConeAngle
;
368 D3DVECTOR vConeOrientation
;
369 LONG lConeOutsideVolume
;
370 D3DVALUE flMinDistance
;
371 D3DVALUE flMaxDistance
;
373 } DS3DBUFFER
, *LPDS3DBUFFER
;
375 typedef const DS3DBUFFER
*LPCDS3DBUFFER
;
377 #define THIS LPDIRECTSOUND3DBUFFER this
378 typedef struct IDirectSound3DBuffer_VTable
380 /* IUnknown methods */
381 STDMETHOD(QueryInterface
) (THIS_ REFIID
, LPVOID FAR
*) PURE
;
382 STDMETHOD_(ULONG
,AddRef
) (THIS
) PURE
;
383 STDMETHOD_(ULONG
,Release
) (THIS
) PURE
;
385 /* IDirectSound3DBuffer methods */
386 STDMETHOD(GetAllParameters
) (THIS_ LPDS3DBUFFER
) PURE
;
387 STDMETHOD(GetConeAngles
) (THIS_ LPDWORD
, LPDWORD
) PURE
;
388 STDMETHOD(GetConeOrientation
) (THIS_ LPD3DVECTOR
) PURE
;
389 STDMETHOD(GetConeOutsideVolume
) (THIS_ LPLONG
) PURE
;
390 STDMETHOD(GetMaxDistance
) (THIS_ LPD3DVALUE
) PURE
;
391 STDMETHOD(GetMinDistance
) (THIS_ LPD3DVALUE
) PURE
;
392 STDMETHOD(GetMode
) (THIS_ LPDWORD
) PURE
;
393 STDMETHOD(GetPosition
) (THIS_ LPD3DVECTOR
) PURE
;
394 STDMETHOD(GetVelocity
) (THIS_ LPD3DVECTOR
) PURE
;
395 STDMETHOD(SetAllParameters
) (THIS_ LPCDS3DBUFFER
, DWORD
) PURE
;
396 STDMETHOD(SetConeAngles
) (THIS_ DWORD
, DWORD
, DWORD
) PURE
;
397 STDMETHOD(SetConeOrientation
) (THIS_ D3DVALUE
, D3DVALUE
, D3DVALUE
, DWORD
) PURE
;
398 STDMETHOD(SetConeOutsideVolume
) (THIS_ LONG
, DWORD
) PURE
;
399 STDMETHOD(SetMaxDistance
) (THIS_ D3DVALUE
, DWORD
) PURE
;
400 STDMETHOD(SetMinDistance
) (THIS_ D3DVALUE
, DWORD
) PURE
;
401 STDMETHOD(SetMode
) (THIS_ DWORD
, DWORD
) PURE
;
402 STDMETHOD(SetPosition
) (THIS_ D3DVALUE
, D3DVALUE
, D3DVALUE
, DWORD
) PURE
;
403 STDMETHOD(SetVelocity
) (THIS_ D3DVALUE
, D3DVALUE
, D3DVALUE
, DWORD
) PURE
;
404 } *LPDIRECTSOUND3DBUFFER_VTABLE
, IDirectSound3DBuffer_VTable
;
406 struct IDirectSound3DBuffer
{
407 LPDIRECTSOUND3DBUFFER_VTABLE lpvtbl
;
409 LPDIRECTSOUNDBUFFER dsb
;
413 CRITICAL_SECTION lock
;