AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) { ALCcontext *Context; Context = GetContextRef(); if(!Context) return; if(n < 0 || IsBadWritePtr((void*)effectslots, n * sizeof(ALuint))) alSetError(Context, AL_INVALID_VALUE); else { ALenum err; ALsizei i; err = ResizeEffectSlotArray(Context, n); if(err != AL_NO_ERROR) { alSetError(Context, err); n = 0; } for(i = 0;i < n;i++) { ALeffectslot *slot = calloc(1, sizeof(ALeffectslot)); if(!slot || InitEffectSlot(slot) != AL_NO_ERROR) { free(slot); // We must have run out or memory alSetError(Context, AL_OUT_OF_MEMORY); alDeleteAuxiliaryEffectSlots(i, effectslots); break; } LockContext(Context); err = ResizeEffectSlotArray(Context, 1); if(err == AL_NO_ERROR) Context->ActiveEffectSlots[Context->ActiveEffectSlotCount++] = slot; UnlockContext(Context); if(err == AL_NO_ERROR) err = NewThunkEntry(&slot->effectslot); if(err == AL_NO_ERROR) err = InsertUIntMapEntry(&Context->EffectSlotMap, slot->effectslot, slot); if(err != AL_NO_ERROR) { RemoveEffectSlotArray(Context, slot); FreeThunkEntry(slot->effectslot); ALeffectState_Destroy(slot->EffectState); free(slot); alSetError(Context, err); alDeleteAuxiliaryEffectSlots(i, effectslots); break; } effectslots[i] = slot->effectslot; } } ALCcontext_DecRef(Context); }
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) { ALCcontext *context; VECTOR(ALeffectslot*) slotvec; ALsizei cur; ALenum err; context = GetContextRef(); if(!context) return; VECTOR_INIT(slotvec); if(!(n >= 0)) SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); if(!VECTOR_RESERVE(slotvec, n)) SET_ERROR_AND_GOTO(context, AL_OUT_OF_MEMORY, done); for(cur = 0;cur < n;cur++) { ALeffectslot *slot = al_calloc(16, sizeof(ALeffectslot)); err = AL_OUT_OF_MEMORY; if(!slot || (err=InitEffectSlot(slot)) != AL_NO_ERROR) { al_free(slot); alDeleteAuxiliaryEffectSlots(cur, effectslots); SET_ERROR_AND_GOTO(context, err, done); } err = NewThunkEntry(&slot->id); if(err == AL_NO_ERROR) err = InsertUIntMapEntry(&context->EffectSlotMap, slot->id, slot); if(err != AL_NO_ERROR) { FreeThunkEntry(slot->id); DELETE_OBJ(slot->Params.EffectState); al_free(slot); alDeleteAuxiliaryEffectSlots(cur, effectslots); SET_ERROR_AND_GOTO(context, err, done); } aluInitEffectPanning(slot); VECTOR_PUSH_BACK(slotvec, slot); effectslots[cur] = slot->id; } err = AddEffectSlotArray(context, VECTOR_BEGIN(slotvec), n); if(err != AL_NO_ERROR) { alDeleteAuxiliaryEffectSlots(cur, effectslots); SET_ERROR_AND_GOTO(context, err, done); } done: VECTOR_DEINIT(slotvec); ALCcontext_DecRef(context); }
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) { ALCcontext *context; ALeffectslot *first, *last; ALsizei cur; ALenum err; context = GetContextRef(); if(!context) return; if(!(n >= 0)) SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); first = last = NULL; for(cur = 0;cur < n;cur++) { ALeffectslot *slot = al_calloc(16, sizeof(ALeffectslot)); err = AL_OUT_OF_MEMORY; if(!slot || (err=InitEffectSlot(slot)) != AL_NO_ERROR) { al_free(slot); alDeleteAuxiliaryEffectSlots(cur, effectslots); SET_ERROR_AND_GOTO(context, err, done); } err = NewThunkEntry(&slot->id); if(err == AL_NO_ERROR) err = InsertUIntMapEntry(&context->EffectSlotMap, slot->id, slot); if(err != AL_NO_ERROR) { FreeThunkEntry(slot->id); DELETE_OBJ(slot->Params.EffectState); al_free(slot); alDeleteAuxiliaryEffectSlots(cur, effectslots); SET_ERROR_AND_GOTO(context, err, done); } aluInitEffectPanning(slot); if(!first) first = slot; if(last) ATOMIC_STORE(&last->next, slot); last = slot; effectslots[cur] = slot->id; } AddEffectSlotList(context, first, last); done: ALCcontext_DecRef(context); }
bool cOAL_EffectSlot::DestroyLowLevelID() { DEF_FUNC_NAME("cOAL_EffectSlot::DestroyLowLevelID()"); FUNC_USES_AL; RUN_AL_FUNC(alDeleteAuxiliaryEffectSlots(1,&mlObjectId)); return (!AL_ERROR_OCCURED && !IsValidObject()); }
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) { ALCcontext *Context; ALsizei i; Context = alcGetCurrentContext(); if(!Context) { alSetError(AL_INVALID_OPERATION); return; } SuspendContext(Context); if (n > 0) { /* NOTE: We only support one slot currently */ if(n == 1 && Context->AuxiliaryEffectSlotCount == 0) { // Check that enough memory has been allocted in the 'effectslots' array for n Effect Slots if (!IsBadWritePtr((void*)effectslots, n * sizeof(ALuint))) { ALeffectslot **list = &Context->AuxiliaryEffectSlot; while(*list) list = &(*list)->next; i = 0; while(i < n) { *list = calloc(1, sizeof(ALeffectslot)); if(!(*list)) { // We must have run out or memory alDeleteAuxiliaryEffectSlots(i, effectslots); alSetError(AL_OUT_OF_MEMORY); break; } (*list)->Gain = 1.0; (*list)->AuxSendAuto = AL_TRUE; (*list)->refcount = 0; effectslots[i] = (ALuint)ALTHUNK_ADDENTRY(*list); (*list)->effectslot = effectslots[i]; Context->AuxiliaryEffectSlotCount++; i++; list = &(*list)->next; } } } else alSetError(AL_INVALID_OPERATION); } ProcessContext(Context); }
ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) { ALCcontext *Context; ALsizei i, j; Context = GetContextSuspended(); if(!Context) return; if (n > 0) { ALCdevice *Device = Context->Device; if(Context->AuxiliaryEffectSlotCount+n <= Device->AuxiliaryEffectSlotMax) { // Check that enough memory has been allocted in the 'effectslots' array for n Effect Slots if (!IsBadWritePtr((void*)effectslots, n * sizeof(ALuint))) { ALeffectslot **list = &Context->AuxiliaryEffectSlot; while(*list) list = &(*list)->next; i = 0; while(i < n) { *list = calloc(1, sizeof(ALeffectslot)); if(!(*list) || !((*list)->EffectState=NoneCreate())) { // We must have run out or memory free(*list); *list = NULL; alDeleteAuxiliaryEffectSlots(i, effectslots); alSetError(AL_OUT_OF_MEMORY); break; } (*list)->Gain = 1.0; (*list)->AuxSendAuto = AL_TRUE; for(j = 0;j < BUFFERSIZE;j++) (*list)->WetBuffer[j] = 0.0f; (*list)->refcount = 0; effectslots[i] = (ALuint)ALTHUNK_ADDENTRY(*list); (*list)->effectslot = effectslots[i]; Context->AuxiliaryEffectSlotCount++; i++; list = &(*list)->next; } } } else alSetError(AL_INVALID_OPERATION); } ProcessContext(Context); }
CEFX::~CEFX() { if (supported) { alAuxiliaryEffectSloti(sfxSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL); alDeleteFilters(1, &sfxFilter); alDeleteEffects(1, &sfxReverb); alDeleteAuxiliaryEffectSlots(1, &sfxSlot); } delete sfxProperties; }
CEFX::~CEFX() { configHandler->RemoveObserver(this); if (supported) { alAuxiliaryEffectSloti(sfxSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL); alDeleteFilters(1, &sfxFilter); alDeleteEffects(1, &sfxReverb); alDeleteAuxiliaryEffectSlots(1, &sfxSlot); } delete sfxProperties; }
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) { ALCcontext *Context; ALsizei cur = 0; Context = GetContextRef(); if(!Context) return; al_try { ALenum err; CHECK_VALUE(Context, n >= 0); for(cur = 0;cur < n;cur++) { ALeffectslot *slot = al_calloc(16, sizeof(ALeffectslot)); err = AL_OUT_OF_MEMORY; if(!slot || (err=InitEffectSlot(slot)) != AL_NO_ERROR) { al_free(slot); al_throwerr(Context, err); break; } err = NewThunkEntry(&slot->id); if(err == AL_NO_ERROR) err = InsertUIntMapEntry(&Context->EffectSlotMap, slot->id, slot); if(err != AL_NO_ERROR) { FreeThunkEntry(slot->id); ALeffectState_Destroy(slot->EffectState); al_free(slot); al_throwerr(Context, err); } effectslots[cur] = slot->id; } err = AddEffectSlotArray(Context, n, effectslots); if(err != AL_NO_ERROR) al_throwerr(Context, err); } al_catchany() { if(cur > 0) alDeleteAuxiliaryEffectSlots(cur, effectslots); } al_endtry; ALCcontext_DecRef(Context); }
// Thread: Main. Must be locked: AudioMutex. void ClosePlaybackDevice(not_null<Instance*> instance) { if (!AudioDevice) return; LOG(("Audio Info: Closing audio playback device.")); #ifndef TDESKTOP_DISABLE_OPENAL_EFFECTS // playback speed related alDeleteFilters(1, &_playbackSpeedData.uiFilter); alDeleteEffects(1, &_playbackSpeedData.uiEffect); alDeleteAuxiliaryEffectSlots(1, &_playbackSpeedData.uiEffectSlot); _playbackSpeedData.uiFilter = 0; _playbackSpeedData.uiEffect = 0; _playbackSpeedData.uiEffectSlot = 0; #endif // TDESKTOP_DISABLE_OPENAL_EFFECTS if (Player::mixer()) { Player::mixer()->detachTracks(); } instance->detachTracks(); DestroyPlaybackDevice(); }
void openal_kill() { if(soundevents.size()) killarray(soundevents); if(soundbuffers.size()) killarray(soundbuffers); if(musiclist.size()) killarray(musiclist); if(uiEffect) alDeleteEffects(1,&uiEffect); if(uiEffectSlot) alDeleteAuxiliaryEffectSlots(1,&uiEffectSlot); if(uiFilter) alDeleteFilters(1,&uiFilter); alcMakeContextCurrent(NULL); alcDestroyContext(ctx); alcCloseDevice(dev); }
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 ALvoid CDECL wine_alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint* slots) { alDeleteAuxiliaryEffectSlots(n, slots); }
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) { ALCdevice *device; ALCcontext *context; ALsizei cur; context = GetContextRef(); if(!context) return; if(n < 0) SETERR_GOTO(context, AL_INVALID_VALUE, done, "Generating %d effect slots", n); if(n == 0) goto done; LockEffectSlotList(context); device = context->Device; for(cur = 0;cur < n;cur++) { ALeffectslotPtr *iter = VECTOR_BEGIN(context->EffectSlotList); ALeffectslotPtr *end = VECTOR_END(context->EffectSlotList); ALeffectslot *slot = NULL; ALenum err = AL_OUT_OF_MEMORY; for(;iter != end;iter++) { if(!*iter) break; } if(iter == end) { if(device->AuxiliaryEffectSlotMax == VECTOR_SIZE(context->EffectSlotList)) { UnlockEffectSlotList(context); alDeleteAuxiliaryEffectSlots(cur, effectslots); SETERR_GOTO(context, AL_OUT_OF_MEMORY, done, "Exceeding %u auxiliary effect slot limit", device->AuxiliaryEffectSlotMax); } VECTOR_PUSH_BACK(context->EffectSlotList, NULL); iter = &VECTOR_BACK(context->EffectSlotList); } slot = al_calloc(16, sizeof(ALeffectslot)); if(!slot || (err=InitEffectSlot(slot)) != AL_NO_ERROR) { al_free(slot); UnlockEffectSlotList(context); alDeleteAuxiliaryEffectSlots(cur, effectslots); SETERR_GOTO(context, err, done, "Effect slot object allocation failed"); } aluInitEffectPanning(slot); slot->id = (iter - VECTOR_BEGIN(context->EffectSlotList)) + 1; *iter = slot; effectslots[cur] = slot->id; } AddActiveEffectSlots(effectslots, n, context); UnlockEffectSlotList(context); done: ALCcontext_DecRef(context); }
rs::EffectSlot::~EffectSlot() { if( alDeleteAuxiliaryEffectSlots ) { rsCheckOpenALError( alDeleteAuxiliaryEffectSlots( 1, &mEFXEffectSlotID )); } }
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) { ALCcontext *Context; ALCdevice *Device; Context = GetContextSuspended(); if(!Context) return; Device = Context->Device; if(n < 0 || IsBadWritePtr((void*)effectslots, n * sizeof(ALuint))) alSetError(Context, AL_INVALID_VALUE); else if((ALuint)n > Device->AuxiliaryEffectSlotMax - Context->EffectSlotMap.size) alSetError(Context, AL_INVALID_VALUE); else { ALenum err; ALsizei i, j; i = 0; while(i < n) { ALeffectslot *slot = calloc(1, sizeof(ALeffectslot)); if(!slot || !(slot->EffectState=NoneCreate())) { free(slot); // We must have run out or memory alSetError(Context, AL_OUT_OF_MEMORY); alDeleteAuxiliaryEffectSlots(i, effectslots); break; } slot->effectslot = (ALuint)ALTHUNK_ADDENTRY(slot); err = InsertUIntMapEntry(&Context->EffectSlotMap, slot->effectslot, slot); if(err != AL_NO_ERROR) { ALTHUNK_REMOVEENTRY(slot->effectslot); ALEffect_Destroy(slot->EffectState); free(slot); alSetError(Context, err); alDeleteAuxiliaryEffectSlots(i, effectslots); break; } effectslots[i++] = slot->effectslot; slot->Gain = int2ALfp(1); slot->AuxSendAuto = AL_TRUE; for(j = 0;j < BUFFERSIZE;j++) slot->WetBuffer[j] = int2ALfp(0); for(j = 0;j < 1;j++) { slot->ClickRemoval[j] = int2ALfp(0); slot->PendingClicks[j] = int2ALfp(0); } slot->refcount = 0; } } ProcessContext(Context); }