ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue) { ALCcontext *Context; Context = GetContextSuspended(); if(!Context) return; if (alIsAuxiliaryEffectSlot(effectslot)) { ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot); switch(param) { case AL_EFFECTSLOT_GAIN: *pflValue = ALEffectSlot->Gain; break; default: alSetError(AL_INVALID_ENUM); break; } } else alSetError(AL_INVALID_NAME); ProcessContext(Context); }
ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues) { ALCcontext *Context; Context = GetContextSuspended(); if(!Context) return; if (alIsAuxiliaryEffectSlot(effectslot)) { switch(param) { case AL_EFFECTSLOT_GAIN: alGetAuxiliaryEffectSlotf(effectslot, param, pflValues); break; default: alSetError(AL_INVALID_ENUM); break; } } else alSetError(AL_INVALID_NAME); ProcessContext(Context); }
ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues) { ALCcontext *Context; Context = GetContextSuspended(); if(!Context) return; if (alIsAuxiliaryEffectSlot(effectslot)) { switch(param) { case AL_EFFECTSLOT_EFFECT: case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: alAuxiliaryEffectSloti(effectslot, param, piValues[0]); break; default: alSetError(AL_INVALID_ENUM); break; } } else alSetError(AL_INVALID_NAME); ProcessContext(Context); }
ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue) { ALCcontext *Context; Context = GetContextSuspended(); if(!Context) return; if (alIsAuxiliaryEffectSlot(effectslot)) { ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot); switch(param) { case AL_EFFECTSLOT_EFFECT: *piValue = ALEffectSlot->effect.effect; break; case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: *piValue = ALEffectSlot->AuxSendAuto; break; default: alSetError(AL_INVALID_ENUM); break; } } else alSetError(AL_INVALID_NAME); ProcessContext(Context); }
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue) { ALCcontext *Context; Context = alcGetCurrentContext(); if(!Context) { alSetError(AL_INVALID_OPERATION); return; } SuspendContext(Context); if (alIsAuxiliaryEffectSlot(effectslot)) { ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot); switch(param) { case AL_EFFECTSLOT_GAIN: if(flValue >= 0.0f && flValue <= 1.0f) ALEffectSlot->Gain = flValue; else alSetError(AL_INVALID_VALUE); break; default: alSetError(AL_INVALID_ENUM); break; } } else alSetError(AL_INVALID_NAME); ProcessContext(Context); }
bool cOAL_EffectSlot::IsValidObject() { DEF_FUNC_NAME("cOAL_EffectSlot::IsValidObject()"); FUNC_USES_AL; return (alIsAuxiliaryEffectSlot(mlObjectId) == AL_TRUE); }
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue) { ALCcontext *Context; Context = alcGetCurrentContext(); if(!Context) { alSetError(AL_INVALID_OPERATION); return; } SuspendContext(Context); if (alIsAuxiliaryEffectSlot(effectslot)) { ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot); switch(param) { case AL_EFFECTSLOT_EFFECT: if(alIsEffect(iValue)) { ALeffect *effect = (ALeffect*)ALTHUNK_LOOKUPENTRY(iValue); InitializeEffect(Context, ALEffectSlot, effect); } else alSetError(AL_INVALID_VALUE); break; case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: if(iValue == AL_TRUE || iValue == AL_FALSE) ALEffectSlot->AuxSendAuto = iValue; else alSetError(AL_INVALID_VALUE); break; default: alSetError(AL_INVALID_ENUM); break; } } else alSetError(AL_INVALID_NAME); ProcessContext(Context); }
ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) { ALCcontext *Context; ALeffectslot *ALAuxiliaryEffectSlot; ALsizei i; Context = GetContextSuspended(); if(!Context) return; if (n >= 0) { // Check that all effectslots are valid for (i = 0; i < n; i++) { if (!alIsAuxiliaryEffectSlot(effectslots[i])) { alSetError(AL_INVALID_NAME); break; } else { ALAuxiliaryEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslots[i]); if(ALAuxiliaryEffectSlot->refcount > 0) { alSetError(AL_INVALID_NAME); break; } } } if (i == n) { // All effectslots are valid for (i = 0; i < n; i++) { // Recheck that the effectslot is valid, because there could be duplicated names if (alIsAuxiliaryEffectSlot(effectslots[i])) { ALeffectslot **list; ALAuxiliaryEffectSlot = ((ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslots[i])); // Remove Source from list of Sources list = &Context->AuxiliaryEffectSlot; while(*list && *list != ALAuxiliaryEffectSlot) list = &(*list)->next; if(*list) *list = (*list)->next; ALTHUNK_REMOVEENTRY(ALAuxiliaryEffectSlot->effectslot); if(ALAuxiliaryEffectSlot->EffectState) ALEffect_Destroy(ALAuxiliaryEffectSlot->EffectState); memset(ALAuxiliaryEffectSlot, 0, sizeof(ALeffectslot)); free(ALAuxiliaryEffectSlot); Context->AuxiliaryEffectSlotCount--; } } } } else alSetError(AL_INVALID_VALUE); ProcessContext(Context); }
CEFX::CEFX(ALCdevice* device) :enabled(false) ,supported(false) ,sfxProperties(NULL) ,sfxSlot(0) ,sfxReverb(0) ,sfxFilter(0) ,updates(0) ,maxSlots(0) ,maxSlotsPerSource(0) { SetAirAbsorptionFactor(configHandler->GetFloat("snd_airAbsorption")); bool hasExtension = alcIsExtensionPresent(device, "ALC_EXT_EFX"); if(hasExtension && alGenEffects && alDeleteEffects) supported = true; //! set default preset eaxPresets["default"] = eaxPresets[default_preset]; //! always allocate this sfxProperties = new EAXSfxProps(); *sfxProperties = eaxPresets[default_preset]; if (!supported) { if(!hasExtension) LOG(" EFX Supported: no"); else LOG(" EFX is supported but software does not seem to work properly"); return; } //! clear log alGetError() ; //! Check Available Effects { static const ALuint effects[] = { AL_EFFECT_REVERB, AL_EFFECT_EAXREVERB, AL_EFFECT_CHORUS, AL_EFFECT_DISTORTION, AL_EFFECT_ECHO, AL_EFFECT_FLANGER, AL_EFFECT_FREQUENCY_SHIFTER, AL_EFFECT_VOCAL_MORPHER, AL_EFFECT_PITCH_SHIFTER, AL_EFFECT_RING_MODULATOR, AL_EFFECT_AUTOWAH, AL_EFFECT_COMPRESSOR, AL_EFFECT_EQUALIZER }; ALuint alFx; alGenEffects(1, &alFx); if (alGetError() == AL_NO_ERROR) { for(size_t i = 0; i < sizeof(effects); i++) { const ALuint fx = effects[i]; alEffecti(alFx, AL_EFFECT_TYPE, fx); effectsSupported[fx] = (alGetError() == AL_NO_ERROR); } } alDeleteEffects(1, &alFx); } //! Check Available Filters { static const ALuint filters[] = { AL_FILTER_LOWPASS, AL_FILTER_HIGHPASS, AL_FILTER_BANDPASS }; ALuint alFilter; alGenFilters(1, &alFilter); if (alGetError() == AL_NO_ERROR) { for(size_t i = 0; i < sizeof(filters); i++) { const ALuint filter = filters[i]; alFilteri(alFilter, AL_FILTER_TYPE, filter); filtersSupported[filter] = (alGetError() == AL_NO_ERROR); } } alDeleteFilters(1, &alFilter); } //! Check Max Available EffectSlots { int n; ALuint alFXSlots[128]; for (n = 0; n < 128; n++) { alGenAuxiliaryEffectSlots(1, &alFXSlots[n]); if (alGetError() != AL_NO_ERROR) break; } maxSlots = n; alDeleteAuxiliaryEffectSlots(n, alFXSlots); } //! Check Max AUX FX SLOTS Per Sound Source alcGetIntegerv(device, ALC_MAX_AUXILIARY_SENDS, 1, (ALCint*)&maxSlotsPerSource); //! Check requirements if (!effectsSupported[AL_EFFECT_EAXREVERB] || !filtersSupported[AL_FILTER_LOWPASS] || (maxSlots<1) || (maxSlotsPerSource<1) ) { LOG_L(L_WARNING, " EFX Supported: no"); supported = false; return; } //! Create our global sfx enviroment alGenAuxiliaryEffectSlots(1, &sfxSlot); alGenEffects(1, &sfxReverb); alEffecti(sfxReverb, AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB); alGenFilters(1, &sfxFilter); alFilteri(sfxFilter, AL_FILTER_TYPE, AL_FILTER_LOWPASS); if (!alIsAuxiliaryEffectSlot(sfxSlot) || !alIsEffect(sfxReverb) || !alIsFilter(sfxFilter)) { LOG_L(L_ERROR, " Initializing EFX failed!"); alDeleteFilters(1, &sfxFilter); alDeleteEffects(1, &sfxReverb); alDeleteAuxiliaryEffectSlots(1, &sfxSlot); supported = false; return; } //! Load defaults CommitEffects(); if (!CheckError(" EFX")) { LOG_L(L_ERROR, " Initializing EFX failed!"); alAuxiliaryEffectSloti(sfxSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL); alDeleteFilters(1, &sfxFilter); alDeleteEffects(1, &sfxReverb); alDeleteAuxiliaryEffectSlots(1, &sfxSlot); supported = false; return; } //! User may disable it (performance reasons?) enabled = configHandler->GetBool("UseEFX"); LOG(" EFX Enabled: %s", (enabled ? "yes" : "no")); if (enabled) { LOG_L(L_DEBUG, " EFX MaxSlots: %i", maxSlots); LOG_L(L_DEBUG, " EFX MaxSlotsPerSource: %i", maxSlotsPerSource); } configHandler->NotifyOnChange(this); }
static ALboolean CDECL wine_alIsAuxiliaryEffectSlot(ALuint sid) { return alIsAuxiliaryEffectSlot(sid); }