| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
#include "pa_win_ds_dynlink.h" |
| 48 |
#include "pa_debugprint.h" |
| 49 |
|
| 50 |
PaWinDsDSoundEntryPoints paWinDsDSoundEntryPoints = { 0, 0, 0, 0, 0, 0, 0 }; |
| 51 |
|
| 52 |
|
| 53 |
static HRESULT WINAPI DummyDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) |
| 54 |
{ |
| 55 |
(void)rclsid; |
| 56 |
(void)riid; |
| 57 |
(void)ppv; |
| 58 |
return CLASS_E_CLASSNOTAVAILABLE; |
| 59 |
} |
| 60 |
|
| 61 |
static HRESULT WINAPI DummyDirectSoundCreate(LPGUID lpcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter) |
| 62 |
{ |
| 63 |
(void)lpcGuidDevice; |
| 64 |
(void)ppDS; |
| 65 |
(void)pUnkOuter; |
| 66 |
return E_NOTIMPL; |
| 67 |
} |
| 68 |
|
| 69 |
static HRESULT WINAPI DummyDirectSoundEnumerateW(LPDSENUMCALLBACKW lpDSEnumCallback, LPVOID lpContext) |
| 70 |
{ |
| 71 |
(void)lpDSEnumCallback; |
| 72 |
(void)lpContext; |
| 73 |
return E_NOTIMPL; |
| 74 |
} |
| 75 |
|
| 76 |
static HRESULT WINAPI DummyDirectSoundEnumerateA(LPDSENUMCALLBACKA lpDSEnumCallback, LPVOID lpContext) |
| 77 |
{ |
| 78 |
(void)lpDSEnumCallback; |
| 79 |
(void)lpContext; |
| 80 |
return E_NOTIMPL; |
| 81 |
} |
| 82 |
|
| 83 |
static HRESULT WINAPI DummyDirectSoundCaptureCreate(LPGUID lpcGUID, LPDIRECTSOUNDCAPTURE *lplpDSC, LPUNKNOWN pUnkOuter) |
| 84 |
{ |
| 85 |
(void)lpcGUID; |
| 86 |
(void)lplpDSC; |
| 87 |
(void)pUnkOuter; |
| 88 |
return E_NOTIMPL; |
| 89 |
} |
| 90 |
|
| 91 |
static HRESULT WINAPI DummyDirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW lpDSCEnumCallback, LPVOID lpContext) |
| 92 |
{ |
| 93 |
(void)lpDSCEnumCallback; |
| 94 |
(void)lpContext; |
| 95 |
return E_NOTIMPL; |
| 96 |
} |
| 97 |
|
| 98 |
static HRESULT WINAPI DummyDirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA lpDSCEnumCallback, LPVOID lpContext) |
| 99 |
{ |
| 100 |
(void)lpDSCEnumCallback; |
| 101 |
(void)lpContext; |
| 102 |
return E_NOTIMPL; |
| 103 |
} |
| 104 |
|
| 105 |
#ifdef PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE |
| 106 |
static HRESULT WINAPI DummyDirectSoundFullDuplexCreate8( |
| 107 |
LPCGUID pcGuidCaptureDevice, |
| 108 |
LPCGUID pcGuidRenderDevice, |
| 109 |
LPCDSCBUFFERDESC pcDSCBufferDesc, |
| 110 |
LPCDSBUFFERDESC pcDSBufferDesc, |
| 111 |
HWND hWnd, |
| 112 |
DWORD dwLevel, |
| 113 |
LPDIRECTSOUNDFULLDUPLEX * ppDSFD, |
| 114 |
LPDIRECTSOUNDCAPTUREBUFFER8 * ppDSCBuffer8, |
| 115 |
LPDIRECTSOUNDBUFFER8 * ppDSBuffer8, |
| 116 |
LPUNKNOWN pUnkOuter) |
| 117 |
{ |
| 118 |
(void)pcGuidCaptureDevice; |
| 119 |
(void)pcGuidRenderDevice; |
| 120 |
(void)pcDSCBufferDesc; |
| 121 |
(void)pcDSBufferDesc; |
| 122 |
(void)hWnd; |
| 123 |
(void)dwLevel; |
| 124 |
(void)ppDSFD; |
| 125 |
(void)ppDSCBuffer8; |
| 126 |
(void)ppDSBuffer8; |
| 127 |
(void)pUnkOuter; |
| 128 |
|
| 129 |
return E_NOTIMPL; |
| 130 |
} |
| 131 |
#endif |
| 132 |
|
| 133 |
void PaWinDs_InitializeDSoundEntryPoints(void) |
| 134 |
{ |
| 135 |
paWinDsDSoundEntryPoints.hInstance_ = LoadLibraryA("dsound.dll"); |
| 136 |
if( paWinDsDSoundEntryPoints.hInstance_ != NULL ) |
| 137 |
{ |
| 138 |
paWinDsDSoundEntryPoints.DllGetClassObject = |
| 139 |
(HRESULT (WINAPI *)(REFCLSID, REFIID , LPVOID *)) |
| 140 |
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DllGetClassObject" ); |
| 141 |
if( paWinDsDSoundEntryPoints.DllGetClassObject == NULL ) |
| 142 |
paWinDsDSoundEntryPoints.DllGetClassObject = DummyDllGetClassObject; |
| 143 |
|
| 144 |
paWinDsDSoundEntryPoints.DirectSoundCreate = |
| 145 |
(HRESULT (WINAPI *)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN)) |
| 146 |
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCreate" ); |
| 147 |
if( paWinDsDSoundEntryPoints.DirectSoundCreate == NULL ) |
| 148 |
paWinDsDSoundEntryPoints.DirectSoundCreate = DummyDirectSoundCreate; |
| 149 |
|
| 150 |
paWinDsDSoundEntryPoints.DirectSoundEnumerateW = |
| 151 |
(HRESULT (WINAPI *)(LPDSENUMCALLBACKW, LPVOID)) |
| 152 |
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundEnumerateW" ); |
| 153 |
if( paWinDsDSoundEntryPoints.DirectSoundEnumerateW == NULL ) |
| 154 |
paWinDsDSoundEntryPoints.DirectSoundEnumerateW = DummyDirectSoundEnumerateW; |
| 155 |
|
| 156 |
paWinDsDSoundEntryPoints.DirectSoundEnumerateA = |
| 157 |
(HRESULT (WINAPI *)(LPDSENUMCALLBACKA, LPVOID)) |
| 158 |
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundEnumerateA" ); |
| 159 |
if( paWinDsDSoundEntryPoints.DirectSoundEnumerateA == NULL ) |
| 160 |
paWinDsDSoundEntryPoints.DirectSoundEnumerateA = DummyDirectSoundEnumerateA; |
| 161 |
|
| 162 |
paWinDsDSoundEntryPoints.DirectSoundCaptureCreate = |
| 163 |
(HRESULT (WINAPI *)(LPGUID, LPDIRECTSOUNDCAPTURE *, LPUNKNOWN)) |
| 164 |
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCaptureCreate" ); |
| 165 |
if( paWinDsDSoundEntryPoints.DirectSoundCaptureCreate == NULL ) |
| 166 |
paWinDsDSoundEntryPoints.DirectSoundCaptureCreate = DummyDirectSoundCaptureCreate; |
| 167 |
|
| 168 |
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW = |
| 169 |
(HRESULT (WINAPI *)(LPDSENUMCALLBACKW, LPVOID)) |
| 170 |
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCaptureEnumerateW" ); |
| 171 |
if( paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW == NULL ) |
| 172 |
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW = DummyDirectSoundCaptureEnumerateW; |
| 173 |
|
| 174 |
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA = |
| 175 |
(HRESULT (WINAPI *)(LPDSENUMCALLBACKA, LPVOID)) |
| 176 |
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCaptureEnumerateA" ); |
| 177 |
if( paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA == NULL ) |
| 178 |
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA = DummyDirectSoundCaptureEnumerateA; |
| 179 |
|
| 180 |
#ifdef PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE |
| 181 |
paWinDsDSoundEntryPoints.DirectSoundFullDuplexCreate8 = |
| 182 |
(HRESULT (WINAPI *)(LPCGUID, LPCGUID, LPCDSCBUFFERDESC, LPCDSBUFFERDESC, |
| 183 |
HWND, DWORD, LPDIRECTSOUNDFULLDUPLEX *, LPDIRECTSOUNDCAPTUREBUFFER8 *, |
| 184 |
LPDIRECTSOUNDBUFFER8 *, LPUNKNOWN)) |
| 185 |
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundFullDuplexCreate" ); |
| 186 |
if( paWinDsDSoundEntryPoints.DirectSoundFullDuplexCreate8 == NULL ) |
| 187 |
paWinDsDSoundEntryPoints.DirectSoundFullDuplexCreate8 = DummyDirectSoundFullDuplexCreate8; |
| 188 |
#endif |
| 189 |
} |
| 190 |
else |
| 191 |
{ |
| 192 |
DWORD errorCode = GetLastError(); |
| 193 |
PA_DEBUG(("Couldn't load dsound.dll error code: %d \n",errorCode)); |
| 194 |
|
| 195 |
|
| 196 |
paWinDsDSoundEntryPoints.DirectSoundCreate = DummyDirectSoundCreate; |
| 197 |
paWinDsDSoundEntryPoints.DirectSoundEnumerateW = DummyDirectSoundEnumerateW; |
| 198 |
paWinDsDSoundEntryPoints.DirectSoundEnumerateA = DummyDirectSoundEnumerateA; |
| 199 |
paWinDsDSoundEntryPoints.DirectSoundCaptureCreate = DummyDirectSoundCaptureCreate; |
| 200 |
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW = DummyDirectSoundCaptureEnumerateW; |
| 201 |
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA = DummyDirectSoundCaptureEnumerateA; |
| 202 |
#ifdef PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE |
| 203 |
paWinDsDSoundEntryPoints.DirectSoundFullDuplexCreate8 = DummyDirectSoundFullDuplexCreate8; |
| 204 |
#endif |
| 205 |
} |
| 206 |
} |
| 207 |
|
| 208 |
|
| 209 |
void PaWinDs_TerminateDSoundEntryPoints(void) |
| 210 |
{ |
| 211 |
if( paWinDsDSoundEntryPoints.hInstance_ != NULL ) |
| 212 |
{ |
| 213 |
|
| 214 |
paWinDsDSoundEntryPoints.DirectSoundCreate = 0; |
| 215 |
paWinDsDSoundEntryPoints.DirectSoundEnumerateW = 0; |
| 216 |
paWinDsDSoundEntryPoints.DirectSoundEnumerateA = 0; |
| 217 |
paWinDsDSoundEntryPoints.DirectSoundCaptureCreate = 0; |
| 218 |
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW = 0; |
| 219 |
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA = 0; |
| 220 |
|
| 221 |
FreeLibrary( paWinDsDSoundEntryPoints.hInstance_ ); |
| 222 |
paWinDsDSoundEntryPoints.hInstance_ = NULL; |
| 223 |
} |
| 224 |
} |