2 * Copyright 2009 Maarten Lankhorst
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef __WINE_CONFIG_H
20 # error You must include config.h to use this header
23 extern HRESULT MMDevEnum_Create(REFIID riid, void **ppv);
24 extern void MMDevEnum_Free(void);
26 extern HRESULT MMDevice_GetPropValue(const GUID *devguid, DWORD flow, REFPROPERTYKEY key, PROPVARIANT *pv);
27 extern HRESULT MMDevice_SetPropValue(const GUID *devguid, DWORD flow, REFPROPERTYKEY key, REFPROPVARIANT pv);
29 typedef struct MMDevice {
30 const IMMDeviceVtbl *lpVtbl;
31 const IMMEndpointVtbl *lpEndpointVtbl;
34 CRITICAL_SECTION crst;
43 extern HRESULT AudioClient_Create(MMDevice *parent, IAudioClient **ppv);
44 extern HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolume **ppv);
50 /* All openal functions */
51 extern int openal_loaded;
52 #ifdef SONAME_LIBOPENAL
53 extern LPALCCREATECONTEXT palcCreateContext;
54 extern LPALCMAKECONTEXTCURRENT palcMakeContextCurrent;
55 extern LPALCPROCESSCONTEXT palcProcessContext;
56 extern LPALCSUSPENDCONTEXT palcSuspendContext;
57 extern LPALCDESTROYCONTEXT palcDestroyContext;
58 extern LPALCGETCURRENTCONTEXT palcGetCurrentContext;
59 extern LPALCGETCONTEXTSDEVICE palcGetContextsDevice;
60 extern LPALCOPENDEVICE palcOpenDevice;
61 extern LPALCCLOSEDEVICE palcCloseDevice;
62 extern LPALCGETERROR palcGetError;
63 extern LPALCISEXTENSIONPRESENT palcIsExtensionPresent;
64 extern LPALCGETPROCADDRESS palcGetProcAddress;
65 extern LPALCGETENUMVALUE palcGetEnumValue;
66 extern LPALCGETSTRING palcGetString;
67 extern LPALCGETINTEGERV palcGetIntegerv;
68 extern LPALCCAPTUREOPENDEVICE palcCaptureOpenDevice;
69 extern LPALCCAPTURECLOSEDEVICE palcCaptureCloseDevice;
70 extern LPALCCAPTURESTART palcCaptureStart;
71 extern LPALCCAPTURESTOP palcCaptureStop;
72 extern LPALCCAPTURESAMPLES palcCaptureSamples;
73 extern LPALENABLE palEnable;
74 extern LPALDISABLE palDisable;
75 extern LPALISENABLED palIsEnabled;
76 extern LPALGETSTRING palGetString;
77 extern LPALGETBOOLEANV palGetBooleanv;
78 extern LPALGETINTEGERV palGetIntegerv;
79 extern LPALGETFLOATV palGetFloatv;
80 extern LPALGETDOUBLEV palGetDoublev;
81 extern LPALGETBOOLEAN palGetBoolean;
82 extern LPALGETINTEGER palGetInteger;
83 extern LPALGETFLOAT palGetFloat;
84 extern LPALGETDOUBLE palGetDouble;
85 extern LPALGETERROR palGetError;
86 extern LPALISEXTENSIONPRESENT palIsExtensionPresent;
87 extern LPALGETPROCADDRESS palGetProcAddress;
88 extern LPALGETENUMVALUE palGetEnumValue;
89 extern LPALLISTENERF palListenerf;
90 extern LPALLISTENER3F palListener3f;
91 extern LPALLISTENERFV palListenerfv;
92 extern LPALLISTENERI palListeneri;
93 extern LPALLISTENER3I palListener3i;
94 extern LPALLISTENERIV palListeneriv;
95 extern LPALGETLISTENERF palGetListenerf;
96 extern LPALGETLISTENER3F palGetListener3f;
97 extern LPALGETLISTENERFV palGetListenerfv;
98 extern LPALGETLISTENERI palGetListeneri;
99 extern LPALGETLISTENER3I palGetListener3i;
100 extern LPALGETLISTENERIV palGetListeneriv;
101 extern LPALGENSOURCES palGenSources;
102 extern LPALDELETESOURCES palDeleteSources;
103 extern LPALISSOURCE palIsSource;
104 extern LPALSOURCEF palSourcef;
105 extern LPALSOURCE3F palSource3f;
106 extern LPALSOURCEFV palSourcefv;
107 extern LPALSOURCEI palSourcei;
108 extern LPALSOURCE3I palSource3i;
109 extern LPALSOURCEIV palSourceiv;
110 extern LPALGETSOURCEF palGetSourcef;
111 extern LPALGETSOURCE3F palGetSource3f;
112 extern LPALGETSOURCEFV palGetSourcefv;
113 extern LPALGETSOURCEI palGetSourcei;
114 extern LPALGETSOURCE3I palGetSource3i;
115 extern LPALGETSOURCEIV palGetSourceiv;
116 extern LPALSOURCEPLAYV palSourcePlayv;
117 extern LPALSOURCESTOPV palSourceStopv;
118 extern LPALSOURCEREWINDV palSourceRewindv;
119 extern LPALSOURCEPAUSEV palSourcePausev;
120 extern LPALSOURCEPLAY palSourcePlay;
121 extern LPALSOURCESTOP palSourceStop;
122 extern LPALSOURCEREWIND palSourceRewind;
123 extern LPALSOURCEPAUSE palSourcePause;
124 extern LPALSOURCEQUEUEBUFFERS palSourceQueueBuffers;
125 extern LPALSOURCEUNQUEUEBUFFERS palSourceUnqueueBuffers;
126 extern LPALGENBUFFERS palGenBuffers;
127 extern LPALDELETEBUFFERS palDeleteBuffers;
128 extern LPALISBUFFER palIsBuffer;
129 extern LPALBUFFERF palBufferf;
130 extern LPALBUFFER3F palBuffer3f;
131 extern LPALBUFFERFV palBufferfv;
132 extern LPALBUFFERI palBufferi;
133 extern LPALBUFFER3I palBuffer3i;
134 extern LPALBUFFERIV palBufferiv;
135 extern LPALGETBUFFERF palGetBufferf;
136 extern LPALGETBUFFER3F palGetBuffer3f;
137 extern LPALGETBUFFERFV palGetBufferfv;
138 extern LPALGETBUFFERI palGetBufferi;
139 extern LPALGETBUFFER3I palGetBuffer3i;
140 extern LPALGETBUFFERIV palGetBufferiv;
141 extern LPALBUFFERDATA palBufferData;
142 extern LPALDOPPLERFACTOR palDopplerFactor;
143 extern LPALDOPPLERVELOCITY palDopplerVelocity;
144 extern LPALDISTANCEMODEL palDistanceModel;
145 extern LPALSPEEDOFSOUND palSpeedOfSound;
147 #define palcCreateContext alcCreateContext
148 #define palcMakeContextCurrent alcMakeContextCurrent
149 #define palcProcessContext alcProcessContext
150 #define palcSuspendContext alcSuspendContext
151 #define palcDestroyContext alcDestroyContext
152 #define palcGetCurrentContext alcGetCurrentContext
153 #define palcGetContextsDevice alcGetContextsDevice
154 #define palcOpenDevice alcOpenDevice
155 #define palcCloseDevice alcCloseDevice
156 #define palcGetError alcGetError
157 #define palcIsExtensionPresent alcIsExtensionPresent
158 #define palcGetProcAddress alcGetProcAddress
159 #define palcGetEnumValue alcGetEnumValue
160 #define palcGetString alcGetString
161 #define palcGetIntegerv alcGetIntegerv
162 #define palcCaptureOpenDevice alcCaptureOpenDevice
163 #define palcCaptureCloseDevice alcCaptureCloseDevice
164 #define palcCaptureStart alcCaptureStart
165 #define palcCaptureStop alcCaptureStop
166 #define palcCaptureSamples alcCaptureSamples
167 #define palEnable alEnable
168 #define palDisable alDisable
169 #define palIsEnabled alIsEnabled
170 #define palGetString alGetString
171 #define palGetBooleanv alGetBooleanv
172 #define palGetIntegerv alGetIntegerv
173 #define palGetFloatv alGetFloatv
174 #define palGetDoublev alGetDoublev
175 #define palGetBoolean alGetBoolean
176 #define palGetInteger alGetInteger
177 #define palGetFloat alGetFloat
178 #define palGetDouble alGetDouble
179 #define palGetError alGetError
180 #define palIsExtensionPresent alIsExtensionPresent
181 #define palGetProcAddress alGetProcAddress
182 #define palGetEnumValue alGetEnumValue
183 #define palListenerf alListenerf
184 #define palListener3f alListener3f
185 #define palListenerfv alListenerfv
186 #define palListeneri alListeneri
187 #define palListener3i alListener3i
188 #define palListeneriv alListeneriv
189 #define palGetListenerf alGetListenerf
190 #define palGetListener3f alGetListener3f
191 #define palGetListenerfv alGetListenerfv
192 #define palGetListeneri alGetListeneri
193 #define palGetListener3i alGetListener3i
194 #define palGetListeneriv alGetListeneriv
195 #define palGenSources alGenSources
196 #define palDeleteSources alDeleteSources
197 #define palIsSource alIsSource
198 #define palSourcef alSourcef
199 #define palSource3f alSource3f
200 #define palSourcefv alSourcefv
201 #define palSourcei alSourcei
202 #define palSource3i alSource3i
203 #define palSourceiv alSourceiv
204 #define palGetSourcef alGetSourcef
205 #define palGetSource3f alGetSource3f
206 #define palGetSourcefv alGetSourcefv
207 #define palGetSourcei alGetSourcei
208 #define palGetSource3i alGetSource3i
209 #define palGetSourceiv alGetSourceiv
210 #define palSourcePlayv alSourcePlayv
211 #define palSourceStopv alSourceStopv
212 #define palSourceRewindv alSourceRewindv
213 #define palSourcePausev alSourcePausev
214 #define palSourcePlay alSourcePlay
215 #define palSourceStop alSourceStop
216 #define palSourceRewind alSourceRewind
217 #define palSourcePause alSourcePause
218 #define palSourceQueueBuffers alSourceQueueBuffers
219 #define palSourceUnqueueBuffers alSourceUnqueueBuffers
220 #define palGenBuffers alGenBuffers
221 #define palDeleteBuffers alDeleteBuffers
222 #define palIsBuffer alIsBuffer
223 #define palBufferf alBufferf
224 #define palBuffer3f alBuffer3f
225 #define palBufferfv alBufferfv
226 #define palBufferi alBufferi
227 #define palBuffer3i alBuffer3i
228 #define palBufferiv alBufferiv
229 #define palGetBufferf alGetBufferf
230 #define palGetBuffer3f alGetBuffer3f
231 #define palGetBufferfv alGetBufferfv
232 #define palGetBufferi alGetBufferi
233 #define palGetBuffer3i alGetBuffer3i
234 #define palGetBufferiv alGetBufferiv
235 #define palBufferData alBufferData
236 #define palDopplerFactor alDopplerFactor
237 #define palDopplerVelocity alDopplerVelocity
238 #define palDistanceModel alDistanceModel
239 #define palSpeedOfSound alSpeedOfSound
242 /* OpenAL only allows for 1 single access to the device at the same time */
243 extern CRITICAL_SECTION openal_crst;
244 extern int local_contexts;
245 extern typeof(alcGetCurrentContext) *get_context;
246 extern typeof(alcMakeContextCurrent) *set_context;
248 #define getALError() \
250 ALenum err = palGetError(); \
251 if(err != AL_NO_ERROR) \
253 ERR(">>>>>>>>>>>> Received AL error %#x on context %p, %s:%u\n", err, get_context(), __FUNCTION__, __LINE__); \
257 #define getALCError(dev) \
259 ALenum err = palcGetError(dev); \
260 if(err != ALC_NO_ERROR) \
262 ERR(">>>>>>>>>>>> Received ALC error %#x on device %p, %s:%u\n", err, dev, __FUNCTION__, __LINE__); \
266 #define setALContext(actx) \
268 ALCcontext *__old_ctx, *cur_ctx = actx ; \
269 if (!local_contexts) EnterCriticalSection(&openal_crst); \
270 __old_ctx = get_context(); \
271 if (__old_ctx != cur_ctx && set_context(cur_ctx) == ALC_FALSE) {\
272 ERR("Couldn't set current context!!\n"); \
273 getALCError(palcGetContextsDevice(cur_ctx)); \
276 /* Only restore a NULL context if using global contexts, for TLS contexts always restore */
277 #define popALContext() \
278 if (__old_ctx != cur_ctx \
279 && (local_contexts || __old_ctx) \
280 && set_context(__old_ctx) == ALC_FALSE) { \
281 ERR("Couldn't restore old context!!\n"); \
282 getALCError(palcGetContextsDevice(__old_ctx)); \
284 if (!local_contexts) LeaveCriticalSection(&openal_crst); \