CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

DSOUND.H (13798B)


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