diff options
author | Chris Robinson <[email protected]> | 2012-01-19 19:30:03 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2012-01-19 19:30:03 -0800 |
commit | 51e81f4867a02001f390222b6ce86bf212a38bd6 (patch) | |
tree | 8391b8f6dee8924223a80140a67f644a53b5fa7d /Alc/ALc.c | |
parent | ae7b61b040059f7112ad6fb38340b8c25d3393b7 (diff) |
Add a global option to apply a reverb effect on source send 0
A special slot on the device is created and processed, so it can be shared
across all contexts on the device. Sources that don't have a slot set on send 0
will use this special slot instead.
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r-- | Alc/ALc.c | 29 |
1 files changed, 28 insertions, 1 deletions
@@ -399,6 +399,9 @@ static ALCboolean TrapALCError = ALC_FALSE; /* One-time configuration init control */ static pthread_once_t alc_config_once = PTHREAD_ONCE_INIT; +/* Forced effect that applies to sources that don't have an effect on send 0 */ +static ALeffect ForcedEffect; + /////////////////////////////////////////////////////// @@ -718,6 +721,10 @@ static void alc_initconfig(void) } } while(next++); } + + str = getenv("__ALSOFT_FORCE_REVERB"); + if(str && str[0]) + GetReverbEffect(&ForcedEffect); } @@ -1296,6 +1303,9 @@ static ALCvoid FreeDevice(ALCdevice *device) { TRACE("%p\n", device); + ALeffectState_Destroy(device->DefaultSlot->EffectState); + device->DefaultSlot->EffectState = NULL; + if(device->BufferMap.size > 0) { WARN("(%p) Deleting %d Buffer(s)\n", device, device->BufferMap.size); @@ -2236,6 +2246,8 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin } while(!CompExchangePtr((XchgPtr*)&device->ContextList, ALContext->next, ALContext)); UnlockLists(); + InitializeEffect(ALContext, device->DefaultSlot, &ForcedEffect); + ALCdevice_DecRef(device); TRACE("Created context %p\n", ALContext); @@ -2414,6 +2426,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) const ALCchar *fmt; ALCdevice *device; ALCenum err; + ALCint i; DO_INITCONFIG(); @@ -2426,7 +2439,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) if(deviceName && (!deviceName[0] || strcasecmp(deviceName, "openal soft") == 0 || strcasecmp(deviceName, "openal-soft") == 0)) deviceName = NULL; - device = calloc(1, sizeof(ALCdevice)); + device = calloc(1, sizeof(ALCdevice)+sizeof(ALeffectslot)); if(!device) { alcSetError(NULL, ALC_OUT_OF_MEMORY); @@ -2491,6 +2504,20 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) device->NumStereoSources = 1; device->NumMonoSources = device->MaxNoOfSources - device->NumStereoSources; + device->DefaultSlot = (ALeffectslot*)(device+1); + device->DefaultSlot->EffectState = NoneCreate(); + device->DefaultSlot->Gain = 1.0; + device->DefaultSlot->AuxSendAuto = AL_TRUE; + device->DefaultSlot->NeedsUpdate = AL_FALSE; + for(i = 0;i < BUFFERSIZE;i++) + device->DefaultSlot->WetBuffer[i] = 0.0f; + for(i = 0;i < 1;i++) + { + device->DefaultSlot->ClickRemoval[i] = 0.0f; + device->DefaultSlot->PendingClicks[i] = 0.0f; + } + device->DefaultSlot->ref = 0; + // Find a playback device to open LockLists(); if((err=ALCdevice_OpenPlayback(device, deviceName)) != ALC_NO_ERROR) |