aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-05-16 14:46:06 -0700
committerChris Robinson <[email protected]>2016-05-16 14:46:06 -0700
commit56c6b3f56cfd300ce62b6dc932a241ac619cb086 (patch)
tree56a6ab88fbc2b45be787e59c5ecb44e689278bca
parent945fd022d6c9d612a5fae944d8cbef68927d8a92 (diff)
Don't store the source's update method with the voice
-rw-r--r--Alc/ALu.c80
-rw-r--r--OpenAL32/Include/alSource.h3
-rw-r--r--OpenAL32/Include/alu.h3
-rw-r--r--OpenAL32/alSource.c4
4 files changed, 42 insertions, 48 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 34c36d5b..4fb9d8e5 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -129,7 +129,7 @@ static inline ALfloat aluDotproduct(const aluVector *vec1, const aluVector *vec2
return vec1->v[0]*vec2->v[0] + vec1->v[1]*vec2->v[1] + vec1->v[2]*vec2->v[2];
}
-static inline ALfloat aluNormalize(ALfloat *vec)
+static ALfloat aluNormalize(ALfloat *vec)
{
ALfloat length = sqrtf(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]);
if(length > 0.0f)
@@ -163,7 +163,7 @@ static inline ALdouble aluNormalized(ALdouble *vec)
return length;
}
-static inline ALvoid aluMatrixdFloat3(ALfloat *vec, ALfloat w, const aluMatrixd *mtx)
+static void aluMatrixdFloat3(ALfloat *vec, ALfloat w, const aluMatrixd *mtx)
{
ALdouble v[4] = { vec[0], vec[1], vec[2], w };
@@ -181,7 +181,7 @@ static inline ALvoid aluMatrixdDouble3(ALdouble *vec, ALdouble w, const aluMatri
vec[2] = v[0]*mtx->m[0][2] + v[1]*mtx->m[1][2] + v[2]*mtx->m[2][2] + v[3]*mtx->m[3][2];
}
-static inline aluVector aluMatrixdVector(const aluMatrixd *mtx, const aluVector *vec)
+static aluVector aluMatrixdVector(const aluMatrixd *mtx, const aluVector *vec)
{
aluVector v;
v.v[0] = (ALfloat)(vec->v[0]*mtx->m[0][0] + vec->v[1]*mtx->m[1][0] + vec->v[2]*mtx->m[2][0] + vec->v[3]*mtx->m[3][0]);
@@ -381,41 +381,8 @@ static void CalcEffectSlotParams(ALeffectslot *slot, ALCdevice *device)
&slot->FreeList, &first, props) == 0);
}
-static void CalcSourceParams(ALvoice *voice, ALCcontext *context)
-{
- ALsource *source = voice->Source;
- ALbufferlistitem *BufferListItem;
- struct ALsourceProps *first;
- struct ALsourceProps *props;
-
- props = ATOMIC_EXCHANGE(struct ALsourceProps*, &source->Update, NULL, almemory_order_acq_rel);
- if(!props) return;
- BufferListItem = ATOMIC_LOAD(&source->queue, almemory_order_relaxed);
- while(BufferListItem != NULL)
- {
- ALbuffer *buffer;
- if((buffer=BufferListItem->buffer) != NULL)
- {
- voice->Update(voice, props, buffer, context);
- break;
- }
- BufferListItem = BufferListItem->next;
- }
-
- /* WARNING: A livelock is theoretically possible if another thread keeps
- * changing the freelist head without giving this a chance to actually swap
- * in the old container (practically impossible with this little code,
- * but...).
- */
- first = ATOMIC_LOAD(&source->FreeList);
- do {
- ATOMIC_STORE(&props->next, first, almemory_order_relaxed);
- } while(ATOMIC_COMPARE_EXCHANGE_WEAK(struct ALsourceProps*,
- &source->FreeList, &first, props) == 0);
-}
-
-ALvoid CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *props, const ALbuffer *ALBuffer, const ALCcontext *ALContext)
+static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *props, const ALbuffer *ALBuffer, const ALCcontext *ALContext)
{
static const struct ChanMap MonoMap[1] = {
{ FrontCenter, 0.0f, 0.0f }
@@ -859,7 +826,7 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *props
}
}
-ALvoid CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *props, const ALbuffer *ALBuffer, const ALCcontext *ALContext)
+static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *props, const ALbuffer *ALBuffer, const ALCcontext *ALContext)
{
const ALCdevice *Device = ALContext->Device;
const ALlistener *Listener = ALContext->Listener;
@@ -1338,6 +1305,43 @@ ALvoid CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *props, c
}
}
+static void CalcSourceParams(ALvoice *voice, ALCcontext *context)
+{
+ ALsource *source = voice->Source;
+ ALbufferlistitem *BufferListItem;
+ struct ALsourceProps *first;
+ struct ALsourceProps *props;
+
+ props = ATOMIC_EXCHANGE(struct ALsourceProps*, &source->Update, NULL, almemory_order_acq_rel);
+ if(!props) return;
+
+ BufferListItem = ATOMIC_LOAD(&source->queue, almemory_order_relaxed);
+ while(BufferListItem != NULL)
+ {
+ ALbuffer *buffer;
+ if((buffer=BufferListItem->buffer) != NULL)
+ {
+ if(buffer->FmtChannels == FmtMono)
+ CalcAttnSourceParams(voice, props, buffer, context);
+ else
+ CalcNonAttnSourceParams(voice, props, buffer, context);
+ break;
+ }
+ BufferListItem = BufferListItem->next;
+ }
+
+ /* WARNING: A livelock is theoretically possible if another thread keeps
+ * changing the freelist head without giving this a chance to actually swap
+ * in the old container (practically impossible with this little code,
+ * but...).
+ */
+ first = ATOMIC_LOAD(&source->FreeList);
+ do {
+ ATOMIC_STORE(&props->next, first, almemory_order_relaxed);
+ } while(ATOMIC_COMPARE_EXCHANGE_WEAK(struct ALsourceProps*,
+ &source->FreeList, &first, props) == 0);
+}
+
static void UpdateContextSources(ALCcontext *ctx)
{
diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h
index 6d915153..4a15cea1 100644
--- a/OpenAL32/Include/alSource.h
+++ b/OpenAL32/Include/alSource.h
@@ -25,9 +25,6 @@ typedef struct ALbufferlistitem {
typedef struct ALvoice {
struct ALsource *volatile Source;
- /** Method to update mixing parameters. */
- ALvoid (*Update)(struct ALvoice *self, const struct ALsourceProps *props, const struct ALbuffer *ALBuffer, const ALCcontext *context);
-
/** Current target parameters used for mixing. */
ALint Step;
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index fc58bfb1..c70c8cff 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -374,9 +374,6 @@ void ComputeFirstOrderGainsMC(const ChannelConfig *chancoeffs, ALuint numchans,
void ComputeFirstOrderGainsBF(const BFChannelConfig *chanmap, ALuint numchans, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
-ALvoid CalcAttnSourceParams(struct ALvoice *voice, const struct ALsourceProps *props, const struct ALbuffer *buffer, const ALCcontext *ALContext);
-ALvoid CalcNonAttnSourceParams(struct ALvoice *voice, const struct ALsourceProps *props, const struct ALbuffer *buffer, const ALCcontext *ALContext);
-
ALvoid MixSource(struct ALvoice *voice, struct ALsource *source, ALCdevice *Device, ALuint SamplesToDo);
ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size);
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index 1124c9c3..090b4659 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -2965,10 +2965,6 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
}
}
- if(BufferList->buffer->FmtChannels == FmtMono)
- voice->Update = CalcAttnSourceParams;
- else
- voice->Update = CalcNonAttnSourceParams;
UpdateSourceProps(Source, device->NumAuxSends);
}
else if(state == AL_PAUSED)