aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-09-27 11:13:18 -0700
committerChris Robinson <[email protected]>2017-09-27 11:13:18 -0700
commit1ab890262168444c2f6e1a9d84c3d65e5afe37f5 (patch)
tree201157974888052def0b8c24cc3f61efa0ba0f8d /OpenAL32
parentfd70b0bca6dcc97edf16d4567c84933576828230 (diff)
Re-update effect slots when context properties change
Also keep all free property update structs together in the context instead of per-object.
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h8
-rw-r--r--OpenAL32/Include/alListener.h5
-rw-r--r--OpenAL32/Include/alMain.h12
-rw-r--r--OpenAL32/Include/alu.h1
-rw-r--r--OpenAL32/alAuxEffectSlot.c34
-rw-r--r--OpenAL32/alListener.c6
-rw-r--r--OpenAL32/alSource.c18
-rw-r--r--OpenAL32/alState.c6
8 files changed, 42 insertions, 48 deletions
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index fe05e008..908c72c5 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -110,13 +110,13 @@ typedef struct ALeffectslot {
RefCount ref;
ATOMIC(struct ALeffectslotProps*) Update;
- ATOMIC(struct ALeffectslotProps*) FreeList;
struct {
ALfloat Gain;
ALboolean AuxSendAuto;
ALenum EffectType;
+ ALeffectProps EffectProps;
ALeffectState *EffectState;
ALfloat RoomRolloff; /* Added to the source's room rolloff, not multiplied. */
@@ -160,7 +160,7 @@ inline struct ALeffectslot *RemoveEffectSlot(ALCcontext *context, ALuint id)
ALenum InitEffectSlot(ALeffectslot *slot);
void DeinitEffectSlot(ALeffectslot *slot);
-void UpdateEffectSlotProps(ALeffectslot *slot);
+void UpdateEffectSlotProps(ALeffectslot *slot, ALCcontext *context);
void UpdateAllEffectSlotProps(ALCcontext *context);
ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context);
@@ -178,11 +178,13 @@ ALeffectStateFactory *ALmodulatorStateFactory_getFactory(void);
ALeffectStateFactory *ALdedicatedStateFactory_getFactory(void);
-ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *effect);
+ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect *effect);
void InitEffectFactoryMap(void);
void DeinitEffectFactoryMap(void);
+void ALeffectState_DecRef(ALeffectState *state);
+
#ifdef __cplusplus
}
#endif
diff --git a/OpenAL32/Include/alListener.h b/OpenAL32/Include/alListener.h
index 8b212d47..0d80a8d7 100644
--- a/OpenAL32/Include/alListener.h
+++ b/OpenAL32/Include/alListener.h
@@ -42,11 +42,6 @@ typedef struct ALlistener {
*/
ATOMIC(struct ALlistenerProps*) Update;
- /* A linked list of unused property containers, free to use for future
- * updates.
- */
- ATOMIC(struct ALlistenerProps*) FreeList;
-
struct {
aluMatrixf Matrix;
aluVector Velocity;
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 7ac7eb13..776fb37b 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -383,6 +383,9 @@ struct HrtfEntry;
struct FrontStablizer;
struct Compressor;
struct ALcontextProps;
+struct ALlistenerProps;
+struct ALvoiceProps;
+struct ALeffectslotProps;
#define DEFAULT_OUTPUT_RATE (44100)
@@ -868,7 +871,14 @@ struct ALCcontext_struct {
ALfloat GainBoost;
ATOMIC(struct ALcontextProps*) Update;
- ATOMIC(struct ALcontextProps*) FreeList;
+
+ /* Linked lists of unused property containers, free to use for future
+ * updates.
+ */
+ ATOMIC(struct ALcontextProps*) FreeContextProps;
+ ATOMIC(struct ALlistenerProps*) FreeListenerProps;
+ ATOMIC(struct ALvoiceProps*) FreeVoiceProps;
+ ATOMIC(struct ALeffectslotProps*) FreeEffectslotProps;
struct ALvoice **Voices;
ALsizei VoiceCount;
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 2344cc6d..049a9dcd 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -251,7 +251,6 @@ typedef struct ALvoice {
struct ALvoiceProps *Props;
ATOMIC(struct ALvoiceProps*) Update;
- ATOMIC(struct ALvoiceProps*) FreeList;
ATOMIC(struct ALsource*) Source;
ATOMIC(bool) Playing;
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index 02288a31..12092100 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -52,11 +52,10 @@ static inline ALeffectStateFactory *getFactoryByType(ALenum type)
}
static void ALeffectState_IncRef(ALeffectState *state);
-static void ALeffectState_DecRef(ALeffectState *state);
#define DO_UPDATEPROPS() do { \
if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) \
- UpdateEffectSlotProps(slot); \
+ UpdateEffectSlotProps(slot, context); \
else \
ATOMIC_FLAG_CLEAR(&slot->PropsClean, almemory_order_release); \
} while(0)
@@ -251,7 +250,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param
UnlockEffectsRead(device);
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
}
- err = InitializeEffect(device, slot, effect);
+ err = InitializeEffect(context, slot, effect);
UnlockEffectsRead(device);
if(err != AL_NO_ERROR)
@@ -497,8 +496,9 @@ void DeinitEffectFactoryMap(void)
}
-ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *effect)
+ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect *effect)
{
+ ALCdevice *Device = Context->Device;
ALenum newtype = (effect ? effect->type : AL_EFFECT_NULL);
struct ALeffectslotProps *props;
ALeffectState *State;
@@ -548,7 +548,7 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e
EffectSlot->Effect.Props = effect->Props;
/* Remove state references from old effect slot property updates. */
- props = ATOMIC_LOAD_SEQ(&EffectSlot->FreeList);
+ props = ATOMIC_LOAD_SEQ(&Context->FreeEffectslotProps);
while(props)
{
if(props->State)
@@ -568,7 +568,7 @@ static void ALeffectState_IncRef(ALeffectState *state)
TRACEREF("%p increasing refcount to %u\n", state, ref);
}
-static void ALeffectState_DecRef(ALeffectState *state)
+void ALeffectState_DecRef(ALeffectState *state)
{
uint ref;
ref = DecrementRef(&state->Ref);
@@ -606,7 +606,6 @@ ALenum InitEffectSlot(ALeffectslot *slot)
InitRef(&slot->ref, 0);
ATOMIC_INIT(&slot->Update, NULL);
- ATOMIC_INIT(&slot->FreeList, NULL);
slot->Params.Gain = 1.0f;
slot->Params.AuxSendAuto = AL_TRUE;
@@ -624,7 +623,6 @@ ALenum InitEffectSlot(ALeffectslot *slot)
void DeinitEffectSlot(ALeffectslot *slot)
{
struct ALeffectslotProps *props;
- size_t count = 0;
props = ATOMIC_LOAD_SEQ(&slot->Update);
if(props)
@@ -633,29 +631,19 @@ void DeinitEffectSlot(ALeffectslot *slot)
TRACE("Freed unapplied AuxiliaryEffectSlot update %p\n", props);
al_free(props);
}
- props = ATOMIC_LOAD(&slot->FreeList, almemory_order_relaxed);
- while(props)
- {
- struct ALeffectslotProps *next = ATOMIC_LOAD(&props->next, almemory_order_relaxed);
- if(props->State) ALeffectState_DecRef(props->State);
- al_free(props);
- props = next;
- ++count;
- }
- TRACE("Freed "SZFMT" AuxiliaryEffectSlot property object%s\n", count, (count==1)?"":"s");
ALeffectState_DecRef(slot->Effect.State);
if(slot->Params.EffectState)
ALeffectState_DecRef(slot->Params.EffectState);
}
-void UpdateEffectSlotProps(ALeffectslot *slot)
+void UpdateEffectSlotProps(ALeffectslot *slot, ALCcontext *context)
{
struct ALeffectslotProps *props;
ALeffectState *oldstate;
/* Get an unused property container, or allocate a new one as needed. */
- props = ATOMIC_LOAD(&slot->FreeList, almemory_order_relaxed);
+ props = ATOMIC_LOAD(&context->FreeEffectslotProps, almemory_order_relaxed);
if(!props)
props = al_calloc(16, sizeof(*props));
else
@@ -663,7 +651,7 @@ void UpdateEffectSlotProps(ALeffectslot *slot)
struct ALeffectslotProps *next;
do {
next = ATOMIC_LOAD(&props->next, almemory_order_relaxed);
- } while(ATOMIC_COMPARE_EXCHANGE_PTR_WEAK(&slot->FreeList, &props, next,
+ } while(ATOMIC_COMPARE_EXCHANGE_PTR_WEAK(&context->FreeEffectslotProps, &props, next,
almemory_order_seq_cst, almemory_order_acquire) == 0);
}
@@ -687,7 +675,7 @@ void UpdateEffectSlotProps(ALeffectslot *slot)
/* If there was an unused update container, put it back in the
* freelist.
*/
- ATOMIC_REPLACE_HEAD(struct ALeffectslotProps*, &slot->FreeList, props);
+ ATOMIC_REPLACE_HEAD(struct ALeffectslotProps*, &context->FreeEffectslotProps, props);
}
if(oldstate)
@@ -705,7 +693,7 @@ void UpdateAllEffectSlotProps(ALCcontext *context)
{
ALeffectslot *slot = auxslots->slot[i];
if(!ATOMIC_FLAG_TEST_AND_SET(&slot->PropsClean, almemory_order_acq_rel))
- UpdateEffectSlotProps(slot);
+ UpdateEffectSlotProps(slot, context);
}
UnlockEffectSlotsRead(context);
}
diff --git a/OpenAL32/alListener.c b/OpenAL32/alListener.c
index 7062f8c4..9a90c16e 100644
--- a/OpenAL32/alListener.c
+++ b/OpenAL32/alListener.c
@@ -470,7 +470,7 @@ void UpdateListenerProps(ALCcontext *context)
struct ALlistenerProps *props;
/* Get an unused proprty container, or allocate a new one as needed. */
- props = ATOMIC_LOAD(&listener->FreeList, almemory_order_acquire);
+ props = ATOMIC_LOAD(&context->FreeListenerProps, almemory_order_acquire);
if(!props)
props = al_calloc(16, sizeof(*props));
else
@@ -478,7 +478,7 @@ void UpdateListenerProps(ALCcontext *context)
struct ALlistenerProps *next;
do {
next = ATOMIC_LOAD(&props->next, almemory_order_relaxed);
- } while(ATOMIC_COMPARE_EXCHANGE_PTR_WEAK(&listener->FreeList, &props, next,
+ } while(ATOMIC_COMPARE_EXCHANGE_PTR_WEAK(&context->FreeListenerProps, &props, next,
almemory_order_seq_cst, almemory_order_acquire) == 0);
}
@@ -507,6 +507,6 @@ void UpdateListenerProps(ALCcontext *context)
/* If there was an unused update container, put it back in the
* freelist.
*/
- ATOMIC_REPLACE_HEAD(struct ALlistenerProps*, &listener->FreeList, props);
+ ATOMIC_REPLACE_HEAD(struct ALlistenerProps*, &context->FreeListenerProps, props);
}
}
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index be191fdb..db698692 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -49,7 +49,7 @@ extern inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id);
static void InitSourceParams(ALsource *Source, ALsizei num_sends);
static void DeinitSource(ALsource *source, ALsizei num_sends);
-static void UpdateSourceProps(ALsource *source, ALvoice *voice, ALsizei num_sends);
+static void UpdateSourceProps(ALsource *source, ALvoice *voice, ALsizei num_sends, ALCcontext *context);
static ALint64 GetSourceSampleOffset(ALsource *Source, ALCcontext *context, ALuint64 *clocktime);
static ALdouble GetSourceSecOffset(ALsource *Source, ALCcontext *context, ALuint64 *clocktime);
static ALdouble GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context);
@@ -447,7 +447,7 @@ static ALint Int64ValsByProp(ALenum prop)
ALvoice *voice; \
if(SourceShouldUpdate(Source, Context) && \
(voice=GetSourceVoice(Source, Context)) != NULL) \
- UpdateSourceProps(Source, voice, device->NumAuxSends); \
+ UpdateSourceProps(Source, voice, device->NumAuxSends, Context); \
else \
ATOMIC_FLAG_CLEAR(&Source->PropsClean, almemory_order_release); \
} while(0)
@@ -948,7 +948,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p
* active source, in case the slot is about to be deleted.
*/
if((voice=GetSourceVoice(Source, Context)) != NULL)
- UpdateSourceProps(Source, voice, device->NumAuxSends);
+ UpdateSourceProps(Source, voice, device->NumAuxSends, Context);
else
ATOMIC_FLAG_CLEAR(&Source->PropsClean, almemory_order_release);
}
@@ -2528,7 +2528,7 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources)
ATOMIC_STORE(&voice->Playing, false, almemory_order_release);
ATOMIC_FLAG_TEST_AND_SET(&source->PropsClean, almemory_order_acquire);
- UpdateSourceProps(source, voice, device->NumAuxSends);
+ UpdateSourceProps(source, voice, device->NumAuxSends, context);
/* A source that's not playing or paused has any offset applied when it
* starts playing.
@@ -3061,13 +3061,13 @@ static void DeinitSource(ALsource *source, ALsizei num_sends)
}
}
-static void UpdateSourceProps(ALsource *source, ALvoice *voice, ALsizei num_sends)
+static void UpdateSourceProps(ALsource *source, ALvoice *voice, ALsizei num_sends, ALCcontext *context)
{
struct ALvoiceProps *props;
ALsizei i;
/* Get an unused property container, or allocate a new one as needed. */
- props = ATOMIC_LOAD(&voice->FreeList, almemory_order_acquire);
+ props = ATOMIC_LOAD(&context->FreeVoiceProps, almemory_order_acquire);
if(!props)
props = al_calloc(16, FAM_SIZE(struct ALvoiceProps, Send, num_sends));
else
@@ -3075,7 +3075,7 @@ static void UpdateSourceProps(ALsource *source, ALvoice *voice, ALsizei num_send
struct ALvoiceProps *next;
do {
next = ATOMIC_LOAD(&props->next, almemory_order_relaxed);
- } while(ATOMIC_COMPARE_EXCHANGE_PTR_WEAK(&voice->FreeList, &props, next,
+ } while(ATOMIC_COMPARE_EXCHANGE_PTR_WEAK(&context->FreeVoiceProps, &props, next,
almemory_order_acq_rel, almemory_order_acquire) == 0);
}
@@ -3145,7 +3145,7 @@ static void UpdateSourceProps(ALsource *source, ALvoice *voice, ALsizei num_send
/* If there was an unused update container, put it back in the
* freelist.
*/
- ATOMIC_REPLACE_HEAD(struct ALvoiceProps*, &voice->FreeList, props);
+ ATOMIC_REPLACE_HEAD(struct ALvoiceProps*, &context->FreeVoiceProps, props);
}
}
@@ -3159,7 +3159,7 @@ void UpdateAllSourceProps(ALCcontext *context)
ALvoice *voice = context->Voices[pos];
ALsource *source = ATOMIC_LOAD(&voice->Source, almemory_order_acquire);
if(source && !ATOMIC_FLAG_TEST_AND_SET(&source->PropsClean, almemory_order_acq_rel))
- UpdateSourceProps(source, voice, num_sends);
+ UpdateSourceProps(source, voice, num_sends, context);
}
}
diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c
index 14646043..a5565f87 100644
--- a/OpenAL32/alState.c
+++ b/OpenAL32/alState.c
@@ -786,7 +786,7 @@ void UpdateContextProps(ALCcontext *context)
struct ALcontextProps *props;
/* Get an unused proprty container, or allocate a new one as needed. */
- props = ATOMIC_LOAD(&context->FreeList, almemory_order_acquire);
+ props = ATOMIC_LOAD(&context->FreeContextProps, almemory_order_acquire);
if(!props)
props = al_calloc(16, sizeof(*props));
else
@@ -794,7 +794,7 @@ void UpdateContextProps(ALCcontext *context)
struct ALcontextProps *next;
do {
next = ATOMIC_LOAD(&props->next, almemory_order_relaxed);
- } while(ATOMIC_COMPARE_EXCHANGE_PTR_WEAK(&context->FreeList, &props, next,
+ } while(ATOMIC_COMPARE_EXCHANGE_PTR_WEAK(&context->FreeContextProps, &props, next,
almemory_order_seq_cst, almemory_order_acquire) == 0);
}
@@ -815,6 +815,6 @@ void UpdateContextProps(ALCcontext *context)
/* If there was an unused update container, put it back in the
* freelist.
*/
- ATOMIC_REPLACE_HEAD(struct ALcontextProps*, &context->FreeList, props);
+ ATOMIC_REPLACE_HEAD(struct ALcontextProps*, &context->FreeContextProps, props);
}
}