1/*==========================================================================;
2 *
3 *  Copyright (C) 1995,1996 Microsoft Corporation.  All Rights Reserved.
4 *
5 *  File:       dsound.h
6 *  Content:    DirectSound include file
7 *
8 ***************************************************************************/
9
10#ifndef __DSOUND_INCLUDED__
11#define __DSOUND_INCLUDED__
12
13#ifdef _WIN32
14#define COM_NO_WINDOWS_H
15#include <objbase.h>
16#endif
17
18#define _FACDS  0x878
19#define MAKE_DSHRESULT( code )  MAKE_HRESULT( 1, _FACDS, code )
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25// Direct Sound Component GUID    {47D4D946-62E8-11cf-93BC-444553540000}
26DEFINE_GUID(CLSID_DirectSound,
270x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0);
28
29// DirectSound 279afa83-4981-11ce-a521-0020af0be560
30DEFINE_GUID(IID_IDirectSound,0x279AFA83,0x4981,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60);
31// DirectSoundBuffer 279afa85-4981-11ce-a521-0020af0be560
32DEFINE_GUID(IID_IDirectSoundBuffer,0x279AFA85,0x4981,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60);
33
34
35
36//==========================================================================;
37//
38//                            Structures...
39//
40//==========================================================================;
41#ifdef __cplusplus
42/* 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined */
43struct IDirectSound;
44struct IDirectSoundBuffer;
45#endif
46
47typedef struct IDirectSound           *LPDIRECTSOUND;
48typedef struct IDirectSoundBuffer     *LPDIRECTSOUNDBUFFER;
49typedef struct IDirectSoundBuffer    **LPLPDIRECTSOUNDBUFFER;
50
51
52typedef struct _DSCAPS
53{
54    DWORD       dwSize;
55    DWORD       dwFlags;
56    DWORD       dwMinSecondarySampleRate;
57    DWORD       dwMaxSecondarySampleRate;
58    DWORD       dwPrimaryBuffers;
59    DWORD       dwMaxHwMixingAllBuffers;
60    DWORD       dwMaxHwMixingStaticBuffers;
61    DWORD       dwMaxHwMixingStreamingBuffers;
62    DWORD       dwFreeHwMixingAllBuffers;
63    DWORD       dwFreeHwMixingStaticBuffers;
64    DWORD       dwFreeHwMixingStreamingBuffers;
65    DWORD       dwMaxHw3DAllBuffers;
66    DWORD       dwMaxHw3DStaticBuffers;
67    DWORD       dwMaxHw3DStreamingBuffers;
68    DWORD       dwFreeHw3DAllBuffers;
69    DWORD       dwFreeHw3DStaticBuffers;
70    DWORD       dwFreeHw3DStreamingBuffers;
71    DWORD       dwTotalHwMemBytes;
72    DWORD       dwFreeHwMemBytes;
73    DWORD       dwMaxContigFreeHwMemBytes;
74    DWORD       dwUnlockTransferRateHwBuffers;
75    DWORD       dwPlayCpuOverheadSwBuffers;
76    DWORD       dwReserved1;
77    DWORD       dwReserved2;
78} DSCAPS, *LPDSCAPS;
79
80typedef struct _DSBCAPS
81{
82
83    DWORD       dwSize;
84    DWORD       dwFlags;
85    DWORD       dwBufferBytes;
86    DWORD       dwUnlockTransferRate;
87    DWORD       dwPlayCpuOverhead;
88} DSBCAPS, *LPDSBCAPS;
89
90typedef struct _DSBUFFERDESC
91{
92    DWORD                   dwSize;
93    DWORD                   dwFlags;
94    DWORD                   dwBufferBytes;
95    DWORD                   dwReserved;
96    LPWAVEFORMATEX          lpwfxFormat;
97} DSBUFFERDESC, *LPDSBUFFERDESC;
98
99
100
101typedef LPVOID* LPLPVOID;
102
103
104typedef BOOL (FAR PASCAL * LPDSENUMCALLBACKW)(GUID FAR *, LPWSTR, LPWSTR, LPVOID);
105typedef BOOL (FAR PASCAL * LPDSENUMCALLBACKA)(GUID FAR *, LPSTR, LPSTR, LPVOID);
106
107extern HRESULT WINAPI DirectSoundCreate(GUID FAR * lpGUID, LPDIRECTSOUND * ppDS, IUnknown FAR *pUnkOuter );
108extern HRESULT WINAPI DirectSoundEnumerateW(LPDSENUMCALLBACKW lpCallback, LPVOID lpContext );
109extern HRESULT WINAPI DirectSoundEnumerateA(LPDSENUMCALLBACKA lpCallback, LPVOID lpContext );
110
111#ifdef UNICODE
112#define LPDSENUMCALLBACK        LPDSENUMCALLBACKW
113#define DirectSoundEnumerate    DirectSoundEnumerateW
114#else
115#define LPDSENUMCALLBACK        LPDSENUMCALLBACKA
116#define DirectSoundEnumerate    DirectSoundEnumerateA
117#endif
118
119//
120// IDirectSound
121//
122#undef INTERFACE
123#define INTERFACE IDirectSound
124#ifdef _WIN32
125DECLARE_INTERFACE_( IDirectSound, IUnknown )
126{
127    /*** IUnknown methods ***/
128    STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
129    STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
130    STDMETHOD_(ULONG,Release) (THIS) PURE;
131    /*** IDirectSound methods ***/
132
133    STDMETHOD( CreateSoundBuffer)(THIS_ LPDSBUFFERDESC, LPLPDIRECTSOUNDBUFFER, IUnknown FAR *) PURE;
134    STDMETHOD( GetCaps)(THIS_ LPDSCAPS ) PURE;
135    STDMETHOD( DuplicateSoundBuffer)(THIS_ LPDIRECTSOUNDBUFFER, LPLPDIRECTSOUNDBUFFER ) PURE;
136    STDMETHOD( SetCooperativeLevel)(THIS_ HWND, DWORD ) PURE;
137    STDMETHOD( Compact)(THIS ) PURE;
138    STDMETHOD( GetSpeakerConfig)(THIS_ LPDWORD ) PURE;
139    STDMETHOD( SetSpeakerConfig)(THIS_ DWORD ) PURE;
140    STDMETHOD( Initialize)(THIS_ GUID FAR * ) PURE;
141};
142
143#if !defined(__cplusplus) || defined(CINTERFACE)
144#define IDirectSound_QueryInterface(p,a,b)       (p)->lpVtbl->QueryInterface(p,a,b)
145#define IDirectSound_AddRef(p)                   (p)->lpVtbl->AddRef(p)
146#define IDirectSound_Release(p)                  (p)->lpVtbl->Release(p)
147#define IDirectSound_CreateSoundBuffer(p,a,b,c)  (p)->lpVtbl->CreateSoundBuffer(p,a,b,c)
148#define IDirectSound_GetCaps(p,a)                (p)->lpVtbl->GetCaps(p,a)
149#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->lpVtbl->DuplicateSoundBuffer(p,a,b)
150#define IDirectSound_SetCooperativeLevel(p,a,b)  (p)->lpVtbl->SetCooperativeLevel(p,a,b)
151#define IDirectSound_Compact(p)                  (p)->lpVtbl->Compact(p)
152#define IDirectSound_GetSpeakerConfig(p,a)       (p)->lpVtbl->GetSpeakerConfig(p,a)
153#define IDirectSound_SetSpeakerConfig(p,b)       (p)->lpVtbl->SetSpeakerConfig(p,b)
154#define IDirectSound_Initialize(p,a)             (p)->lpVtbl->Initialize(p,a)
155#endif
156
157#endif
158
159//
160// IDirectSoundBuffer
161//
162#undef INTERFACE
163#define INTERFACE IDirectSoundBuffer
164#ifdef _WIN32
165DECLARE_INTERFACE_( IDirectSoundBuffer, IUnknown )
166{
167    /*** IUnknown methods ***/
168    STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
169    STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
170    STDMETHOD_(ULONG,Release) (THIS) PURE;
171    /*** IDirectSoundBuffer methods ***/
172
173    STDMETHOD(           GetCaps)(THIS_ LPDSBCAPS ) PURE;
174    STDMETHOD(GetCurrentPosition)(THIS_ LPDWORD,LPDWORD ) PURE;
175    STDMETHOD(         GetFormat)(THIS_ LPWAVEFORMATEX, DWORD, LPDWORD ) PURE;
176    STDMETHOD(         GetVolume)(THIS_ LPLONG ) PURE;
177    STDMETHOD(            GetPan)(THIS_ LPLONG ) PURE;
178    STDMETHOD(      GetFrequency)(THIS_ LPDWORD ) PURE;
179    STDMETHOD(         GetStatus)(THIS_ LPDWORD ) PURE;
180    STDMETHOD(        Initialize)(THIS_ LPDIRECTSOUND, LPDSBUFFERDESC ) PURE;
181    STDMETHOD(              Lock)(THIS_ DWORD,DWORD,LPVOID,LPDWORD,LPVOID,LPDWORD,DWORD ) PURE;
182    STDMETHOD(              Play)(THIS_ DWORD,DWORD,DWORD ) PURE;
183    STDMETHOD(SetCurrentPosition)(THIS_ DWORD ) PURE;
184    STDMETHOD(         SetFormat)(THIS_ LPWAVEFORMATEX ) PURE;
185    STDMETHOD(         SetVolume)(THIS_ LONG ) PURE;
186    STDMETHOD(            SetPan)(THIS_ LONG ) PURE;
187    STDMETHOD(      SetFrequency)(THIS_ DWORD ) PURE;
188    STDMETHOD(              Stop)(THIS  ) PURE;
189    STDMETHOD(            Unlock)(THIS_ LPVOID,DWORD,LPVOID,DWORD ) PURE;
190    STDMETHOD(           Restore)(THIS  ) PURE;
191};
192
193#if !defined(__cplusplus) || defined(CINTERFACE)
194#define IDirectSoundBuffer_QueryInterface(p,a,b)        (p)->lpVtbl->QueryInterface(p,a,b)
195#define IDirectSoundBuffer_AddRef(p)                    (p)->lpVtbl->AddRef(p)
196#define IDirectSoundBuffer_Release(p)                   (p)->lpVtbl->Release(p)
197#define IDirectSoundBuffer_GetCaps(p,a)                 (p)->lpVtbl->GetCaps(p,a)
198#define IDirectSoundBuffer_GetCurrentPosition(p,a,b)    (p)->lpVtbl->GetCurrentPosition(p,a,b)
199#define IDirectSoundBuffer_GetFormat(p,a,b,c)           (p)->lpVtbl->GetFormat(p,a,b,c)
200#define IDirectSoundBuffer_GetVolume(p,a)               (p)->lpVtbl->GetVolume(p,a)
201#define IDirectSoundBuffer_GetPan(p,a)                  (p)->lpVtbl->GetPan(p,a)
202#define IDirectSoundBuffer_GetFrequency(p,a)            (p)->lpVtbl->GetFrequency(p,a)
203#define IDirectSoundBuffer_GetStatus(p,a)               (p)->lpVtbl->GetStatus(p,a)
204#define IDirectSoundBuffer_Initialize(p,a,b)            (p)->lpVtbl->Initialize(p,a,b)
205#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g)        (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g)
206#define IDirectSoundBuffer_Play(p,a,b,c)                (p)->lpVtbl->Play(p,a,b,c)
207#define IDirectSoundBuffer_SetCurrentPosition(p,a)      (p)->lpVtbl->SetCurrentPosition(p,a)
208#define IDirectSoundBuffer_SetFormat(p,a)               (p)->lpVtbl->SetFormat(p,a)
209#define IDirectSoundBuffer_SetVolume(p,a)               (p)->lpVtbl->SetVolume(p,a)
210#define IDirectSoundBuffer_SetPan(p,a)                  (p)->lpVtbl->SetPan(p,a)
211#define IDirectSoundBuffer_SetFrequency(p,a)            (p)->lpVtbl->SetFrequency(p,a)
212#define IDirectSoundBuffer_Stop(p)                      (p)->lpVtbl->Stop(p)
213#define IDirectSoundBuffer_Unlock(p,a,b,c,d)            (p)->lpVtbl->Unlock(p,a,b,c,d)
214#define IDirectSoundBuffer_Restore(p)                   (p)->lpVtbl->Restore(p)
215#endif
216
217#endif
218
219
220
221/*
222 * Return Codes
223 */
224
225#define DS_OK                           0
226
227/*
228 * The call failed because resources (such as a priority level)
229 *  were already being used by another caller.
230 */
231#define DSERR_ALLOCATED                 MAKE_DSHRESULT( 10 )
232/*
233 * The control (vol,pan,etc.) requested by the caller is not available.
234 */
235#define DSERR_CONTROLUNAVAIL            MAKE_DSHRESULT( 30 )
236/*
237 * An invalid parameter was passed to the returning function
238 */
239#define DSERR_INVALIDPARAM              E_INVALIDARG
240/*
241 * This call is not valid for the current state of this object
242 */
243#define DSERR_INVALIDCALL               MAKE_DSHRESULT( 50 )
244/*
245 * An undetermined error occured inside the DSound subsystem
246 */
247#define DSERR_GENERIC                   E_FAIL
248/*
249 * The caller does not have the priority level required for the function to
250 * succeed.
251 */
252#define DSERR_PRIOLEVELNEEDED           MAKE_DSHRESULT( 70 )
253/*
254 * The DSound subsystem couldn't allocate sufficient memory to complete the
255 * caller's request.
256 */
257#define DSERR_OUTOFMEMORY               E_OUTOFMEMORY
258/*
259 * The specified WAVE format is not supported
260 */
261#define DSERR_BADFORMAT                 MAKE_DSHRESULT( 100 )
262/*
263 * The function called is not supported at this time
264 */
265#define DSERR_UNSUPPORTED               E_NOTIMPL
266/*
267 * No sound driver is available for use
268 */
269#define DSERR_NODRIVER                  MAKE_DSHRESULT( 120 )
270/*
271 * This object is already initialized
272 */
273#define DSERR_ALREADYINITIALIZED        MAKE_DSHRESULT( 130 )
274/*
275 * This object does not support aggregation
276 */
277#define DSERR_NOAGGREGATION             CLASS_E_NOAGGREGATION
278/*
279 * The buffer memory has been lost, and must be Restored.
280 */
281#define DSERR_BUFFERLOST                MAKE_DSHRESULT( 150 )
282/*
283 * Another app has a higher priority level, preventing this call from
284 * succeeding.
285 */
286#define DSERR_OTHERAPPHASPRIO           MAKE_DSHRESULT( 160 )
287/*
288 * The Initialize() member on the Direct Sound Object has not been
289 * called or called successfully before calls to other members.
290 */
291#define DSERR_UNINITIALIZED             MAKE_DSHRESULT( 170 )
292
293
294
295
296//==========================================================================;
297//
298//                               Flags...
299//
300//==========================================================================;
301
302#define DSCAPS_PRIMARYMONO          0x00000001
303#define DSCAPS_PRIMARYSTEREO        0x00000002
304#define DSCAPS_PRIMARY8BIT          0x00000004
305#define DSCAPS_PRIMARY16BIT         0x00000008
306#define DSCAPS_CONTINUOUSRATE       0x00000010
307#define DSCAPS_EMULDRIVER           0x00000020
308#define DSCAPS_CERTIFIED            0x00000040
309#define DSCAPS_SECONDARYMONO        0x00000100
310#define DSCAPS_SECONDARYSTEREO      0x00000200
311#define DSCAPS_SECONDARY8BIT        0x00000400
312#define DSCAPS_SECONDARY16BIT       0x00000800
313
314
315
316#define DSBPLAY_LOOPING         0x00000001
317
318
319
320#define DSBSTATUS_PLAYING           0x00000001
321#define DSBSTATUS_BUFFERLOST        0x00000002
322#define DSBSTATUS_LOOPING           0x00000004
323
324
325#define DSBLOCK_FROMWRITECURSOR         0x00000001
326
327
328
329#define DSSCL_NORMAL                1
330#define DSSCL_PRIORITY              2
331#define DSSCL_EXCLUSIVE             3
332#define DSSCL_WRITEPRIMARY          4
333
334
335
336#define DSBCAPS_PRIMARYBUFFER       0x00000001
337#define DSBCAPS_STATIC              0x00000002
338#define DSBCAPS_LOCHARDWARE         0x00000004
339#define DSBCAPS_LOCSOFTWARE         0x00000008
340#define DSBCAPS_CTRLFREQUENCY       0x00000020
341#define DSBCAPS_CTRLPAN             0x00000040
342#define DSBCAPS_CTRLVOLUME          0x00000080
343#define DSBCAPS_CTRLDEFAULT         0x000000E0  // Pan + volume + frequency.
344#define DSBCAPS_CTRLALL             0x000000E0  // All control capabilities
345#define DSBCAPS_STICKYFOCUS         0x00004000
346#define DSBCAPS_GETCURRENTPOSITION2 0x00010000  // More accurate play cursor under emulation
347
348
349
350
351#define DSSPEAKER_HEADPHONE     1
352#define DSSPEAKER_MONO          2
353#define DSSPEAKER_QUAD          3
354#define DSSPEAKER_STEREO        4
355#define DSSPEAKER_SURROUND      5
356
357
358
359
360
361
362#ifdef __cplusplus
363};
364#endif
365
366#endif  /* __DSOUND_INCLUDED__ */
367