From 4b153dade82b0558c96d54828bd2f9f86dc808fd Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 26 Aug 2016 19:46:46 -0700 Subject: Allow sources to play while alcSuspendContext is in effect This appears to be how Creative's Windows drivers handle it, and is necessary for at least the Windows version of UT2k4 (otherwise it tries to play a source while suspended, checks and sees it's stopped, then kills it before it's given a chance to start playing). Consequently, the internal properties it gets mixed with are determined by what the source properties are at the time of the play call, and the listener properties at the time of the suspend call. This does not change alDeferUpdatesSOFT, which will still hold the play state change until alProcessUpdatesSOFT. --- OpenAL32/Include/alMain.h | 8 +++++++- OpenAL32/alSource.c | 2 +- OpenAL32/alState.c | 17 +++++++++++------ 3 files changed, 19 insertions(+), 8 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index e0e1b835..74f967ae 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -772,7 +772,7 @@ void AppendCaptureDeviceList(const ALCchar *name); void ALCdevice_Lock(ALCdevice *device); void ALCdevice_Unlock(ALCdevice *device); -void ALCcontext_DeferUpdates(ALCcontext *context); +void ALCcontext_DeferUpdates(ALCcontext *context, ALenum type); void ALCcontext_ProcessUpdates(ALCcontext *context); inline void LockContext(ALCcontext *context) @@ -781,6 +781,12 @@ inline void LockContext(ALCcontext *context) inline void UnlockContext(ALCcontext *context) { ALCdevice_Unlock(context->Device); } +enum { + DeferOff = AL_FALSE, + DeferAll, + DeferAllowPlay +}; + typedef struct { #ifdef HAVE_FENV_H diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index f5941729..a7d7f35c 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -2316,7 +2316,7 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) context->MaxVoices = newcount; } - if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) + if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire) == DeferAll) { for(i = 0;i < n;i++) { diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c index fa3b190a..330d7fe2 100644 --- a/OpenAL32/alState.c +++ b/OpenAL32/alState.c @@ -150,7 +150,8 @@ AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum pname) break; case AL_DEFERRED_UPDATES_SOFT: - value = ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire); + if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire) == DeferAll) + value = AL_TRUE; break; default: @@ -190,7 +191,8 @@ AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname) break; case AL_DEFERRED_UPDATES_SOFT: - value = (ALdouble)ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire); + if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire) == DeferAll) + value = (ALdouble)AL_TRUE; break; default: @@ -230,7 +232,8 @@ AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname) break; case AL_DEFERRED_UPDATES_SOFT: - value = (ALfloat)ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire); + if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire) == DeferAll) + value = (ALfloat)AL_TRUE; break; default: @@ -270,7 +273,8 @@ AL_API ALint AL_APIENTRY alGetInteger(ALenum pname) break; case AL_DEFERRED_UPDATES_SOFT: - value = (ALint)ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire); + if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire) == DeferAll) + value = (ALint)AL_TRUE; break; default: @@ -310,7 +314,8 @@ AL_API ALint64SOFT AL_APIENTRY alGetInteger64SOFT(ALenum pname) break; case AL_DEFERRED_UPDATES_SOFT: - value = (ALint64SOFT)ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire); + if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire) == DeferAll) + value = (ALint64SOFT)AL_TRUE; break; default: @@ -638,7 +643,7 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void) context = GetContextRef(); if(!context) return; - ALCcontext_DeferUpdates(context); + ALCcontext_DeferUpdates(context, DeferAll); ALCcontext_DecRef(context); } -- cgit v1.2.3