From 0593d8e34d6d80f52be8f5c5ce13cadc873d9221 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Sat, 14 Jul 2012 01:39:21 +0200 Subject: [PATCH] dsound: Add supper secret stuff from dsound-openal --- dlls/dsound/dsound_private.h | 187 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h index 0d376844cc2..14ad7344085 100644 --- a/dlls/dsound/dsound_private.h +++ b/dlls/dsound/dsound_private.h @@ -246,6 +246,193 @@ extern LPALSPEEDOFSOUND palSpeedOfSound; /* OpenAL only allows for 1 single access to the device at the same time */ extern CRITICAL_SECTION openal_crst; + +extern LPALCMAKECONTEXTCURRENT set_context; +extern LPALCGETCURRENTCONTEXT get_context; +extern BOOL local_contexts; + +/* Device implementation */ +typedef struct DS8Primary DS8Primary; +typedef struct DS8Buffer DS8Buffer; + +typedef struct DS8Impl +{ + IDirectSound8 IDirectSound8_iface; + + LONG ref; + BOOL is_8; + + LONG *deviceref; + ALCdevice *device; + DS8Primary *primary; + + DWORD speaker_config; + DWORD prio_level; + GUID guid; +} DS8Impl; + +typedef struct ExtALFuncs +{ + PFNALBUFFERSUBDATASOFTPROC BufferSubData; + PFNALBUFFERDATASTATICPROC BufferDataStatic; + + LPALGENEFFECTS GenEffects; + LPALDELETEEFFECTS DeleteEffects; + LPALEFFECTI Effecti; + LPALEFFECTF Effectf; + + LPALGENAUXILIARYEFFECTSLOTS GenAuxiliaryEffectSlots; + LPALDELETEAUXILIARYEFFECTSLOTS DeleteAuxiliaryEffectSlots; + LPALAUXILIARYEFFECTSLOTI AuxiliaryEffectSloti; + +} ExtALFuncs; + +struct DS8Primary +{ + IDirectSoundBuffer IDirectSoundBuffer_iface; + IDirectSound3DListener IDirectSound3DListener_iface; + IKsPropertySet IKsPropertySet_iface; + + LONG ref, ds3d_ref, prop_ref; + IDirectSoundBuffer8 *write_emu; + DS8Impl *parent; + + CRITICAL_SECTION crst; + + DWORD buf_size; + BOOL stopped; + DWORD flags; + WAVEFORMATEX *format; + ALCcontext *ctx; + BOOL has_efx; + + ALuint *sources; + DWORD nsources, sizesources; + DWORD max_sources; + DS8Buffer **buffers; + DWORD nbuffers, sizebuffers; + DS8Buffer **notifies; + DWORD nnotifies, sizenotifies; + UINT timer_id; + DWORD timer_res; + + ALuint auxslot; + ALuint effect; + EAXLISTENERPROPERTIES eax_prop; + + ExtALFuncs ExtAL; + union { + struct { + BOOL pos : 1; + BOOL vel : 1; + BOOL orientation : 1; + BOOL distancefactor : 1; + BOOL rollofffactor : 1; + BOOL dopplerfactor : 1; + BOOL effect : 1; + } bit; + int flags; + } dirty; + ALfloat rollofffactor; + DS3DLISTENER listen; +}; + +typedef struct DS8Data DS8Data; + +struct DS8Buffer +{ + IDirectSoundBuffer8 IDirectSoundBuffer8_iface; + IDirectSound3DBuffer IDirectSound3DBuffer_iface; + IDirectSoundNotify IDirectSoundNotify_iface; + IKsPropertySet IKsPropertySet_iface; + + LONG ref, ds3d_ref, not_ref, prop_ref; + LONG all_ref; + + DWORD ds3dmode; + DS8Primary *primary; + DS8Data *buffer; + ALuint source; + ALuint curidx; + BOOL isplaying, islooping, bufferlost; + ALCcontext *ctx; + ExtALFuncs *ExtAL; + CRITICAL_SECTION *crst; + + DS3DBUFFER ds3dbuffer; + union { + struct { + BOOL pos : 1; + BOOL vel : 1; + BOOL cone_angles : 1; + BOOL cone_orient : 1; + BOOL cone_outsidevolume : 1; + BOOL min_distance : 1; + BOOL max_distance : 1; + BOOL mode : 1; + } bit; + int flags; + } dirty; + + DWORD nnotify, lastpos; + DSBPOSITIONNOTIFY *notify; +}; + +extern HRESULT DS8Primary_Create(DS8Primary **prim, DS8Impl *parent); +extern void DS8Primary_Destroy(DS8Primary *prim); + +extern HRESULT DS8Buffer_Create(DS8Buffer **ppv, DS8Primary *parent, DS8Buffer *orig); +extern void DS8Buffer_Destroy(DS8Buffer *buf); + +static inline ALdouble gain_to_mB(ALdouble gain) +{ + return log10(gain) * 2000.0; +} + +static inline ALdouble mB_to_gain(ALdouble millibels) +{ + return pow(10.0, millibels/2000.0); +} + +#define getALError() \ +do { \ + ALenum err = palGetError(); \ + if(err != AL_NO_ERROR) \ + { \ + ERR(">>>>>>>>>>>> Received AL error %#x on context %p, %s:%u\n", err, get_context(), __FUNCTION__, __LINE__); \ + } \ +} while (0) + +#define getALCError(dev) \ +do { \ + ALenum err = palcGetError(dev); \ + if(err != ALC_NO_ERROR) \ + { \ + ERR(">>>>>>>>>>>> Received ALC error %#x on device %p, %s:%u\n", err, dev, __FUNCTION__, __LINE__); \ + } \ +} while(0) + +#define setALContext(actx) \ + do { \ + ALCcontext *__old_ctx, *cur_ctx = actx; \ + if (!local_contexts) EnterCriticalSection(&openal_crst); \ + __old_ctx = get_context(); \ + if (__old_ctx != cur_ctx && set_context(cur_ctx) == ALC_FALSE) {\ + ERR("Couldn't set current context!!\n"); \ + getALCError(palcGetContextsDevice(cur_ctx)); \ + } + +/* Only restore a NULL context if using global contexts, for TLS contexts always restore */ +#define popALContext() \ + if (__old_ctx != cur_ctx && \ + (local_contexts || __old_ctx) && \ + set_context(__old_ctx) == ALC_FALSE) { \ + ERR("Couldn't restore old context!!\n"); \ + getALCError(palcGetContextsDevice(__old_ctx)); \ + } \ + if (!local_contexts) LeaveCriticalSection(&openal_crst); \ + } while (0) + #endif extern int ds_hel_buflen DECLSPEC_HIDDEN; -- 2.11.4.GIT