1 // Copyright © 2015, Peter Atashian 2 // Licensed under the MIT License <LICENSE.md> 3 //! DSound procedure declarations, constant definitions and macros 4 STRUCT!{struct DSCAPS { 5 dwSize: ::DWORD, 6 dwFlags: ::DWORD, 7 dwMinSecondarySampleRate: ::DWORD, 8 dwMaxSecondarySampleRate: ::DWORD, 9 dwPrimaryBuffers: ::DWORD, 10 dwMaxHwMixingAllBuffers: ::DWORD, 11 dwMaxHwMixingStaticBuffers: ::DWORD, 12 dwMaxHwMixingStreamingBuffers: ::DWORD, 13 dwFreeHwMixingAllBuffers: ::DWORD, 14 dwFreeHwMixingStaticBuffers: ::DWORD, 15 dwFreeHwMixingStreamingBuffers: ::DWORD, 16 dwMaxHw3DAllBuffers: ::DWORD, 17 dwMaxHw3DStaticBuffers: ::DWORD, 18 dwMaxHw3DStreamingBuffers: ::DWORD, 19 dwFreeHw3DAllBuffers: ::DWORD, 20 dwFreeHw3DStaticBuffers: ::DWORD, 21 dwFreeHw3DStreamingBuffers: ::DWORD, 22 dwTotalHwMemBytes: ::DWORD, 23 dwFreeHwMemBytes: ::DWORD, 24 dwMaxContigFreeHwMemBytes: ::DWORD, 25 dwUnlockTransferRateHwBuffers: ::DWORD, 26 dwPlayCpuOverheadSwBuffers: ::DWORD, 27 dwReserved1: ::DWORD, 28 dwReserved2: ::DWORD, 29 }} 30 pub type LPDSCAPS = *mut DSCAPS; 31 STRUCT!{struct DSBCAPS { 32 dwSize: ::DWORD, 33 dwFlags: ::DWORD, 34 dwBufferBytes: ::DWORD, 35 dwUnlockTransferRate: ::DWORD, 36 dwPlayCpuOverhead: ::DWORD, 37 }} 38 pub type LPDSBCAPS = *mut DSBCAPS; 39 STRUCT!{struct DSBUFFERDESC { 40 dwSize: ::DWORD, 41 dwFlags: ::DWORD, 42 dwBufferBytes: ::DWORD, 43 dwReserved: ::DWORD, 44 lpwfxFormat: ::LPWAVEFORMATEX, 45 guid3DAlgorithm: ::GUID, 46 }} 47 pub type LPCDSBUFFERDESC = *const DSBUFFERDESC; 48 RIDL!( 49 interface IDirectSoundBuffer(IDirectSoundBufferVtbl): IUnknown(IUnknownVtbl) { 50 fn GetCaps(&mut self, pDSBufferCaps: ::LPDSBCAPS) -> ::HRESULT, 51 fn GetCurrentPosition( 52 &mut self, pdwCurrentPlayCursor: ::LPDWORD, pdwCurrentWriteCursor: ::LPDWORD 53 ) -> ::HRESULT, 54 fn GetFormat( 55 &mut self, pwfxFormat: ::LPWAVEFORMATEX, dwSizeAllocated: ::DWORD, 56 pdwSizeWritten: ::LPDWORD 57 ) -> ::HRESULT, 58 fn GetVolume(&mut self, plVolume: ::LPLONG) -> ::HRESULT, 59 fn GetPan(&mut self, plPan: ::LPLONG) -> ::HRESULT, 60 fn GetFrequency(&mut self, pdwFrequency: ::LPDWORD) -> ::HRESULT, 61 fn GetStatus(&mut self, pdwStatus: ::LPDWORD) -> ::HRESULT, 62 fn Initialize( 63 &mut self, pDirectSound: ::LPDIRECTSOUND, pcDSBufferDesc: ::LPCDSBUFFERDESC 64 ) -> ::HRESULT, 65 fn Lock( 66 &mut self, dwOffset: ::DWORD, dwBytes: ::DWORD, ppvAudioPtr1: *mut ::LPVOID, 67 pdwAudioBytes1: ::LPDWORD, ppvAudioPtr2: *mut ::LPVOID, pdwAudioBytes2: ::LPDWORD, 68 dwFlags: ::DWORD 69 ) -> ::HRESULT, 70 fn Play(&mut self, dwReserved1: ::DWORD, dwPriority: ::DWORD, dwFlags: ::DWORD) -> ::HRESULT, 71 fn SetCurrentPosition(&mut self, dwNewPosition: ::DWORD) -> ::HRESULT, 72 fn SetFormat(&mut self, pcfxFormat: ::LPCWAVEFORMATEX) -> ::HRESULT, 73 fn SetVolume(&mut self, lVolume: ::LONG) -> ::HRESULT, 74 fn SetPan(&mut self, lPan: ::LONG) -> ::HRESULT, 75 fn SetFrequency(&mut self, dwFrequency: ::DWORD) -> ::HRESULT, 76 fn Stop(&mut self) -> ::HRESULT, 77 fn Unlock( 78 &mut self, pvAudioPtr1: ::LPVOID, dwAudioBytes1: ::DWORD, pvAudioPtr2: ::LPVOID, 79 dwAudioBytes2: ::DWORD 80 ) -> ::HRESULT, 81 fn Restore(&mut self) -> ::HRESULT 82 } 83 ); 84 pub type LPDIRECTSOUNDBUFFER = *mut IDirectSoundBuffer; 85 RIDL!( 86 interface IDirectSound(IDirectSoundVtbl): IUnknown(IUnknownVtbl) 87 { 88 fn CreateSoundBuffer( 89 &mut self, pcDSBufferDesc: ::LPCDSBUFFERDESC, ppDSBuffer: *mut ::LPDIRECTSOUNDBUFFER, 90 pUnkOuter: ::LPUNKNOWN 91 ) -> ::HRESULT, 92 fn GetCaps(&mut self, pDSCaps: ::LPDSCAPS) -> ::HRESULT, 93 fn DuplicateSoundBuffer( 94 &mut self, pDSBufferOriginal: LPDIRECTSOUNDBUFFER, 95 ppDSBufferDuplicate: *mut ::LPDIRECTSOUNDBUFFER 96 ) -> ::HRESULT, 97 fn SetCooperativeLevel(&mut self, hWnd: ::HWND, dwLevel: ::DWORD) -> ::HRESULT, 98 fn Compact(&mut self) -> ::HRESULT, 99 fn GetSpeakerConfig(&mut self, pdwSpeakerConfig: ::LPDWORD) -> ::HRESULT, 100 fn SetSpeakerConfig(&mut self, dwSpeakerConfig: ::DWORD) -> ::HRESULT, 101 fn Initialize(&mut self, pcGuidDevice: ::LPCGUID) -> ::HRESULT 102 } 103 ); 104 pub type LPDIRECTSOUND = *mut IDirectSound; 105 pub const DS_OK: ::HRESULT = ::S_OK; 106 pub const DSERR_GENERIC: ::HRESULT = ::E_FAIL; 107 pub const DSSCL_NORMAL: ::DWORD = 0x00000001; 108 pub const DSSCL_PRIORITY: ::DWORD = 0x00000002; 109 pub const DSSCL_EXCLUSIVE: ::DWORD = 0x00000003; 110 pub const DSSCL_WRITEPRIMARY: ::DWORD = 0x00000004; 111 pub const DSBCAPS_PRIMARYBUFFER: ::DWORD = 0x00000001; 112 pub const DSBCAPS_STATIC: ::DWORD = 0x00000002; 113 pub const DSBCAPS_LOCHARDWARE: ::DWORD = 0x00000004; 114 pub const DSBCAPS_LOCSOFTWARE: ::DWORD = 0x00000008; 115 pub const DSBCAPS_CTRL3D: ::DWORD = 0x00000010; 116 pub const DSBCAPS_CTRLFREQUENCY: ::DWORD = 0x00000020; 117 pub const DSBCAPS_CTRLPAN: ::DWORD = 0x00000040; 118 pub const DSBCAPS_CTRLVOLUME: ::DWORD = 0x00000080; 119 pub const DSBCAPS_CTRLPOSITIONNOTIFY: ::DWORD = 0x00000100; 120 pub const DSBCAPS_CTRLFX: ::DWORD = 0x00000200; 121 pub const DSBCAPS_STICKYFOCUS: ::DWORD = 0x00004000; 122 pub const DSBCAPS_GLOBALFOCUS: ::DWORD = 0x00008000; 123 pub const DSBCAPS_GETCURRENTPOSITION2: ::DWORD = 0x00010000; 124 pub const DSBCAPS_MUTE3DATMAXDISTANCE: ::DWORD = 0x00020000; 125 pub const DSBCAPS_LOCDEFER: ::DWORD = 0x00040000; 126 pub const DSBCAPS_TRUEPLAYPOSITION: ::DWORD = 0x00080000; 127 pub const DSBPLAY_LOOPING: ::DWORD = 0x00000001; 128 pub const DSBPLAY_LOCHARDWARE: ::DWORD = 0x00000002; 129 pub const DSBPLAY_LOCSOFTWARE: ::DWORD = 0x00000004; 130 pub const DSBPLAY_TERMINATEBY_TIME: ::DWORD = 0x00000008; 131 pub const DSBPLAY_TERMINATEBY_DISTANCE: ::DWORD = 0x000000010; 132 pub const DSBPLAY_TERMINATEBY_PRIORITY: ::DWORD = 0x000000020; 133