From 79900d72f7aa073d0d7963a65289079abd664126 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 5 Aug 2011 13:59:20 -0700 Subject: [PATCH] Make the effect object part of the primary buffer It's effectively the OpenAL storage of the EAXLISTENERPROPERTIES struct, and should be where it is. --- dsound8.c | 5 ----- dsound_private.h | 6 +++--- primary.c | 21 ++++++++++++++++----- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/dsound8.c b/dsound8.c index 5203b77..e40f65e 100644 --- a/dsound8.c +++ b/dsound8.c @@ -96,8 +96,6 @@ static void DSShare_Destroy(DeviceShare *share) if(share->nsources) alDeleteSources(share->nsources, share->sources); - if(share->effect) - share->ExtAL.DeleteEffects(1, &share->effect); if(share->auxslot) share->ExtAL.DeleteAuxiliaryEffectSlots(1, &share->auxslot); @@ -221,9 +219,6 @@ static HRESULT DSShare_Create(REFIID guid, DeviceShare **out) #undef LOAD_FUNC share->SupportedExt[EXT_EFX] = AL_TRUE; - share->ExtAL.GenEffects(1, &share->effect); - share->ExtAL.Effecti(share->effect, AL_EFFECT_TYPE, AL_EFFECT_REVERB); - share->ExtAL.GenAuxiliaryEffectSlots(1, &share->auxslot); } diff --git a/dsound_private.h b/dsound_private.h index 5851668..4e58d8c 100644 --- a/dsound_private.h +++ b/dsound_private.h @@ -397,7 +397,6 @@ typedef struct DeviceShare { DWORD nsources, max_sources; ALuint auxslot; - ALuint effect; GUID guid; } DeviceShare; @@ -419,7 +418,6 @@ struct DS8Primary { CRITICAL_SECTION *crst; ALuint *sources; ALuint auxslot; - ALuint effect; DWORD buf_size; BOOL stopped; @@ -436,6 +434,9 @@ struct DS8Primary { DS8Buffer **notifies; DWORD nnotifies, sizenotifies; + ALuint effect; + ALfloat rollofffactor; + union { struct { BOOL pos : 1; @@ -448,7 +449,6 @@ struct DS8Primary { } bit; int flags; } dirty; - ALfloat rollofffactor; DS3DLISTENER listen; EAXLISTENERPROPERTIES eax_prop; diff --git a/primary.c b/primary.c index 00f5ada..b3e163a 100644 --- a/primary.c +++ b/primary.c @@ -234,14 +234,11 @@ HRESULT DS8Primary_PreInit(DS8Primary *This, DS8Impl *parent) This->SupportedExt = parent->share->SupportedExt; This->ExtAL = &parent->share->ExtAL; This->sources = parent->share->sources; - This->effect = parent->share->effect; This->auxslot = parent->share->auxslot; /* Allocate enough for a WAVEFORMATEXTENSIBLE */ wfx = &This->format.Format; - This->eax_prop = EnvironmentDefaults[EAX_ENVIRONMENT_GENERIC]; - wfx->wFormatTag = WAVE_FORMAT_PCM; wfx->nChannels = 2; wfx->wBitsPerSample = 8; @@ -269,6 +266,18 @@ HRESULT DS8Primary_PreInit(DS8Primary *This, DS8Impl *parent) This->ProcessUpdates = wrap_ProcessUpdates; } + This->eax_prop = EnvironmentDefaults[EAX_ENVIRONMENT_GENERIC]; + if(This->SupportedExt[EXT_EFX] && This->auxslot != 0) + { + ALint revid = alGetEnumValue("AL_EFFECT_REVERB"); + if(revid != 0 && revid != -1) + { + This->ExtAL->GenEffects(1, &This->effect); + This->ExtAL->Effecti(This->effect, AL_EFFECT_TYPE, AL_EFFECT_REVERB); + checkALError(); + } + } + /* Make sure DS3DListener defaults are applied to OpenAL */ listener = &This->listen; listener->dwSize = sizeof(*listener); @@ -331,10 +340,12 @@ void DS8Primary_Clear(DS8Primary *This) CloseHandle(This->thread_hdl); } - EnterCriticalSection(This->crst); + setALContext(This->ctx); + if(This->effect) + This->ExtAL->DeleteEffects(1, &This->effect); + popALContext(); while(This->nbuffers--) DS8Buffer_Destroy(This->buffers[This->nbuffers]); - LeaveCriticalSection(This->crst); HeapFree(GetProcessHeap(), 0, This->notifies); HeapFree(GetProcessHeap(), 0, This->buffers); -- 2.11.4.GIT