aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-05-15 17:14:58 -0700
committerChris Robinson <[email protected]>2016-05-15 22:16:27 -0700
commit945fd022d6c9d612a5fae944d8cbef68927d8a92 (patch)
tree88a1fdfd2890c0f9f0ee4d3a541571177609f2bc /OpenAL32
parent63e98481eef0eb02dac14b889be80836a300eecc (diff)
Avoid separate updates to sources that should apply together
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h6
-rw-r--r--OpenAL32/Include/alu.h2
-rw-r--r--OpenAL32/alSource.c13
3 files changed, 18 insertions, 3 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index a624e078..f709e9bd 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -699,6 +699,12 @@ struct ALCcontext_struct {
RWLock PropLock;
+ /* Counter for the pre-mixing updates, in 31.1 fixed point (lowest bit
+ * indicates if updates are currently happening).
+ */
+ RefCount UpdateCount;
+ ATOMIC(ALenum) HoldUpdates;
+
struct ALvoice *Voices;
ALsizei VoiceCount;
ALsizei MaxVoices;
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 8e93dc6e..fc58bfb1 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -374,8 +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 UpdateContextSources(ALCcontext *context);
-
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);
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index e2d6ca4f..1124c9c3 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -2848,7 +2848,15 @@ void UpdateSourceProps(ALsource *source, ALuint num_sends)
void UpdateAllSourceProps(ALCcontext *context)
{
ALuint num_sends = context->Device->NumAuxSends;
+ uint updates;
ALsizei pos;
+
+ /* Tell the mixer to stop applying updates, then wait for any active
+ * updating to finish, before providing source updates.
+ */
+ ATOMIC_STORE(&context->HoldUpdates, AL_TRUE);
+ while(((updates=ReadRef(&context->UpdateCount))&1) != 0)
+ althrd_yield();
for(pos = 0;pos < context->VoiceCount;pos++)
{
ALvoice *voice = &context->Voices[pos];
@@ -2857,7 +2865,10 @@ void UpdateAllSourceProps(ALCcontext *context)
source->state == AL_PAUSED))
UpdateSourceProps(source, num_sends);
}
-
+ /* Now with all updates declared, let the mixer continue applying them so
+ * they all happen at once.
+ */
+ ATOMIC_STORE(&context->HoldUpdates, AL_FALSE);
}