diff options
author | Chris Robinson <[email protected]> | 2018-12-22 22:14:25 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-12-22 22:31:26 -0800 |
commit | e218999b4f408b7fd35daa9d021288b68f5b4ab5 (patch) | |
tree | 87a5e78d31310136620bf0418cbd9ec9c63636cb /OpenAL32/alAuxEffectSlot.cpp | |
parent | ebfe818d2eb3a5c4e27040f139ae3fb349f13865 (diff) |
Dynamically sort the effect slots when mixing
This is to be able to support effects that output to other effects. When an
effect outputs to another effect, the former needs to process first, so the
former mixes to the latter's buffer before the latter is processed.
This sorting needs to happen in the mixer because the effect slot's "Target"
property changes asynchronously.
Diffstat (limited to 'OpenAL32/alAuxEffectSlot.cpp')
-rw-r--r-- | OpenAL32/alAuxEffectSlot.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/OpenAL32/alAuxEffectSlot.cpp b/OpenAL32/alAuxEffectSlot.cpp index db22ca4c..ca279aee 100644 --- a/OpenAL32/alAuxEffectSlot.cpp +++ b/OpenAL32/alAuxEffectSlot.cpp @@ -71,10 +71,11 @@ void AddActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontext *cont ALsizei newcount{curarray->count + count}; /* Insert the new effect slots into the head of the array, followed by the - * existing ones. + * existing ones. Allocate twice as much space for effect slots so the + * mixer has a place to sort them. */ auto newarray = static_cast<ALeffectslotArray*>(al_calloc(DEF_ALIGN, - FAM_SIZE(ALeffectslotArray, slot, newcount))); + FAM_SIZE(ALeffectslotArray, slot, newcount*2))); newarray->count = newcount; auto slotiter = std::transform(slotids, slotids+count, newarray->slot, [context](ALuint id) noexcept -> ALeffectslot* @@ -99,7 +100,7 @@ void AddActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontext *cont { curarray = newarray; newarray = static_cast<ALeffectslotArray*>(al_calloc(DEF_ALIGN, - FAM_SIZE(ALeffectslotArray, slot, newcount))); + FAM_SIZE(ALeffectslotArray, slot, newcount*2))); newarray->count = newcount; std::copy_n(curarray->slot, newcount, newarray->slot); al_free(curarray); @@ -122,7 +123,7 @@ void RemoveActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontext *c * any) of the effect slots to remove are in the array. */ auto newarray = static_cast<ALeffectslotArray*>(al_calloc(DEF_ALIGN, - FAM_SIZE(ALeffectslotArray, slot, curarray->count))); + FAM_SIZE(ALeffectslotArray, slot, curarray->count*2))); /* Copy each element in curarray to newarray whose ID is not in slotids. */ const ALuint *slotids_end{slotids + count}; |