Remove some unnecessary locks
[dsound-openal.git] / dsound_private.h
blob4e58d8cb32504d4f6155c85cade122d13f5009a9
1 /* DirectSound
3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998 Rob Riggs
5 * Copyright 2000-2001 TransGaming Technologies, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 /* Linux does not support better timing than 10ms */
23 #define DS_TIME_RES 2 /* Resolution of multimedia timer */
24 #define DS_TIME_DEL 10 /* Delay of multimedia timer callback, and duration of HEL fragment */
25 /* Default refresh count, can be overridden */
26 #define FAKE_REFRESH_COUNT (1000/DS_TIME_DEL/2)
29 #ifdef __WINESRC__
31 #ifdef __APPLE__
32 #include <OpenAL/al.h>
33 #include <OpenAL/alc.h>
34 #else
35 #include <AL/al.h>
36 #include <AL/alc.h>
37 #endif
39 #define LONGFMT
40 #else
42 #include <al.h>
43 #include <alc.h>
45 #include <stdio.h>
47 extern int LogLevel;
49 #ifdef DEBUG_INFO
50 #define TRACE(fmt,args...) do { \
51 if(LogLevel >= 3) \
52 fprintf(stderr, "%04x:trace:dsound:%s " fmt, (UINT)GetCurrentThreadId(), __FUNCTION__, ##args); \
53 } while(0)
54 #define WARN(fmt,args...) do { \
55 if(LogLevel >= 2) \
56 fprintf(stderr, "%04x:warn:dsound:%s " fmt, (UINT)GetCurrentThreadId(), __FUNCTION__, ##args); \
57 } while(0)
58 #define FIXME(fmt,args...) do { \
59 if(LogLevel >= 1) \
60 fprintf(stderr, "%04x:fixme:dsound:%s " fmt, (UINT)GetCurrentThreadId(), __FUNCTION__, ##args); \
61 } while(0)
62 #define ERR(fmt,args...) do { \
63 if(LogLevel >= 0) \
64 fprintf(stderr, "%04x:err:dsound:%s " fmt, (UINT)GetCurrentThreadId(), __FUNCTION__, ##args); \
65 } while(0)
66 #else
67 #define TRACE(args...)
68 #define WARN(args...)
69 #define FIXME(args...)
70 #define ERR(args...)
71 #endif
73 const char *wine_dbg_sprintf( const char *format, ... );
74 const char *wine_dbgstr_wn( const WCHAR *str, int n );
75 const char *debugstr_guid( const GUID *id );
77 static inline const char *debugstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
79 #define LONGFMT "l"
80 #endif
83 #include "alext.h"
84 #include "eax.h"
86 /* Set to 1 to build a DLL that can be used in an app that uses OpenAL itself.
87 * Thread-local contexts are needed for true concurrency, however. Disallowing
88 * concurrency can avoid a save and restore of the context. */
89 #define ALLOW_CONCURRENT_AL 0
91 /* All openal functions */
92 extern int openal_loaded;
93 #ifdef SONAME_LIBOPENAL
94 extern LPALCCREATECONTEXT palcCreateContext;
95 extern LPALCMAKECONTEXTCURRENT palcMakeContextCurrent;
96 extern LPALCPROCESSCONTEXT palcProcessContext;
97 extern LPALCSUSPENDCONTEXT palcSuspendContext;
98 extern LPALCDESTROYCONTEXT palcDestroyContext;
99 extern LPALCGETCURRENTCONTEXT palcGetCurrentContext;
100 extern LPALCGETCONTEXTSDEVICE palcGetContextsDevice;
101 extern LPALCOPENDEVICE palcOpenDevice;
102 extern LPALCCLOSEDEVICE palcCloseDevice;
103 extern LPALCGETERROR palcGetError;
104 extern LPALCISEXTENSIONPRESENT palcIsExtensionPresent;
105 extern LPALCGETPROCADDRESS palcGetProcAddress;
106 extern LPALCGETENUMVALUE palcGetEnumValue;
107 extern LPALCGETSTRING palcGetString;
108 extern LPALCGETINTEGERV palcGetIntegerv;
109 extern LPALCCAPTUREOPENDEVICE palcCaptureOpenDevice;
110 extern LPALCCAPTURECLOSEDEVICE palcCaptureCloseDevice;
111 extern LPALCCAPTURESTART palcCaptureStart;
112 extern LPALCCAPTURESTOP palcCaptureStop;
113 extern LPALCCAPTURESAMPLES palcCaptureSamples;
114 extern LPALENABLE palEnable;
115 extern LPALDISABLE palDisable;
116 extern LPALISENABLED palIsEnabled;
117 extern LPALGETSTRING palGetString;
118 extern LPALGETBOOLEANV palGetBooleanv;
119 extern LPALGETINTEGERV palGetIntegerv;
120 extern LPALGETFLOATV palGetFloatv;
121 extern LPALGETDOUBLEV palGetDoublev;
122 extern LPALGETBOOLEAN palGetBoolean;
123 extern LPALGETINTEGER palGetInteger;
124 extern LPALGETFLOAT palGetFloat;
125 extern LPALGETDOUBLE palGetDouble;
126 extern LPALGETERROR palGetError;
127 extern LPALISEXTENSIONPRESENT palIsExtensionPresent;
128 extern LPALGETPROCADDRESS palGetProcAddress;
129 extern LPALGETENUMVALUE palGetEnumValue;
130 extern LPALLISTENERF palListenerf;
131 extern LPALLISTENER3F palListener3f;
132 extern LPALLISTENERFV palListenerfv;
133 extern LPALLISTENERI palListeneri;
134 extern LPALLISTENER3I palListener3i;
135 extern LPALLISTENERIV palListeneriv;
136 extern LPALGETLISTENERF palGetListenerf;
137 extern LPALGETLISTENER3F palGetListener3f;
138 extern LPALGETLISTENERFV palGetListenerfv;
139 extern LPALGETLISTENERI palGetListeneri;
140 extern LPALGETLISTENER3I palGetListener3i;
141 extern LPALGETLISTENERIV palGetListeneriv;
142 extern LPALGENSOURCES palGenSources;
143 extern LPALDELETESOURCES palDeleteSources;
144 extern LPALISSOURCE palIsSource;
145 extern LPALSOURCEF palSourcef;
146 extern LPALSOURCE3F palSource3f;
147 extern LPALSOURCEFV palSourcefv;
148 extern LPALSOURCEI palSourcei;
149 extern LPALSOURCE3I palSource3i;
150 extern LPALSOURCEIV palSourceiv;
151 extern LPALGETSOURCEF palGetSourcef;
152 extern LPALGETSOURCE3F palGetSource3f;
153 extern LPALGETSOURCEFV palGetSourcefv;
154 extern LPALGETSOURCEI palGetSourcei;
155 extern LPALGETSOURCE3I palGetSource3i;
156 extern LPALGETSOURCEIV palGetSourceiv;
157 extern LPALSOURCEPLAYV palSourcePlayv;
158 extern LPALSOURCESTOPV palSourceStopv;
159 extern LPALSOURCEREWINDV palSourceRewindv;
160 extern LPALSOURCEPAUSEV palSourcePausev;
161 extern LPALSOURCEPLAY palSourcePlay;
162 extern LPALSOURCESTOP palSourceStop;
163 extern LPALSOURCEREWIND palSourceRewind;
164 extern LPALSOURCEPAUSE palSourcePause;
165 extern LPALSOURCEQUEUEBUFFERS palSourceQueueBuffers;
166 extern LPALSOURCEUNQUEUEBUFFERS palSourceUnqueueBuffers;
167 extern LPALGENBUFFERS palGenBuffers;
168 extern LPALDELETEBUFFERS palDeleteBuffers;
169 extern LPALISBUFFER palIsBuffer;
170 extern LPALBUFFERF palBufferf;
171 extern LPALBUFFER3F palBuffer3f;
172 extern LPALBUFFERFV palBufferfv;
173 extern LPALBUFFERI palBufferi;
174 extern LPALBUFFER3I palBuffer3i;
175 extern LPALBUFFERIV palBufferiv;
176 extern LPALGETBUFFERF palGetBufferf;
177 extern LPALGETBUFFER3F palGetBuffer3f;
178 extern LPALGETBUFFERFV palGetBufferfv;
179 extern LPALGETBUFFERI palGetBufferi;
180 extern LPALGETBUFFER3I palGetBuffer3i;
181 extern LPALGETBUFFERIV palGetBufferiv;
182 extern LPALBUFFERDATA palBufferData;
183 extern LPALDOPPLERFACTOR palDopplerFactor;
184 extern LPALDOPPLERVELOCITY palDopplerVelocity;
185 extern LPALDISTANCEMODEL palDistanceModel;
186 extern LPALSPEEDOFSOUND palSpeedOfSound;
188 #define alcCreateContext palcCreateContext
189 #define alcMakeContextCurrent palcMakeContextCurrent
190 #define alcProcessContext palcProcessContext
191 #define alcSuspendContext palcSuspendContext
192 #define alcDestroyContext palcDestroyContext
193 #define alcGetCurrentContext palcGetCurrentContext
194 #define alcGetContextsDevice palcGetContextsDevice
195 #define alcOpenDevice palcOpenDevice
196 #define alcCloseDevice palcCloseDevice
197 #define alcGetError palcGetError
198 #define alcIsExtensionPresent palcIsExtensionPresent
199 #define alcGetProcAddress palcGetProcAddress
200 #define alcGetEnumValue palcGetEnumValue
201 #define alcGetString palcGetString
202 #define alcGetIntegerv palcGetIntegerv
203 #define alcCaptureOpenDevice palcCaptureOpenDevice
204 #define alcCaptureCloseDevice palcCaptureCloseDevice
205 #define alcCaptureStart palcCaptureStart
206 #define alcCaptureStop palcCaptureStop
207 #define alcCaptureSamples palcCaptureSamples
208 #define alEnable palEnable
209 #define alDisable palDisable
210 #define alIsEnabled palIsEnabled
211 #define alGetString palGetString
212 #define alGetBooleanv palGetBooleanv
213 #define alGetIntegerv palGetIntegerv
214 #define alGetFloatv palGetFloatv
215 #define alGetDoublev palGetDoublev
216 #define alGetBoolean palGetBoolean
217 #define alGetInteger palGetInteger
218 #define alGetFloat palGetFloat
219 #define alGetDouble palGetDouble
220 #define alGetError palGetError
221 #define alIsExtensionPresent palIsExtensionPresent
222 #define alGetProcAddress palGetProcAddress
223 #define alGetEnumValue palGetEnumValue
224 #define alListenerf palListenerf
225 #define alListener3f palListener3f
226 #define alListenerfv palListenerfv
227 #define alListeneri palListeneri
228 #define alListener3i palListener3i
229 #define alListeneriv palListeneriv
230 #define alGetListenerf palGetListenerf
231 #define alGetListener3f palGetListener3f
232 #define alGetListenerfv palGetListenerfv
233 #define alGetListeneri palGetListeneri
234 #define alGetListener3i palGetListener3i
235 #define alGetListeneriv palGetListeneriv
236 #define alGenSources palGenSources
237 #define alDeleteSources palDeleteSources
238 #define alIsSource palIsSource
239 #define alSourcef palSourcef
240 #define alSource3f palSource3f
241 #define alSourcefv palSourcefv
242 #define alSourcei palSourcei
243 #define alSource3i palSource3i
244 #define alSourceiv palSourceiv
245 #define alGetSourcef palGetSourcef
246 #define alGetSource3f palGetSource3f
247 #define alGetSourcefv palGetSourcefv
248 #define alGetSourcei palGetSourcei
249 #define alGetSource3i palGetSource3i
250 #define alGetSourceiv palGetSourceiv
251 #define alSourcePlayv palSourcePlayv
252 #define alSourceStopv palSourceStopv
253 #define alSourceRewindv palSourceRewindv
254 #define alSourcePausev palSourcePausev
255 #define alSourcePlay palSourcePlay
256 #define alSourceStop palSourceStop
257 #define alSourceRewind palSourceRewind
258 #define alSourcePause palSourcePause
259 #define alSourceQueueBuffers palSourceQueueBuffers
260 #define alSourceUnqueueBuffers palSourceUnqueueBuffers
261 #define alGenBuffers palGenBuffers
262 #define alDeleteBuffers palDeleteBuffers
263 #define alIsBuffer palIsBuffer
264 #define alBufferf palBufferf
265 #define alBuffer3f palBuffer3f
266 #define alBufferfv palBufferfv
267 #define alBufferi palBufferi
268 #define alBuffer3i palBuffer3i
269 #define alBufferiv palBufferiv
270 #define alGetBufferf palGetBufferf
271 #define alGetBuffer3f palGetBuffer3f
272 #define alGetBufferfv palGetBufferfv
273 #define alGetBufferi palGetBufferi
274 #define alGetBuffer3i palGetBuffer3i
275 #define alGetBufferiv palGetBufferiv
276 #define alBufferData palBufferData
277 #define alDopplerFactor palDopplerFactor
278 #define alDopplerVelocity palDopplerVelocity
279 #define alDistanceModel palDistanceModel
280 #define alSpeedOfSound palSpeedOfSound
281 #endif
283 #include <math.h>
284 #include "wingdi.h"
285 #include "mmreg.h"
287 /* OpenAL only allows for 1 single access to the device at the same time */
288 extern CRITICAL_SECTION openal_crst;
290 extern const ALCchar *DSOUND_getdevicestrings(void);
291 extern const ALCchar *DSOUND_getcapturedevicestrings(void);
293 extern LPALCMAKECONTEXTCURRENT set_context;
294 extern LPALCGETCURRENTCONTEXT get_context;
295 extern BOOL local_contexts;
298 typedef struct DS8Impl DS8Impl;
299 typedef struct DS8Primary DS8Primary;
300 typedef struct DS8Buffer DS8Buffer;
303 /* Sample types */
304 #define AL_BYTE 0x1400
305 #define AL_UNSIGNED_BYTE 0x1401
306 #define AL_SHORT 0x1402
307 #define AL_UNSIGNED_SHORT 0x1403
308 #define AL_INT 0x1404
309 #define AL_UNSIGNED_INT 0x1405
310 #define AL_FLOAT 0x1406
311 #define AL_DOUBLE 0x1407
312 #define AL_BYTE3 0x1408
313 #define AL_UNSIGNED_BYTE3 0x1409
314 #define AL_MULAW 0x1410
315 #define AL_IMA4 0x1411
317 /* Channel configurations */
318 #define AL_MONO 0x1500
319 #define AL_STEREO 0x1501
320 #define AL_REAR 0x1502
321 #define AL_QUAD 0x1503
322 #define AL_5POINT1 0x1504 /* (WFX order) */
323 #define AL_6POINT1 0x1505 /* (WFX order) */
324 #define AL_7POINT1 0x1506 /* (WFX order) */
326 /* Storage formats */
327 #define AL_MONO8 0x1100
328 #define AL_MONO16 0x1101
329 #define AL_MONO32F 0x10010
330 #define AL_STEREO8 0x1102
331 #define AL_STEREO16 0x1103
332 #define AL_STEREO32F 0x10011
333 #define AL_QUAD8 0x1204
334 #define AL_QUAD16 0x1205
335 #define AL_QUAD32F 0x1206
336 #define AL_REAR8 0x1207
337 #define AL_REAR16 0x1208
338 #define AL_REAR32F 0x1209
339 #define AL_5POINT1_8 0x120A
340 #define AL_5POINT1_16 0x120B
341 #define AL_5POINT1_32F 0x120C
342 #define AL_6POINT1_8 0x120D
343 #define AL_6POINT1_16 0x120E
344 #define AL_6POINT1_32F 0x120F
345 #define AL_7POINT1_8 0x1210
346 #define AL_7POINT1_16 0x1211
347 #define AL_7POINT1_32F 0x1212
349 enum {
350 EXT_EFX,
351 EXT_FLOAT32,
352 EXT_MCFORMATS,
353 EXT_STATIC_BUFFER,
354 SOFT_BUFFER_SAMPLES,
355 SOFT_BUFFER_SUB_DATA,
356 SOFT_DEFERRED_UPDATES,
358 MAX_EXTENSIONS
361 typedef struct ExtALFuncs {
362 PFNALBUFFERSUBDATASOFTPROC BufferSubData;
363 PFNALBUFFERDATASTATICPROC BufferDataStatic;
365 LPALGENEFFECTS GenEffects;
366 LPALDELETEEFFECTS DeleteEffects;
367 LPALEFFECTI Effecti;
368 LPALEFFECTF Effectf;
370 LPALGENAUXILIARYEFFECTSLOTS GenAuxiliaryEffectSlots;
371 LPALDELETEAUXILIARYEFFECTSLOTS DeleteAuxiliaryEffectSlots;
372 LPALAUXILIARYEFFECTSLOTI AuxiliaryEffectSloti;
374 void (AL_APIENTRY*BufferSamplesSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*);
375 void (AL_APIENTRY*BufferSubSamplesSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*);
376 void (AL_APIENTRY*GetBufferSamplesSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,ALvoid*);
377 ALboolean (AL_APIENTRY*IsBufferFormatSupportedSOFT)(ALenum);
379 void (AL_APIENTRY*DeferUpdatesSOFT)(void);
380 void (AL_APIENTRY*ProcessUpdatesSOFT)(void);
381 } ExtALFuncs;
383 #define MAX_SOURCES 256
384 typedef struct DeviceShare {
385 LONG ref;
387 ALCdevice *device;
388 ALCcontext *ctx;
390 ALboolean SupportedExt[MAX_EXTENSIONS];
392 ExtALFuncs ExtAL;
394 CRITICAL_SECTION crst;
396 ALuint sources[MAX_SOURCES];
397 DWORD nsources, max_sources;
399 ALuint auxslot;
401 GUID guid;
402 } DeviceShare;
405 struct DS8Primary {
406 IDirectSoundBuffer IDirectSoundBuffer_iface;
407 IDirectSound3DListener IDirectSound3DListener_iface;
408 IKsPropertySet IKsPropertySet_iface;
410 LONG ref, ds3d_ref, prop_ref;
411 IDirectSoundBuffer8 *write_emu;
412 DS8Impl *parent;
414 /* Taken from the share */
415 ALCcontext *ctx;
416 const ALboolean *SupportedExt;
417 const ExtALFuncs *ExtAL;
418 CRITICAL_SECTION *crst;
419 ALuint *sources;
420 ALuint auxslot;
422 DWORD buf_size;
423 BOOL stopped;
424 DWORD flags;
425 WAVEFORMATEXTENSIBLE format;
427 UINT timer_id;
428 DWORD timer_res;
429 HANDLE thread_hdl;
430 DWORD thread_id;
432 DS8Buffer **buffers;
433 DWORD nbuffers, sizebuffers;
434 DS8Buffer **notifies;
435 DWORD nnotifies, sizenotifies;
437 ALuint effect;
438 ALfloat rollofffactor;
440 union {
441 struct {
442 BOOL pos : 1;
443 BOOL vel : 1;
444 BOOL orientation : 1;
445 BOOL distancefactor : 1;
446 BOOL rollofffactor : 1;
447 BOOL dopplerfactor : 1;
448 BOOL effect : 1;
449 } bit;
450 int flags;
451 } dirty;
452 DS3DLISTENER listen;
454 EAXLISTENERPROPERTIES eax_prop;
456 void (AL_APIENTRY*DeferUpdates)(void);
457 void (AL_APIENTRY*ProcessUpdates)(void);
461 /* Device implementation */
462 struct DS8Impl {
463 IDirectSound8 IDirectSound8_iface;
464 IDirectSound IDirectSound_iface;
466 LONG ref;
467 BOOL is_8;
469 DeviceShare *share;
471 /* Taken from the share */
472 ALCdevice *device;
474 DS8Primary primary;
476 DWORD speaker_config;
477 DWORD prio_level;
481 typedef struct DS8Data {
482 LONG ref;
484 /* Lock was called and unlock isn't? */
485 LONG locked;
487 WAVEFORMATEXTENSIBLE format;
489 ALuint buf_size;
490 ALenum buf_format;
491 ALenum in_type, in_chans;
492 DWORD dsbflags;
493 BYTE *data;
494 ALuint *buffers;
495 ALuint numsegs;
496 ALuint segsize;
497 ALuint lastsegsize;
498 } DS8Data;
499 /* Amount of buffers that have to be queued when
500 * bufferdatastatic and buffersubdata are not available */
501 #define QBUFFERS 3
503 struct DS8Buffer {
504 IDirectSoundBuffer8 IDirectSoundBuffer8_iface;
505 IDirectSoundBuffer IDirectSoundBuffer_iface;
506 IDirectSound3DBuffer IDirectSound3DBuffer_iface;
507 IDirectSoundNotify IDirectSoundNotify_iface;
508 IKsPropertySet IKsPropertySet_iface;
510 LONG ref, ds3d_ref, not_ref, prop_ref;
511 LONG all_ref;
513 DS8Primary *primary;
515 /* From the primary */
516 ALCcontext *ctx;
517 const ExtALFuncs *ExtAL;
518 CRITICAL_SECTION *crst;
520 DS8Data *buffer;
521 ALuint source;
522 ALuint curidx;
523 BOOL isplaying, islooping, bufferlost;
524 DWORD ds3dmode;
526 DS3DBUFFER ds3dbuffer;
527 union {
528 struct {
529 BOOL pos : 1;
530 BOOL vel : 1;
531 BOOL cone_angles : 1;
532 BOOL cone_orient : 1;
533 BOOL cone_outsidevolume : 1;
534 BOOL min_distance : 1;
535 BOOL max_distance : 1;
536 BOOL mode : 1;
537 } bit;
538 int flags;
539 } dirty;
541 DWORD nnotify, lastpos;
542 DSBPOSITIONNOTIFY *notify;
545 extern HRESULT DS8Primary_PreInit(DS8Primary *prim, DS8Impl *parent);
546 extern void DS8Primary_Clear(DS8Primary *prim);
548 extern HRESULT DS8Buffer_Create(DS8Buffer **ppv, DS8Primary *parent, IDirectSoundBuffer *orig);
549 extern void DS8Buffer_Destroy(DS8Buffer *buf);
551 static inline ALdouble gain_to_mB(ALdouble gain)
553 return log10(gain) * 2000.0;
555 static inline ALdouble mB_to_gain(ALdouble millibels)
557 return pow(10.0, millibels/2000.0);
560 static inline LONG clampI(LONG val, LONG minval, LONG maxval)
562 if(val >= maxval) return maxval;
563 if(val <= minval) return minval;
564 return val;
566 static inline ULONG clampU(ULONG val, ULONG minval, ULONG maxval)
568 if(val >= maxval) return maxval;
569 if(val <= minval) return minval;
570 return val;
572 static inline FLOAT clampF(FLOAT val, FLOAT minval, FLOAT maxval)
574 if(val >= maxval) return maxval;
575 if(val <= minval) return minval;
576 return val;
580 #define checkALError() do { \
581 ALenum err = alGetError(); \
582 if(err != AL_NO_ERROR) \
583 ERR(">>>>>>>>>>>> Received AL error %#x on context %p, %s:%u\n", \
584 err, get_context(), __FUNCTION__, __LINE__); \
585 } while (0)
587 #define checkALCError(dev) do { \
588 ALenum err = alcGetError(dev); \
589 if(err != ALC_NO_ERROR) \
590 ERR(">>>>>>>>>>>> Received ALC error %#x on device %p, %s:%u\n", \
591 err, dev, __FUNCTION__, __LINE__); \
592 } while(0)
594 #if ALLOW_CONCURRENT_AL
596 #define setALContext(actx) do { \
597 ALCcontext *__old_ctx, *cur_ctx = actx; \
598 if(!local_contexts) EnterCriticalSection(&openal_crst); \
599 __old_ctx = get_context(); \
600 if(__old_ctx != cur_ctx && set_context(cur_ctx) == ALC_FALSE) { \
601 ERR("Couldn't set current context!!\n"); \
602 checkALCError(alcGetContextsDevice(cur_ctx)); \
604 /* Only restore a NULL context if using global contexts, for TLS contexts always restore */
605 #define popALContext() \
606 if(__old_ctx != cur_ctx && (local_contexts || __old_ctx) && \
607 set_context(__old_ctx) == ALC_FALSE) { \
608 ERR("Couldn't restore old context!!\n"); \
609 checkALCError(alcGetContextsDevice(__old_ctx)); \
611 if (!local_contexts) LeaveCriticalSection(&openal_crst); \
612 } while(0)
614 #else
616 #define setALContext(actx) do { \
617 ALCcontext *cur_ctx = actx; \
618 if(!local_contexts) EnterCriticalSection(&openal_crst); \
619 if(set_context(cur_ctx) == ALC_FALSE) { \
620 ERR("Couldn't set current context!!\n"); \
621 checkALCError(alcGetContextsDevice(cur_ctx)); \
623 #define popALContext() \
624 if (!local_contexts) LeaveCriticalSection(&openal_crst); \
625 } while (0)
627 #endif
629 HRESULT DSOUND_Create(REFIID riid, void **ppDS);
630 HRESULT DSOUND_Create8(REFIID riid, void **ppDS);
631 HRESULT DSOUND_FullDuplexCreate(REFIID riid, void **ppDSFD);
632 HRESULT IKsPrivatePropertySetImpl_Create(REFIID riid, void **piks);
633 HRESULT DSOUND_CaptureCreate(REFIID riid, void **ppDSC);
634 HRESULT DSOUND_CaptureCreate8(REFIID riid, void **ppDSC);
636 extern const GUID DSOUND_renderer_guid;
637 extern const GUID DSOUND_capture_guid;