diff options
-rw-r--r-- | Alc/ALc.c | 35 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 8 | ||||
-rw-r--r-- | OpenAL32/Include/alSource.h | 4 | ||||
-rw-r--r-- | OpenAL32/alSource.c | 48 | ||||
-rw-r--r-- | OpenAL32/alState.c | 12 |
5 files changed, 22 insertions, 85 deletions
@@ -1679,9 +1679,9 @@ extern inline ALint GetChannelIndex(const enum Channel names[MAX_OUTPUT_CHANNELS * does *NOT* stop mixing, but rather prevents certain property changes from * taking effect. */ -void ALCcontext_DeferUpdates(ALCcontext *context, ALenum type) +void ALCcontext_DeferUpdates(ALCcontext *context) { - ATOMIC_STORE_SEQ(&context->DeferUpdates, type); + ATOMIC_STORE_SEQ(&context->DeferUpdates, AL_TRUE); } /* ALCcontext_ProcessUpdates @@ -1690,13 +1690,9 @@ void ALCcontext_DeferUpdates(ALCcontext *context, ALenum type) */ void ALCcontext_ProcessUpdates(ALCcontext *context) { - ALCdevice *device = context->Device; - ReadLock(&context->PropLock); if(ATOMIC_EXCHANGE_SEQ(ALenum, &context->DeferUpdates, AL_FALSE)) { - ALsizei pos; - /* Tell the mixer to stop applying updates, then wait for any active * updating to finish, before providing updates. */ @@ -1706,31 +1702,6 @@ void ALCcontext_ProcessUpdates(ALCcontext *context) UpdateListenerProps(context); UpdateAllEffectSlotProps(context); - - LockUIntMapRead(&context->SourceMap); - V0(device->Backend,lock)(); - for(pos = 0;pos < context->VoiceCount;pos++) - { - ALvoice *voice = context->Voices[pos]; - ALsource *source = ATOMIC_LOAD(&voice->Source, almemory_order_acquire); - if(source && source->OffsetType != AL_NONE) - { - WriteLock(&source->queue_lock); - ApplyOffset(source, voice); - WriteUnlock(&source->queue_lock); - } - } - for(pos = 0;pos < context->SourceMap.size;pos++) - { - ALsource *source = context->SourceMap.values[pos]; - ALenum new_state = source->new_state; - source->new_state = AL_NONE; - if(new_state) - SetSourceState(source, context, new_state); - } - V0(device->Backend,unlock)(); - UnlockUIntMapRead(&context->SourceMap); - UpdateAllSourceProps(context); /* Now with all updates declared, let the mixer continue applying them @@ -2819,7 +2790,7 @@ ALC_API ALCvoid ALC_APIENTRY alcSuspendContext(ALCcontext *context) alcSetError(NULL, ALC_INVALID_CONTEXT); else { - ALCcontext_DeferUpdates(context, DeferAllowPlay); + ALCcontext_DeferUpdates(context); ALCcontext_DecRef(context); } } diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index ac89adf8..2182d3f0 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -879,15 +879,9 @@ void AppendCaptureDeviceList(const ALCchar *name); void ALCdevice_Lock(ALCdevice *device); void ALCdevice_Unlock(ALCdevice *device); -void ALCcontext_DeferUpdates(ALCcontext *context, ALenum type); +void ALCcontext_DeferUpdates(ALCcontext *context); void ALCcontext_ProcessUpdates(ALCcontext *context); -enum { - DeferOff = AL_FALSE, - DeferAll, - DeferAllowPlay -}; - typedef struct { #ifdef HAVE_FENV_H diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index 1dd835c4..284d5cbe 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -142,7 +142,6 @@ typedef struct ALsource { /** Source state (initial, playing, paused, or stopped) */ ATOMIC(ALenum) state; - ALenum new_state; /** Source Buffer Queue head. */ RWLock queue_lock; @@ -174,9 +173,6 @@ inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id) { return (struct ALsource*)RemoveUIntMapKeyNoLock(&context->SourceMap, id); } void UpdateAllSourceProps(ALCcontext *context); -ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state); -ALboolean ApplyOffset(ALsource *Source, ALvoice *voice); - ALvoid ReleaseALSources(ALCcontext *Context); diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index c4cdf16e..540821eb 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -54,6 +54,8 @@ static ALint64 GetSourceSampleOffset(ALsource *Source, ALCcontext *context, ALui static ALdouble GetSourceSecOffset(ALsource *Source, ALCcontext *context, ALuint64 *clocktime); static ALdouble GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context); static ALboolean GetSampleOffset(ALsource *Source, ALuint *offset, ALuint *frac); +static void SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state); +static ALboolean ApplyOffset(ALsource *Source, ALvoice *voice); typedef enum SourceProp { srcPitch = AL_PITCH, @@ -543,7 +545,7 @@ static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp p Source->OffsetType = prop; Source->Offset = *values; - if(SourceShouldUpdate(Source, Context)) + if(IsPlayingOrPaused(Source)) { ALvoice *voice; @@ -749,7 +751,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p Source->OffsetType = prop; Source->Offset = *values; - if(SourceShouldUpdate(Source, Context)) + if(IsPlayingOrPaused(Source)) { ALvoice *voice; @@ -2354,7 +2356,6 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) { source = LookupSource(context, sources[i]); ATOMIC_STORE(&source->state, AL_STOPPED, almemory_order_relaxed); - source->new_state = AL_NONE; } ALCdevice_Unlock(device); goto done; @@ -2371,21 +2372,10 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) AllocateVoices(context, newcount, device->NumAuxSends); } - if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire) == DeferAll) - { - for(i = 0;i < n;i++) - { - source = LookupSource(context, sources[i]); - source->new_state = AL_PLAYING; - } - } - else + for(i = 0;i < n;i++) { - for(i = 0;i < n;i++) - { - source = LookupSource(context, sources[i]); - SetSourceState(source, context, AL_PLAYING); - } + source = LookupSource(context, sources[i]); + SetSourceState(source, context, AL_PLAYING); } ALCdevice_Unlock(device); @@ -2417,21 +2407,10 @@ AL_API ALvoid AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources) } ALCdevice_Lock(context->Device); - if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) - { - for(i = 0;i < n;i++) - { - source = LookupSource(context, sources[i]); - source->new_state = AL_PAUSED; - } - } - else + for(i = 0;i < n;i++) { - for(i = 0;i < n;i++) - { - source = LookupSource(context, sources[i]); - SetSourceState(source, context, AL_PAUSED); - } + source = LookupSource(context, sources[i]); + SetSourceState(source, context, AL_PAUSED); } ALCdevice_Unlock(context->Device); @@ -2466,7 +2445,6 @@ AL_API ALvoid AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources) for(i = 0;i < n;i++) { source = LookupSource(context, sources[i]); - source->new_state = AL_NONE; SetSourceState(source, context, AL_STOPPED); } ALCdevice_Unlock(context->Device); @@ -2502,7 +2480,6 @@ AL_API ALvoid AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources) for(i = 0;i < n;i++) { source = LookupSource(context, sources[i]); - source->new_state = AL_NONE; SetSourceState(source, context, AL_INITIAL); } ALCdevice_Unlock(context->Device); @@ -2810,7 +2787,6 @@ static void InitSourceParams(ALsource *Source, ALsizei num_sends) Source->OffsetType = AL_NONE; Source->SourceType = AL_UNDETERMINED; ATOMIC_INIT(&Source->state, AL_INITIAL); - Source->new_state = AL_NONE; ATOMIC_INIT(&Source->queue, NULL); @@ -2979,7 +2955,7 @@ void UpdateAllSourceProps(ALCcontext *context) * * Sets the source's new play state given its current state. */ -ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state) +static void SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state) { ALCdevice *device = Context->Device; ALvoice *voice; @@ -3372,7 +3348,7 @@ static ALdouble GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *conte * Apply the stored playback offset to the Source. This function will update * the number of buffers "played" given the stored offset. */ -ALboolean ApplyOffset(ALsource *Source, ALvoice *voice) +static ALboolean ApplyOffset(ALsource *Source, ALvoice *voice) { ALbufferlistitem *BufferList; const ALbuffer *Buffer; diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c index e633a86b..eddd2999 100644 --- a/OpenAL32/alState.c +++ b/OpenAL32/alState.c @@ -152,7 +152,7 @@ AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum pname) break; case AL_DEFERRED_UPDATES_SOFT: - if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire) == DeferAll) + if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) value = AL_TRUE; break; @@ -198,7 +198,7 @@ AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname) break; case AL_DEFERRED_UPDATES_SOFT: - if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire) == DeferAll) + if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) value = (ALdouble)AL_TRUE; break; @@ -243,7 +243,7 @@ AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname) break; case AL_DEFERRED_UPDATES_SOFT: - if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire) == DeferAll) + if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) value = (ALfloat)AL_TRUE; break; @@ -288,7 +288,7 @@ AL_API ALint AL_APIENTRY alGetInteger(ALenum pname) break; case AL_DEFERRED_UPDATES_SOFT: - if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire) == DeferAll) + if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) value = (ALint)AL_TRUE; break; @@ -333,7 +333,7 @@ AL_API ALint64SOFT AL_APIENTRY alGetInteger64SOFT(ALenum pname) break; case AL_DEFERRED_UPDATES_SOFT: - if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire) == DeferAll) + if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) value = (ALint64SOFT)AL_TRUE; break; @@ -671,7 +671,7 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void) context = GetContextRef(); if(!context) return; - ALCcontext_DeferUpdates(context, DeferAll); + ALCcontext_DeferUpdates(context); ALCcontext_DecRef(context); } |