aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h4
-rw-r--r--OpenAL32/alState.c19
2 files changed, 14 insertions, 9 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index b0a33114..a9f5813d 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -571,6 +571,9 @@ struct ALCcontext_struct
ALCcontext *next;
};
+void ALCcontext_IncRef(ALCcontext *context);
+void ALCcontext_DecRef(ALCcontext *context);
+
void AppendDeviceList(const ALCchar *name);
void AppendAllDeviceList(const ALCchar *name);
void AppendCaptureDeviceList(const ALCchar *name);
@@ -586,6 +589,7 @@ ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr);
ALuint StopThread(ALvoid *thread);
ALCcontext *GetLockedContext(void);
+ALCcontext *GetReffedContext(void);
typedef struct RingBuffer RingBuffer;
RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length);
diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c
index 7e73f407..a65eaa82 100644
--- a/OpenAL32/alState.c
+++ b/OpenAL32/alState.c
@@ -577,7 +577,7 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
{
ALCcontext *Context;
- Context = GetLockedContext();
+ Context = GetReffedContext();
if(!Context) return;
if(!Context->DeferUpdates)
@@ -587,11 +587,11 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
ALeffectslot *ALEffectSlot;
ALsizei e;
+ LockContext(Context);
Context->DeferUpdates = AL_TRUE;
/* Make sure all pending updates are performed */
- UpdateSources = Context->UpdateSources;
- Context->UpdateSources = AL_FALSE;
+ UpdateSources = Exchange_ALenum(&Context->UpdateSources, AL_FALSE);
src = Context->ActiveSources;
src_end = src + Context->ActiveSourceCount;
@@ -616,24 +616,24 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
if(Exchange_ALenum(&ALEffectSlot->NeedsUpdate, AL_FALSE))
ALEffect_Update(ALEffectSlot->EffectState, Context, ALEffectSlot);
}
+ UnlockContext(Context);
}
- UnlockContext(Context);
+ ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void)
{
ALCcontext *Context;
- Context = GetLockedContext();
+ Context = GetReffedContext();
if(!Context) return;
- if(Context->DeferUpdates)
+ if(Exchange_ALenum(&Context->DeferUpdates, AL_FALSE))
{
ALsizei pos;
- Context->DeferUpdates = AL_FALSE;
-
+ LockContext(Context);
for(pos = 0;pos < Context->SourceMap.size;pos++)
{
ALsource *Source = Context->SourceMap.array[pos].value;
@@ -647,7 +647,8 @@ AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void)
if(new_state)
SetSourceState(Source, Context, new_state);
}
+ UnlockContext(Context);
}
- UnlockContext(Context);
+ ALCcontext_DecRef(Context);
}