dsound.h 13 KB

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