Add an IDirectSound interface
[dsound-openal.git] / dsound_private.h
blob9f6ba81f2a6a9f1aa1037b7d3de26549ffd64b77
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 #else
41 #include <al.h>
42 #include <alc.h>
44 #include <stdio.h>
46 extern int LogLevel;
48 #ifdef DEBUG_INFO
49 #define TRACE(fmt,args...) do { \
50 if(LogLevel >= 3) \
51 fprintf(stderr, "%04x:trace:dsound:%s " fmt, (UINT)GetCurrentThreadId(), __FUNCTION__, ##args); \
52 } while(0)
53 #define WARN(fmt,args...) do { \
54 if(LogLevel >= 2) \
55 fprintf(stderr, "%04x:warn:dsound:%s " fmt, (UINT)GetCurrentThreadId(), __FUNCTION__, ##args); \
56 } while(0)
57 #define FIXME(fmt,args...) do { \
58 if(LogLevel >= 1) \
59 fprintf(stderr, "%04x:fixme:dsound:%s " fmt, (UINT)GetCurrentThreadId(), __FUNCTION__, ##args); \
60 } while(0)
61 #define ERR(fmt,args...) do { \
62 if(LogLevel >= 0) \
63 fprintf(stderr, "%04x:err:dsound:%s " fmt, (UINT)GetCurrentThreadId(), __FUNCTION__, ##args); \
64 } while(0)
65 #else
66 #define TRACE(args...)
67 #define WARN(args...)
68 #define FIXME(args...)
69 #define ERR(args...)
70 #endif
72 const char *wine_dbg_sprintf( const char *format, ... );
73 const char *wine_dbgstr_wn( const WCHAR *str, int n );
75 static inline const char *debugstr_guid( const GUID *id )
77 if (!id) return "(null)";
78 if (!((ULONG_PTR)id >> 16)) return wine_dbg_sprintf( "<guid-0x%04hx>", (WORD)(ULONG_PTR)id );
79 return wine_dbg_sprintf( "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
80 id->Data1, id->Data2, id->Data3,
81 id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
82 id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] );
85 static inline const char *debugstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
87 #endif
90 #include "alext.h"
91 #include "eax.h"
93 /* Set to 1 to build a DLL that can be used in an app that uses OpenAL itself.
94 * Thread-local contexts are needed for true concurrency, however. Disallowing
95 * concurrency can avoid a save and restore of the context. */
96 #define ALLOW_CONCURRENT_AL 0
98 /* All openal functions */
99 extern int openal_loaded;
100 #ifdef SONAME_LIBOPENAL
101 extern LPALCCREATECONTEXT palcCreateContext;
102 extern LPALCMAKECONTEXTCURRENT palcMakeContextCurrent;
103 extern LPALCPROCESSCONTEXT palcProcessContext;
104 extern LPALCSUSPENDCONTEXT palcSuspendContext;
105 extern LPALCDESTROYCONTEXT palcDestroyContext;
106 extern LPALCGETCURRENTCONTEXT palcGetCurrentContext;
107 extern LPALCGETCONTEXTSDEVICE palcGetContextsDevice;
108 extern LPALCOPENDEVICE palcOpenDevice;
109 extern LPALCCLOSEDEVICE palcCloseDevice;
110 extern LPALCGETERROR palcGetError;
111 extern LPALCISEXTENSIONPRESENT palcIsExtensionPresent;
112 extern LPALCGETPROCADDRESS palcGetProcAddress;
113 extern LPALCGETENUMVALUE palcGetEnumValue;
114 extern LPALCGETSTRING palcGetString;
115 extern LPALCGETINTEGERV palcGetIntegerv;
116 extern LPALCCAPTUREOPENDEVICE palcCaptureOpenDevice;
117 extern LPALCCAPTURECLOSEDEVICE palcCaptureCloseDevice;
118 extern LPALCCAPTURESTART palcCaptureStart;
119 extern LPALCCAPTURESTOP palcCaptureStop;
120 extern LPALCCAPTURESAMPLES palcCaptureSamples;
121 extern LPALENABLE palEnable;
122 extern LPALDISABLE palDisable;
123 extern LPALISENABLED palIsEnabled;
124 extern LPALGETSTRING palGetString;
125 extern LPALGETBOOLEANV palGetBooleanv;
126 extern LPALGETINTEGERV palGetIntegerv;
127 extern LPALGETFLOATV palGetFloatv;
128 extern LPALGETDOUBLEV palGetDoublev;
129 extern LPALGETBOOLEAN palGetBoolean;
130 extern LPALGETINTEGER palGetInteger;
131 extern LPALGETFLOAT palGetFloat;
132 extern LPALGETDOUBLE palGetDouble;
133 extern LPALGETERROR palGetError;
134 extern LPALISEXTENSIONPRESENT palIsExtensionPresent;
135 extern LPALGETPROCADDRESS palGetProcAddress;
136 extern LPALGETENUMVALUE palGetEnumValue;
137 extern LPALLISTENERF palListenerf;
138 extern LPALLISTENER3F palListener3f;
139 extern LPALLISTENERFV palListenerfv;
140 extern LPALLISTENERI palListeneri;
141 extern LPALLISTENER3I palListener3i;
142 extern LPALLISTENERIV palListeneriv;
143 extern LPALGETLISTENERF palGetListenerf;
144 extern LPALGETLISTENER3F palGetListener3f;
145 extern LPALGETLISTENERFV palGetListenerfv;
146 extern LPALGETLISTENERI palGetListeneri;
147 extern LPALGETLISTENER3I palGetListener3i;
148 extern LPALGETLISTENERIV palGetListeneriv;
149 extern LPALGENSOURCES palGenSources;
150 extern LPALDELETESOURCES palDeleteSources;
151 extern LPALISSOURCE palIsSource;
152 extern LPALSOURCEF palSourcef;
153 extern LPALSOURCE3F palSource3f;
154 extern LPALSOURCEFV palSourcefv;
155 extern LPALSOURCEI palSourcei;
156 extern LPALSOURCE3I palSource3i;
157 extern LPALSOURCEIV palSourceiv;
158 extern LPALGETSOURCEF palGetSourcef;
159 extern LPALGETSOURCE3F palGetSource3f;
160 extern LPALGETSOURCEFV palGetSourcefv;
161 extern LPALGETSOURCEI palGetSourcei;
162 extern LPALGETSOURCE3I palGetSource3i;
163 extern LPALGETSOURCEIV palGetSourceiv;
164 extern LPALSOURCEPLAYV palSourcePlayv;
165 extern LPALSOURCESTOPV palSourceStopv;
166 extern LPALSOURCEREWINDV palSourceRewindv;
167 extern LPALSOURCEPAUSEV palSourcePausev;
168 extern LPALSOURCEPLAY palSourcePlay;
169 extern LPALSOURCESTOP palSourceStop;
170 extern LPALSOURCEREWIND palSourceRewind;
171 extern LPALSOURCEPAUSE palSourcePause;
172 extern LPALSOURCEQUEUEBUFFERS palSourceQueueBuffers;
173 extern LPALSOURCEUNQUEUEBUFFERS palSourceUnqueueBuffers;
174 extern LPALGENBUFFERS palGenBuffers;
175 extern LPALDELETEBUFFERS palDeleteBuffers;
176 extern LPALISBUFFER palIsBuffer;
177 extern LPALBUFFERF palBufferf;
178 extern LPALBUFFER3F palBuffer3f;
179 extern LPALBUFFERFV palBufferfv;
180 extern LPALBUFFERI palBufferi;
181 extern LPALBUFFER3I palBuffer3i;
182 extern LPALBUFFERIV palBufferiv;
183 extern LPALGETBUFFERF palGetBufferf;
184 extern LPALGETBUFFER3F palGetBuffer3f;
185 extern LPALGETBUFFERFV palGetBufferfv;
186 extern LPALGETBUFFERI palGetBufferi;
187 extern LPALGETBUFFER3I palGetBuffer3i;
188 extern LPALGETBUFFERIV palGetBufferiv;
189 extern LPALBUFFERDATA palBufferData;
190 extern LPALDOPPLERFACTOR palDopplerFactor;
191 extern LPALDOPPLERVELOCITY palDopplerVelocity;
192 extern LPALDISTANCEMODEL palDistanceModel;
193 extern LPALSPEEDOFSOUND palSpeedOfSound;
195 #define alcCreateContext palcCreateContext
196 #define alcMakeContextCurrent palcMakeContextCurrent
197 #define alcProcessContext palcProcessContext
198 #define alcSuspendContext palcSuspendContext
199 #define alcDestroyContext palcDestroyContext
200 #define alcGetCurrentContext palcGetCurrentContext
201 #define alcGetContextsDevice palcGetContextsDevice
202 #define alcOpenDevice palcOpenDevice
203 #define alcCloseDevice palcCloseDevice
204 #define alcGetError palcGetError
205 #define alcIsExtensionPresent palcIsExtensionPresent
206 #define alcGetProcAddress palcGetProcAddress
207 #define alcGetEnumValue palcGetEnumValue
208 #define alcGetString palcGetString
209 #define alcGetIntegerv palcGetIntegerv
210 #define alcCaptureOpenDevice palcCaptureOpenDevice
211 #define alcCaptureCloseDevice palcCaptureCloseDevice
212 #define alcCaptureStart palcCaptureStart
213 #define alcCaptureStop palcCaptureStop
214 #define alcCaptureSamples palcCaptureSamples
215 #define alEnable palEnable
216 #define alDisable palDisable
217 #define alIsEnabled palIsEnabled
218 #define alGetString palGetString
219 #define alGetBooleanv palGetBooleanv
220 #define alGetIntegerv palGetIntegerv
221 #define alGetFloatv palGetFloatv
222 #define alGetDoublev palGetDoublev
223 #define alGetBoolean palGetBoolean
224 #define alGetInteger palGetInteger
225 #define alGetFloat palGetFloat
226 #define alGetDouble palGetDouble
227 #define alGetError palGetError
228 #define alIsExtensionPresent palIsExtensionPresent
229 #define alGetProcAddress palGetProcAddress
230 #define alGetEnumValue palGetEnumValue
231 #define alListenerf palListenerf
232 #define alListener3f palListener3f
233 #define alListenerfv palListenerfv
234 #define alListeneri palListeneri
235 #define alListener3i palListener3i
236 #define alListeneriv palListeneriv
237 #define alGetListenerf palGetListenerf
238 #define alGetListener3f palGetListener3f
239 #define alGetListenerfv palGetListenerfv
240 #define alGetListeneri palGetListeneri
241 #define alGetListener3i palGetListener3i
242 #define alGetListeneriv palGetListeneriv
243 #define alGenSources palGenSources
244 #define alDeleteSources palDeleteSources
245 #define alIsSource palIsSource
246 #define alSourcef palSourcef
247 #define alSource3f palSource3f
248 #define alSourcefv palSourcefv
249 #define alSourcei palSourcei
250 #define alSource3i palSource3i
251 #define alSourceiv palSourceiv
252 #define alGetSourcef palGetSourcef
253 #define alGetSource3f palGetSource3f
254 #define alGetSourcefv palGetSourcefv
255 #define alGetSourcei palGetSourcei
256 #define alGetSource3i palGetSource3i
257 #define alGetSourceiv palGetSourceiv
258 #define alSourcePlayv palSourcePlayv
259 #define alSourceStopv palSourceStopv
260 #define alSourceRewindv palSourceRewindv
261 #define alSourcePausev palSourcePausev
262 #define alSourcePlay palSourcePlay
263 #define alSourceStop palSourceStop
264 #define alSourceRewind palSourceRewind
265 #define alSourcePause palSourcePause
266 #define alSourceQueueBuffers palSourceQueueBuffers
267 #define alSourceUnqueueBuffers palSourceUnqueueBuffers
268 #define alGenBuffers palGenBuffers
269 #define alDeleteBuffers palDeleteBuffers
270 #define alIsBuffer palIsBuffer
271 #define alBufferf palBufferf
272 #define alBuffer3f palBuffer3f
273 #define alBufferfv palBufferfv
274 #define alBufferi palBufferi
275 #define alBuffer3i palBuffer3i
276 #define alBufferiv palBufferiv
277 #define alGetBufferf palGetBufferf
278 #define alGetBuffer3f palGetBuffer3f
279 #define alGetBufferfv palGetBufferfv
280 #define alGetBufferi palGetBufferi
281 #define alGetBuffer3i palGetBuffer3i
282 #define alGetBufferiv palGetBufferiv
283 #define alBufferData palBufferData
284 #define alDopplerFactor palDopplerFactor
285 #define alDopplerVelocity palDopplerVelocity
286 #define alDistanceModel palDistanceModel
287 #define alSpeedOfSound palSpeedOfSound
288 #endif
290 #include <math.h>
291 #include "wingdi.h"
292 #include "mmreg.h"
294 /* OpenAL only allows for 1 single access to the device at the same time */
295 extern CRITICAL_SECTION openal_crst;
297 extern const ALCchar *DSOUND_getdevicestrings(void);
298 extern const ALCchar *DSOUND_getcapturedevicestrings(void);
300 extern LPALCMAKECONTEXTCURRENT set_context;
301 extern LPALCGETCURRENTCONTEXT get_context;
302 extern BOOL local_contexts;
304 /* Device implementation */
305 typedef struct DS8Primary DS8Primary;
306 typedef struct DS8Buffer DS8Buffer;
308 typedef struct DS8Impl
310 IDirectSound8 IDirectSound8_iface;
311 IDirectSound IDirectSound_iface;
313 LONG ref;
314 BOOL is_8;
316 LONG *deviceref;
317 ALCdevice *device;
318 DS8Primary *primary;
320 DWORD speaker_config;
321 DWORD prio_level;
322 GUID guid;
323 } DS8Impl;
325 /* Sample types */
326 #define AL_BYTE 0x1400
327 #define AL_UNSIGNED_BYTE 0x1401
328 #define AL_SHORT 0x1402
329 #define AL_UNSIGNED_SHORT 0x1403
330 #define AL_INT 0x1404
331 #define AL_UNSIGNED_INT 0x1405
332 #define AL_FLOAT 0x1406
333 #define AL_DOUBLE 0x1407
334 #define AL_BYTE3 0x1408
335 #define AL_UNSIGNED_BYTE3 0x1409
336 #define AL_MULAW 0x1410
337 #define AL_IMA4 0x1411
339 /* Channel configurations */
340 #define AL_MONO 0x1500
341 #define AL_STEREO 0x1501
342 #define AL_REAR 0x1502
343 #define AL_QUAD 0x1503
344 #define AL_5POINT1 0x1504 /* (WFX order) */
345 #define AL_6POINT1 0x1505 /* (WFX order) */
346 #define AL_7POINT1 0x1506 /* (WFX order) */
348 /* Storage formats */
349 #define AL_MONO8 0x1100
350 #define AL_MONO16 0x1101
351 #define AL_MONO32F 0x10010
352 #define AL_STEREO8 0x1102
353 #define AL_STEREO16 0x1103
354 #define AL_STEREO32F 0x10011
355 #define AL_QUAD8 0x1204
356 #define AL_QUAD16 0x1205
357 #define AL_QUAD32F 0x1206
358 #define AL_REAR8 0x1207
359 #define AL_REAR16 0x1208
360 #define AL_REAR32F 0x1209
361 #define AL_5POINT1_8 0x120A
362 #define AL_5POINT1_16 0x120B
363 #define AL_5POINT1_32F 0x120C
364 #define AL_6POINT1_8 0x120D
365 #define AL_6POINT1_16 0x120E
366 #define AL_6POINT1_32F 0x120F
367 #define AL_7POINT1_8 0x1210
368 #define AL_7POINT1_16 0x1211
369 #define AL_7POINT1_32F 0x1212
371 enum {
372 EXT_EFX,
373 EXT_FLOAT32,
374 EXT_MCFORMATS,
375 EXT_STATIC_BUFFER,
376 SOFT_BUFFER_SAMPLES,
377 SOFT_BUFFER_SUB_DATA,
378 SOFT_DEFERRED_UPDATES,
380 MAX_EXTENSIONS
383 typedef struct ExtALFuncs
385 PFNALBUFFERSUBDATASOFTPROC BufferSubData;
386 PFNALBUFFERDATASTATICPROC BufferDataStatic;
388 LPALGENEFFECTS GenEffects;
389 LPALDELETEEFFECTS DeleteEffects;
390 LPALEFFECTI Effecti;
391 LPALEFFECTF Effectf;
393 LPALGENAUXILIARYEFFECTSLOTS GenAuxiliaryEffectSlots;
394 LPALDELETEAUXILIARYEFFECTSLOTS DeleteAuxiliaryEffectSlots;
395 LPALAUXILIARYEFFECTSLOTI AuxiliaryEffectSloti;
397 void (AL_APIENTRY*BufferSamplesSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*);
398 void (AL_APIENTRY*BufferSubSamplesSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*);
399 void (AL_APIENTRY*GetBufferSamplesSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,ALvoid*);
400 ALboolean (AL_APIENTRY*IsBufferFormatSupportedSOFT)(ALenum);
402 void (AL_APIENTRY*DeferUpdates)(void);
403 void (AL_APIENTRY*ProcessUpdates)(void);
404 } ExtALFuncs;
406 struct DS8Primary
408 IDirectSoundBuffer IDirectSoundBuffer_iface;
409 IDirectSound3DListener IDirectSound3DListener_iface;
410 IKsPropertySet IKsPropertySet_iface;
412 LONG ref, ds3d_ref, prop_ref;
413 IDirectSoundBuffer8 *write_emu;
414 DS8Impl *parent;
416 CRITICAL_SECTION crst;
418 DWORD buf_size;
419 BOOL stopped;
420 DWORD flags;
421 WAVEFORMATEXTENSIBLE format;
422 ALCcontext *ctx;
424 ALboolean SupportedExt[MAX_EXTENSIONS];
426 ALuint *sources;
427 DWORD nsources, sizesources;
428 DWORD max_sources;
429 DS8Buffer **buffers;
430 DWORD nbuffers, sizebuffers;
431 DS8Buffer **notifies;
432 DWORD nnotifies, sizenotifies;
434 UINT timer_id;
435 DWORD timer_res;
436 HANDLE thread_hdl;
437 DWORD thread_id;
439 ALuint auxslot;
440 ALuint effect;
441 EAXLISTENERPROPERTIES eax_prop;
443 ExtALFuncs ExtAL;
444 union {
445 struct {
446 BOOL pos : 1;
447 BOOL vel : 1;
448 BOOL orientation : 1;
449 BOOL distancefactor : 1;
450 BOOL rollofffactor : 1;
451 BOOL dopplerfactor : 1;
452 BOOL effect : 1;
453 } bit;
454 int flags;
455 } dirty;
456 ALfloat rollofffactor;
457 DS3DLISTENER listen;
461 typedef struct DS8Data {
462 LONG ref;
464 /* Lock was called and unlock isn't? */
465 LONG locked;
467 WAVEFORMATEXTENSIBLE format;
469 ALuint buf_size;
470 ALenum buf_format;
471 ALenum in_type, in_chans;
472 DWORD dsbflags;
473 BYTE *data;
474 ALuint *buffers;
475 ALuint numsegs;
476 ALuint segsize;
477 ALuint lastsegsize;
478 } DS8Data;
479 /* Amount of buffers that have to be queued when
480 * bufferdatastatic and buffersubdata are not available */
481 #define QBUFFERS 3
483 struct DS8Buffer
485 IDirectSoundBuffer8 IDirectSoundBuffer8_iface;
486 IDirectSoundBuffer IDirectSoundBuffer_iface;
487 IDirectSound3DBuffer IDirectSound3DBuffer_iface;
488 IDirectSoundNotify IDirectSoundNotify_iface;
489 IKsPropertySet IKsPropertySet_iface;
491 LONG ref, ds3d_ref, not_ref, prop_ref;
492 LONG all_ref;
494 DWORD ds3dmode;
495 DS8Primary *primary;
496 DS8Data *buffer;
497 ALuint source;
498 ALuint curidx;
499 BOOL isplaying, islooping, bufferlost;
500 ALCcontext *ctx;
501 ExtALFuncs *ExtAL;
502 CRITICAL_SECTION *crst;
504 DS3DBUFFER ds3dbuffer;
505 union {
506 struct {
507 BOOL pos : 1;
508 BOOL vel : 1;
509 BOOL cone_angles : 1;
510 BOOL cone_orient : 1;
511 BOOL cone_outsidevolume : 1;
512 BOOL min_distance : 1;
513 BOOL max_distance : 1;
514 BOOL mode : 1;
515 } bit;
516 int flags;
517 } dirty;
519 DWORD nnotify, lastpos;
520 DSBPOSITIONNOTIFY *notify;
523 extern HRESULT DS8Primary_Create(DS8Primary **prim, DS8Impl *parent);
524 extern void DS8Primary_Destroy(DS8Primary *prim);
526 extern HRESULT DS8Buffer_Create(DS8Buffer **ppv, DS8Primary *parent, IDirectSoundBuffer *orig);
527 extern void DS8Buffer_Destroy(DS8Buffer *buf);
529 static inline ALdouble gain_to_mB(ALdouble gain)
531 return log10(gain) * 2000.0;
533 static inline ALdouble mB_to_gain(ALdouble millibels)
535 return pow(10.0, millibels/2000.0);
538 static inline LONG clampI(LONG val, LONG minval, LONG maxval)
540 if(val >= maxval) return maxval;
541 if(val <= minval) return minval;
542 return val;
544 static inline ULONG clampU(ULONG val, ULONG minval, ULONG maxval)
546 if(val >= maxval) return maxval;
547 if(val <= minval) return minval;
548 return val;
550 static inline FLOAT clampF(FLOAT val, FLOAT minval, FLOAT maxval)
552 if(val >= maxval) return maxval;
553 if(val <= minval) return minval;
554 return val;
558 #define getALError() \
559 do { \
560 ALenum err = alGetError(); \
561 if(err != AL_NO_ERROR) \
562 ERR(">>>>>>>>>>>> Received AL error %#x on context %p, %s:%u\n", err, get_context(), __FUNCTION__, __LINE__); \
563 } while (0)
565 #define getALCError(dev) \
566 do { \
567 ALenum err = alcGetError(dev); \
568 if(err != ALC_NO_ERROR) \
569 ERR(">>>>>>>>>>>> Received ALC error %#x on device %p, %s:%u\n", err, dev, __FUNCTION__, __LINE__); \
570 } while(0)
572 #if ALLOW_CONCURRENT_AL
574 #define setALContext(actx) \
575 do { \
576 ALCcontext *__old_ctx, *cur_ctx = actx; \
577 if (!local_contexts) EnterCriticalSection(&openal_crst); \
578 __old_ctx = get_context(); \
579 if (__old_ctx != cur_ctx && set_context(cur_ctx) == ALC_FALSE) {\
580 ERR("Couldn't set current context!!\n"); \
581 getALCError(alcGetContextsDevice(cur_ctx)); \
584 /* Only restore a NULL context if using global contexts, for TLS contexts always restore */
585 #define popALContext() \
586 if (__old_ctx != cur_ctx && \
587 (local_contexts || __old_ctx) && \
588 set_context(__old_ctx) == ALC_FALSE) { \
589 ERR("Couldn't restore old context!!\n"); \
590 getALCError(alcGetContextsDevice(__old_ctx)); \
592 if (!local_contexts) LeaveCriticalSection(&openal_crst); \
593 } while (0)
595 #else
597 #define setALContext(actx) \
598 do { \
599 ALCcontext *cur_ctx = actx; \
600 if (!local_contexts) EnterCriticalSection(&openal_crst); \
601 if (set_context(cur_ctx) == ALC_FALSE) { \
602 ERR("Couldn't set current context!!\n"); \
603 getALCError(alcGetContextsDevice(cur_ctx)); \
606 #define popALContext() \
607 if (!local_contexts) LeaveCriticalSection(&openal_crst); \
608 } while (0)
610 #endif
612 HRESULT DSOUND_Create(REFIID riid, void **ppDS);
613 HRESULT DSOUND_Create8(REFIID riid, void **ppDS);
614 HRESULT DSOUND_FullDuplexCreate(REFIID riid, void **ppDSFD);
615 HRESULT IKsPrivatePropertySetImpl_Create(REFIID riid, void **piks);
616 HRESULT DSOUND_CaptureCreate(REFIID riid, void **ppDSC);
617 HRESULT DSOUND_CaptureCreate8(REFIID riid, void **ppDSC8);
619 extern const GUID DSOUND_renderer_guid;
620 extern const GUID DSOUND_capture_guid;