home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / borland / cb / setup / cbuilder / data.z / DSOUND.H < prev    next >
C/C++ Source or Header  |  1997-02-28  |  13KB  |  371 lines

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