2
* Interface for dynamically loading directsound and providing a dummy
3
* implementation if it isn't present.
5
* Author: Ross Bencina (some portions Phil Burk & Robert Marsanyi)
7
* For PortAudio Portable Real-Time Audio Library
8
* For more information see: http://www.portaudio.com
9
* Copyright (c) 1999-2006 Phil Burk, Robert Marsanyi and Ross Bencina
11
* Permission is hereby granted, free of charge, to any person obtaining
12
* a copy of this software and associated documentation files
13
* (the "Software"), to deal in the Software without restriction,
14
* including without limitation the rights to use, copy, modify, merge,
15
* publish, distribute, sublicense, and/or sell copies of the Software,
16
* and to permit persons to whom the Software is furnished to do so,
17
* subject to the following conditions:
19
* The above copyright notice and this permission notice shall be
20
* included in all copies or substantial portions of the Software.
22
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
26
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32
* The text above constitutes the entire PortAudio license; however,
33
* the PortAudio community also makes the following non-binding requests:
35
* Any person wishing to distribute modifications to the Software is
36
* requested to send the modifications to the original developer so that
37
* they can be incorporated into the canonical version. It is also
38
* requested that these non-binding requests be included along with the
47
#include "pa_win_ds_dynlink.h"
49
PaWinDsDSoundEntryPoints paWinDsDSoundEntryPoints = { 0, 0, 0, 0, 0, 0, 0 };
52
static HRESULT WINAPI DummyDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
54
(void)rclsid; /* unused parameter */
55
(void)riid; /* unused parameter */
56
(void)ppv; /* unused parameter */
57
return CLASS_E_CLASSNOTAVAILABLE;
60
static HRESULT WINAPI DummyDirectSoundCreate(LPGUID lpcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter)
62
(void)lpcGuidDevice; /* unused parameter */
63
(void)ppDS; /* unused parameter */
64
(void)pUnkOuter; /* unused parameter */
68
static HRESULT WINAPI DummyDirectSoundEnumerateW(LPDSENUMCALLBACKW lpDSEnumCallback, LPVOID lpContext)
70
(void)lpDSEnumCallback; /* unused parameter */
71
(void)lpContext; /* unused parameter */
75
static HRESULT WINAPI DummyDirectSoundEnumerateA(LPDSENUMCALLBACKA lpDSEnumCallback, LPVOID lpContext)
77
(void)lpDSEnumCallback; /* unused parameter */
78
(void)lpContext; /* unused parameter */
82
static HRESULT WINAPI DummyDirectSoundCaptureCreate(LPGUID lpcGUID, LPDIRECTSOUNDCAPTURE *lplpDSC, LPUNKNOWN pUnkOuter)
84
(void)lpcGUID; /* unused parameter */
85
(void)lplpDSC; /* unused parameter */
86
(void)pUnkOuter; /* unused parameter */
90
static HRESULT WINAPI DummyDirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW lpDSCEnumCallback, LPVOID lpContext)
92
(void)lpDSCEnumCallback; /* unused parameter */
93
(void)lpContext; /* unused parameter */
97
static HRESULT WINAPI DummyDirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA lpDSCEnumCallback, LPVOID lpContext)
99
(void)lpDSCEnumCallback; /* unused parameter */
100
(void)lpContext; /* unused parameter */
105
void PaWinDs_InitializeDSoundEntryPoints(void)
107
paWinDsDSoundEntryPoints.hInstance_ = LoadLibrary("dsound.dll");
108
if( paWinDsDSoundEntryPoints.hInstance_ != NULL )
110
paWinDsDSoundEntryPoints.DllGetClassObject =
111
(HRESULT (WINAPI *)(REFCLSID, REFIID , LPVOID *))
112
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DllGetClassObject" );
113
if( paWinDsDSoundEntryPoints.DllGetClassObject == NULL )
114
paWinDsDSoundEntryPoints.DllGetClassObject = DummyDllGetClassObject;
116
paWinDsDSoundEntryPoints.DirectSoundCreate =
117
(HRESULT (WINAPI *)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN))
118
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCreate" );
119
if( paWinDsDSoundEntryPoints.DirectSoundCreate == NULL )
120
paWinDsDSoundEntryPoints.DirectSoundCreate = DummyDirectSoundCreate;
122
paWinDsDSoundEntryPoints.DirectSoundEnumerateW =
123
(HRESULT (WINAPI *)(LPDSENUMCALLBACKW, LPVOID))
124
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundEnumerateW" );
125
if( paWinDsDSoundEntryPoints.DirectSoundEnumerateW == NULL )
126
paWinDsDSoundEntryPoints.DirectSoundEnumerateW = DummyDirectSoundEnumerateW;
128
paWinDsDSoundEntryPoints.DirectSoundEnumerateA =
129
(HRESULT (WINAPI *)(LPDSENUMCALLBACKA, LPVOID))
130
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundEnumerateA" );
131
if( paWinDsDSoundEntryPoints.DirectSoundEnumerateA == NULL )
132
paWinDsDSoundEntryPoints.DirectSoundEnumerateA = DummyDirectSoundEnumerateA;
134
paWinDsDSoundEntryPoints.DirectSoundCaptureCreate =
135
(HRESULT (WINAPI *)(LPGUID, LPDIRECTSOUNDCAPTURE *, LPUNKNOWN))
136
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCaptureCreate" );
137
if( paWinDsDSoundEntryPoints.DirectSoundCaptureCreate == NULL )
138
paWinDsDSoundEntryPoints.DirectSoundCaptureCreate = DummyDirectSoundCaptureCreate;
140
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW =
141
(HRESULT (WINAPI *)(LPDSENUMCALLBACKW, LPVOID))
142
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCaptureEnumerateW" );
143
if( paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW == NULL )
144
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW = DummyDirectSoundCaptureEnumerateW;
146
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA =
147
(HRESULT (WINAPI *)(LPDSENUMCALLBACKA, LPVOID))
148
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCaptureEnumerateA" );
149
if( paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA == NULL )
150
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA = DummyDirectSoundCaptureEnumerateA;
154
/* initialize with dummy entry points to make live easy when ds isn't present */
155
paWinDsDSoundEntryPoints.DirectSoundCreate = DummyDirectSoundCreate;
156
paWinDsDSoundEntryPoints.DirectSoundEnumerateW = DummyDirectSoundEnumerateW;
157
paWinDsDSoundEntryPoints.DirectSoundEnumerateA = DummyDirectSoundEnumerateA;
158
paWinDsDSoundEntryPoints.DirectSoundCaptureCreate = DummyDirectSoundCaptureCreate;
159
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW = DummyDirectSoundCaptureEnumerateW;
160
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA = DummyDirectSoundCaptureEnumerateA;
165
void PaWinDs_TerminateDSoundEntryPoints(void)
167
if( paWinDsDSoundEntryPoints.hInstance_ != NULL )
169
/* ensure that we crash reliably if the entry points arent initialised */
170
paWinDsDSoundEntryPoints.DirectSoundCreate = 0;
171
paWinDsDSoundEntryPoints.DirectSoundEnumerateW = 0;
172
paWinDsDSoundEntryPoints.DirectSoundEnumerateA = 0;
173
paWinDsDSoundEntryPoints.DirectSoundCaptureCreate = 0;
174
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW = 0;
175
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA = 0;
177
FreeLibrary( paWinDsDSoundEntryPoints.hInstance_ );
178
paWinDsDSoundEntryPoints.hInstance_ = NULL;
b'\\ No newline at end of file'