diff options
Diffstat (limited to 'OpenAL32/alAuxEffectSlot.c')
-rw-r--r-- | OpenAL32/alAuxEffectSlot.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index 9f554cb0..c1314301 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -13,8 +13,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * Or go to http://www.gnu.org/copyleft/lgpl.html */ @@ -35,7 +35,7 @@ extern inline struct ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id); extern inline struct ALeffectslot *RemoveEffectSlot(ALCcontext *context, ALuint id); -static ALenum AddEffectSlotArray(ALCcontext *Context, const_vector_ALeffectslotPtr slots); +static ALenum AddEffectSlotArray(ALCcontext *Context, ALeffectslot **start, ALsizei count); static void RemoveEffectSlotArray(ALCcontext *Context, const ALeffectslot *slot); @@ -52,7 +52,7 @@ static inline ALeffectStateFactory *getFactoryByType(ALenum type) AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) { ALCcontext *context; - vector_ALeffectslotPtr slotvec; + VECTOR(ALeffectslot*) slotvec; ALsizei cur; ALenum err; @@ -94,7 +94,7 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo effectslots[cur] = slot->id; } - err = AddEffectSlotArray(context, slotvec); + err = AddEffectSlotArray(context, VECTOR_ITER_BEGIN(slotvec), n); if(err != AL_NO_ERROR) { alDeleteAuxiliaryEffectSlots(cur, effectslots); @@ -183,7 +183,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param err = InitializeEffect(device, slot, effect); if(err != AL_NO_ERROR) SET_ERROR_AND_GOTO(context, err, done); - context->UpdateSources = AL_TRUE; + ATOMIC_STORE(&context->UpdateSources, AL_TRUE); break; case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: @@ -191,7 +191,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); slot->AuxSendAuto = value; - context->UpdateSources = AL_TRUE; + ATOMIC_STORE(&context->UpdateSources, AL_TRUE); break; default: @@ -246,7 +246,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); slot->Gain = value; - slot->NeedsUpdate = AL_TRUE; + ATOMIC_STORE(&slot->NeedsUpdate, AL_TRUE); break; default: @@ -385,13 +385,12 @@ done: } -static ALenum AddEffectSlotArray(ALCcontext *context, const_vector_ALeffectslotPtr slots) +static ALenum AddEffectSlotArray(ALCcontext *context, ALeffectslot **start, ALsizei count) { ALenum err = AL_NO_ERROR; LockContext(context); - if(!VECTOR_INSERT(context->ActiveAuxSlots, VECTOR_ITER_END(context->ActiveAuxSlots), - VECTOR_ITER_BEGIN(slots), VECTOR_ITER_END(slots))) + if(!VECTOR_INSERT(context->ActiveAuxSlots, VECTOR_ITER_END(context->ActiveAuxSlots), start, start+count)) err = AL_OUT_OF_MEMORY; UnlockContext(context); @@ -400,21 +399,17 @@ static ALenum AddEffectSlotArray(ALCcontext *context, const_vector_ALeffectslotP static void RemoveEffectSlotArray(ALCcontext *context, const ALeffectslot *slot) { - ALeffectslot **slotlist, **slotlistend; + ALeffectslot **iter; LockContext(context); - slotlist = VECTOR_ITER_BEGIN(context->ActiveAuxSlots); - slotlistend = VECTOR_ITER_END(context->ActiveAuxSlots); - while(slotlist != slotlistend) +#define MATCH_SLOT(_i) (slot == *(_i)) + VECTOR_FIND_IF(iter, ALeffectslot*, context->ActiveAuxSlots, MATCH_SLOT); + if(iter != VECTOR_ITER_END(context->ActiveAuxSlots)) { - if(*slotlist == slot) - { - *slotlist = VECTOR_BACK(context->ActiveAuxSlots); - VECTOR_POP_BACK(context->ActiveAuxSlots); - break; - } - slotlist++; + *iter = VECTOR_BACK(context->ActiveAuxSlots); + VECTOR_POP_BACK(context->ActiveAuxSlots); } +#undef MATCH_SLOT UnlockContext(context); } @@ -490,7 +485,7 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e /* FIXME: This should be done asynchronously, but since the EffectState * object was changed, it needs an update before its Process method can * be called. */ - EffectSlot->NeedsUpdate = AL_FALSE; + ATOMIC_STORE(&EffectSlot->NeedsUpdate, AL_FALSE); V(EffectSlot->EffectState,update)(Device, EffectSlot); ALCdevice_Unlock(Device); @@ -506,7 +501,7 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e ALCdevice_Lock(Device); memcpy(&EffectSlot->EffectProps, &effect->Props, sizeof(effect->Props)); ALCdevice_Unlock(Device); - EffectSlot->NeedsUpdate = AL_TRUE; + ATOMIC_STORE(&EffectSlot->NeedsUpdate, AL_TRUE); } } @@ -527,7 +522,7 @@ ALenum InitEffectSlot(ALeffectslot *slot) slot->Gain = 1.0; slot->AuxSendAuto = AL_TRUE; - slot->NeedsUpdate = AL_FALSE; + ATOMIC_INIT(&slot->NeedsUpdate, AL_FALSE); for(c = 0;c < 1;c++) { for(i = 0;i < BUFFERSIZE;i++) |