Update OpenAL Soft to commit 414b56edec5441211dc924fef365c54267c04f1c

This commit is contained in:
Alex Szpakowski
2018-04-03 20:46:26 -03:00
parent ac70ec9f6f
commit 5be7c968b8
138 changed files with 18084 additions and 18482 deletions
+208 -87
View File
@@ -50,8 +50,27 @@ static const ALchar alErrOutOfMemory[] = "Out of Memory";
/* Resampler strings */
static const ALchar alPointResampler[] = "Nearest";
static const ALchar alLinearResampler[] = "Linear";
static const ALchar alSinc4Resampler[] = "4-Point Sinc";
static const ALchar alBSincResampler[] = "Band-limited Sinc (12/24)";
static const ALchar alCubicResampler[] = "Cubic";
static const ALchar alBSinc12Resampler[] = "11th order Sinc";
static const ALchar alBSinc24Resampler[] = "23rd order Sinc";
/* WARNING: Non-standard export! Not part of any extension, or exposed in the
* alcFunctions list.
*/
AL_API const ALchar* AL_APIENTRY alsoft_get_version(void)
{
const char *spoof = getenv("ALSOFT_SPOOF_VERSION");
if(spoof && spoof[0] != '\0') return spoof;
return ALSOFT_VERSION;
}
#define DO_UPDATEPROPS() do { \
if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) \
UpdateContextProps(context); \
else \
ATOMIC_FLAG_CLEAR(&context->PropsClean, almemory_order_release); \
} while(0)
AL_API ALvoid AL_APIENTRY alEnable(ALenum capability)
{
@@ -60,21 +79,19 @@ AL_API ALvoid AL_APIENTRY alEnable(ALenum capability)
context = GetContextRef();
if(!context) return;
WriteLock(&context->PropLock);
almtx_lock(&context->PropLock);
switch(capability)
{
case AL_SOURCE_DISTANCE_MODEL:
context->SourceDistanceModel = AL_TRUE;
DO_UPDATEPROPS();
break;
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
alSetError(context, AL_INVALID_VALUE, "Invalid enable property 0x%04x", capability);
}
if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire))
UpdateListenerProps(context);
almtx_unlock(&context->PropLock);
done:
WriteUnlock(&context->PropLock);
ALCcontext_DecRef(context);
}
@@ -85,21 +102,19 @@ AL_API ALvoid AL_APIENTRY alDisable(ALenum capability)
context = GetContextRef();
if(!context) return;
WriteLock(&context->PropLock);
almtx_lock(&context->PropLock);
switch(capability)
{
case AL_SOURCE_DISTANCE_MODEL:
context->SourceDistanceModel = AL_FALSE;
DO_UPDATEPROPS();
break;
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
alSetError(context, AL_INVALID_VALUE, "Invalid disable property 0x%04x", capability);
}
if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire))
UpdateListenerProps(context);
almtx_unlock(&context->PropLock);
done:
WriteUnlock(&context->PropLock);
ALCcontext_DecRef(context);
}
@@ -111,6 +126,7 @@ AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability)
context = GetContextRef();
if(!context) return AL_FALSE;
almtx_lock(&context->PropLock);
switch(capability)
{
case AL_SOURCE_DISTANCE_MODEL:
@@ -118,12 +134,11 @@ AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability)
break;
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
alSetError(context, AL_INVALID_VALUE, "Invalid is enabled property 0x%04x", capability);
}
almtx_unlock(&context->PropLock);
done:
ALCcontext_DecRef(context);
return value;
}
@@ -135,6 +150,7 @@ AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum pname)
context = GetContextRef();
if(!context) return AL_FALSE;
almtx_lock(&context->PropLock);
switch(pname)
{
case AL_DOPPLER_FACTOR:
@@ -177,12 +193,11 @@ AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum pname)
break;
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
alSetError(context, AL_INVALID_VALUE, "Invalid boolean property 0x%04x", pname);
}
almtx_unlock(&context->PropLock);
done:
ALCcontext_DecRef(context);
return value;
}
@@ -194,6 +209,7 @@ AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname)
context = GetContextRef();
if(!context) return 0.0;
almtx_lock(&context->PropLock);
switch(pname)
{
case AL_DOPPLER_FACTOR:
@@ -230,12 +246,11 @@ AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname)
break;
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
alSetError(context, AL_INVALID_VALUE, "Invalid double property 0x%04x", pname);
}
almtx_unlock(&context->PropLock);
done:
ALCcontext_DecRef(context);
return value;
}
@@ -247,6 +262,7 @@ AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname)
context = GetContextRef();
if(!context) return 0.0f;
almtx_lock(&context->PropLock);
switch(pname)
{
case AL_DOPPLER_FACTOR:
@@ -283,12 +299,11 @@ AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname)
break;
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
alSetError(context, AL_INVALID_VALUE, "Invalid float property 0x%04x", pname);
}
almtx_unlock(&context->PropLock);
done:
ALCcontext_DecRef(context);
return value;
}
@@ -300,6 +315,7 @@ AL_API ALint AL_APIENTRY alGetInteger(ALenum pname)
context = GetContextRef();
if(!context) return 0;
almtx_lock(&context->PropLock);
switch(pname)
{
case AL_DOPPLER_FACTOR:
@@ -336,12 +352,11 @@ AL_API ALint AL_APIENTRY alGetInteger(ALenum pname)
break;
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
alSetError(context, AL_INVALID_VALUE, "Invalid integer property 0x%04x", pname);
}
almtx_unlock(&context->PropLock);
done:
ALCcontext_DecRef(context);
return value;
}
@@ -353,6 +368,7 @@ AL_API ALint64SOFT AL_APIENTRY alGetInteger64SOFT(ALenum pname)
context = GetContextRef();
if(!context) return 0;
almtx_lock(&context->PropLock);
switch(pname)
{
case AL_DOPPLER_FACTOR:
@@ -389,12 +405,39 @@ AL_API ALint64SOFT AL_APIENTRY alGetInteger64SOFT(ALenum pname)
break;
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
alSetError(context, AL_INVALID_VALUE, "Invalid integer64 property 0x%04x", pname);
}
almtx_unlock(&context->PropLock);
done:
ALCcontext_DecRef(context);
return value;
}
AL_API void* AL_APIENTRY alGetPointerSOFT(ALenum pname)
{
ALCcontext *context;
void *value = NULL;
context = GetContextRef();
if(!context) return NULL;
almtx_lock(&context->PropLock);
switch(pname)
{
case AL_EVENT_CALLBACK_FUNCTION_SOFT:
value = context->EventCb;
break;
case AL_EVENT_CALLBACK_USER_PARAM_SOFT:
value = context->EventParam;
break;
default:
alSetError(context, AL_INVALID_VALUE, "Invalid pointer property 0x%04x", pname);
}
almtx_unlock(&context->PropLock);
ALCcontext_DecRef(context);
return value;
}
@@ -422,15 +465,14 @@ AL_API ALvoid AL_APIENTRY alGetBooleanv(ALenum pname, ALboolean *values)
context = GetContextRef();
if(!context) return;
if(!(values))
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
if(!values)
alSetError(context, AL_INVALID_VALUE, "NULL pointer");
switch(pname)
{
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
alSetError(context, AL_INVALID_VALUE, "Invalid boolean-vector property 0x%04x", pname);
}
done:
ALCcontext_DecRef(context);
}
@@ -458,15 +500,14 @@ AL_API ALvoid AL_APIENTRY alGetDoublev(ALenum pname, ALdouble *values)
context = GetContextRef();
if(!context) return;
if(!(values))
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
if(!values)
alSetError(context, AL_INVALID_VALUE, "NULL pointer");
switch(pname)
{
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
alSetError(context, AL_INVALID_VALUE, "Invalid double-vector property 0x%04x", pname);
}
done:
ALCcontext_DecRef(context);
}
@@ -494,15 +535,14 @@ AL_API ALvoid AL_APIENTRY alGetFloatv(ALenum pname, ALfloat *values)
context = GetContextRef();
if(!context) return;
if(!(values))
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
if(!values)
alSetError(context, AL_INVALID_VALUE, "NULL pointer");
switch(pname)
{
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
alSetError(context, AL_INVALID_VALUE, "Invalid float-vector property 0x%04x", pname);
}
done:
ALCcontext_DecRef(context);
}
@@ -530,13 +570,14 @@ AL_API ALvoid AL_APIENTRY alGetIntegerv(ALenum pname, ALint *values)
context = GetContextRef();
if(!context) return;
if(!values)
alSetError(context, AL_INVALID_VALUE, "NULL pointer");
switch(pname)
{
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
alSetError(context, AL_INVALID_VALUE, "Invalid integer-vector property 0x%04x", pname);
}
done:
ALCcontext_DecRef(context);
}
@@ -564,13 +605,43 @@ AL_API void AL_APIENTRY alGetInteger64vSOFT(ALenum pname, ALint64SOFT *values)
context = GetContextRef();
if(!context) return;
if(!values)
alSetError(context, AL_INVALID_VALUE, "NULL pointer");
switch(pname)
{
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
alSetError(context, AL_INVALID_VALUE, "Invalid integer64-vector property 0x%04x", pname);
}
ALCcontext_DecRef(context);
}
AL_API void AL_APIENTRY alGetPointervSOFT(ALenum pname, void **values)
{
ALCcontext *context;
if(values)
{
switch(pname)
{
case AL_EVENT_CALLBACK_FUNCTION_SOFT:
case AL_EVENT_CALLBACK_USER_PARAM_SOFT:
values[0] = alGetPointerSOFT(pname);
return;
}
}
context = GetContextRef();
if(!context) return;
if(!values)
alSetError(context, AL_INVALID_VALUE, "NULL pointer");
switch(pname)
{
default:
alSetError(context, AL_INVALID_VALUE, "Invalid pointer-vector property 0x%04x", pname);
}
done:
ALCcontext_DecRef(context);
}
@@ -625,12 +696,10 @@ AL_API const ALchar* AL_APIENTRY alGetString(ALenum pname)
break;
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
alSetError(context, AL_INVALID_VALUE, "Invalid string property 0x%04x", pname);
}
done:
ALCcontext_DecRef(context);
return value;
}
@@ -642,15 +711,15 @@ AL_API ALvoid AL_APIENTRY alDopplerFactor(ALfloat value)
if(!context) return;
if(!(value >= 0.0f && isfinite(value)))
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
alSetError(context, AL_INVALID_VALUE, "Doppler factor %f out of range", value);
else
{
almtx_lock(&context->PropLock);
context->DopplerFactor = value;
DO_UPDATEPROPS();
almtx_unlock(&context->PropLock);
}
WriteLock(&context->PropLock);
context->DopplerFactor = value;
if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire))
UpdateListenerProps(context);
WriteUnlock(&context->PropLock);
done:
ALCcontext_DecRef(context);
}
@@ -661,16 +730,30 @@ AL_API ALvoid AL_APIENTRY alDopplerVelocity(ALfloat value)
context = GetContextRef();
if(!context) return;
if((ATOMIC_LOAD(&context->EnabledEvts, almemory_order_relaxed)&EventType_Deprecated))
{
static const ALCchar msg[] =
"alDopplerVelocity is deprecated in AL1.1, use alSpeedOfSound";
const ALsizei msglen = (ALsizei)strlen(msg);
ALbitfieldSOFT enabledevts;
almtx_lock(&context->EventCbLock);
enabledevts = ATOMIC_LOAD(&context->EnabledEvts, almemory_order_relaxed);
if((enabledevts&EventType_Deprecated) && context->EventCb)
(*context->EventCb)(AL_EVENT_TYPE_DEPRECATED_SOFT, 0, 0, msglen, msg,
context->EventParam);
almtx_unlock(&context->EventCbLock);
}
if(!(value >= 0.0f && isfinite(value)))
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
alSetError(context, AL_INVALID_VALUE, "Doppler velocity %f out of range", value);
else
{
almtx_lock(&context->PropLock);
context->DopplerVelocity = value;
DO_UPDATEPROPS();
almtx_unlock(&context->PropLock);
}
WriteLock(&context->PropLock);
context->DopplerVelocity = value;
if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire))
UpdateListenerProps(context);
WriteUnlock(&context->PropLock);
done:
ALCcontext_DecRef(context);
}
@@ -682,15 +765,15 @@ AL_API ALvoid AL_APIENTRY alSpeedOfSound(ALfloat value)
if(!context) return;
if(!(value > 0.0f && isfinite(value)))
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
alSetError(context, AL_INVALID_VALUE, "Speed of sound %f out of range", value);
else
{
almtx_lock(&context->PropLock);
context->SpeedOfSound = value;
DO_UPDATEPROPS();
almtx_unlock(&context->PropLock);
}
WriteLock(&context->PropLock);
context->SpeedOfSound = value;
if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire))
UpdateListenerProps(context);
WriteUnlock(&context->PropLock);
done:
ALCcontext_DecRef(context);
}
@@ -705,18 +788,16 @@ AL_API ALvoid AL_APIENTRY alDistanceModel(ALenum value)
value == AL_LINEAR_DISTANCE || value == AL_LINEAR_DISTANCE_CLAMPED ||
value == AL_EXPONENT_DISTANCE || value == AL_EXPONENT_DISTANCE_CLAMPED ||
value == AL_NONE))
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
WriteLock(&context->PropLock);
context->DistanceModel = value;
if(!context->SourceDistanceModel)
alSetError(context, AL_INVALID_VALUE, "Distance model 0x%04x out of range", value);
else
{
if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire))
UpdateListenerProps(context);
almtx_lock(&context->PropLock);
context->DistanceModel = value;
if(!context->SourceDistanceModel)
DO_UPDATEPROPS();
almtx_unlock(&context->PropLock);
}
WriteUnlock(&context->PropLock);
done:
ALCcontext_DecRef(context);
}
@@ -750,7 +831,8 @@ AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index)
{
const char *ResamplerNames[] = {
alPointResampler, alLinearResampler,
alSinc4Resampler, alBSincResampler,
alCubicResampler, alBSinc12Resampler,
alBSinc24Resampler,
};
const ALchar *value = NULL;
ALCcontext *context;
@@ -764,16 +846,55 @@ AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index)
{
case AL_RESAMPLER_NAME_SOFT:
if(index < 0 || (size_t)index >= COUNTOF(ResamplerNames))
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
SETERR_GOTO(context, AL_INVALID_VALUE, done, "Resampler name index %d out of range",
index);
value = ResamplerNames[index];
break;
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
alSetError(context, AL_INVALID_VALUE, "Invalid string indexed property");
}
done:
ALCcontext_DecRef(context);
return value;
}
void UpdateContextProps(ALCcontext *context)
{
struct ALcontextProps *props;
/* Get an unused proprty container, or allocate a new one as needed. */
props = ATOMIC_LOAD(&context->FreeContextProps, almemory_order_acquire);
if(!props)
props = al_calloc(16, sizeof(*props));
else
{
struct ALcontextProps *next;
do {
next = ATOMIC_LOAD(&props->next, almemory_order_relaxed);
} while(ATOMIC_COMPARE_EXCHANGE_PTR_WEAK(&context->FreeContextProps, &props, next,
almemory_order_seq_cst, almemory_order_acquire) == 0);
}
/* Copy in current property values. */
props->MetersPerUnit = context->MetersPerUnit;
props->DopplerFactor = context->DopplerFactor;
props->DopplerVelocity = context->DopplerVelocity;
props->SpeedOfSound = context->SpeedOfSound;
props->SourceDistanceModel = context->SourceDistanceModel;
props->DistanceModel = context->DistanceModel;
/* Set the new container for updating internal parameters. */
props = ATOMIC_EXCHANGE_PTR(&context->Update, props, almemory_order_acq_rel);
if(props)
{
/* If there was an unused update container, put it back in the
* freelist.
*/
ATOMIC_REPLACE_HEAD(struct ALcontextProps*, &context->FreeContextProps, props);
}
}