diff options
author | Chris Robinson <[email protected]> | 2017-04-21 04:15:08 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-04-21 04:15:08 -0700 |
commit | b59359f80f45512210f37b8a8cd4c250d78dd37d (patch) | |
tree | 0a88f20ce7b0baa098991276f9b29271176a7bbe /OpenAL32 | |
parent | 26b49c54afb9868115e495098ce69f2d2487c932 (diff) |
Add a method to enumerate resamplers
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alMain.h | 13 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 2 | ||||
-rw-r--r-- | OpenAL32/alState.c | 90 |
3 files changed, 105 insertions, 0 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 34635773..7f5c0aa8 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -139,6 +139,19 @@ AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format); #endif #endif +#ifndef AL_SOFT_source_resampler +#define AL_SOFT_source_resampler +#define AL_NUM_RESAMPLERS_SOFT 0x7fff0000 +#define AL_DEFAULT_RESAMPLER_SOFT 0x7fff0001 +#define AL_SOURCE_RESAMPLER_SOFT 0x7fff0003 +#define AL_RESAMPLER_NAME_SOFT 0x7fff0004 + +typedef const ALchar* (AL_APIENTRY*LPALGETSTRINGISOFT)(ALenum pname, ALsizei index); +#ifdef AL_ALEXT_PROTOTYPES +AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index); +#endif +#endif + #if defined(_WIN64) #define SZFMT "%I64u" diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 071ef3d2..c6706bad 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -45,6 +45,8 @@ enum Resampler { LinearResampler, FIR4Resampler, BSincResampler, + + ResamplerMax = BSincResampler }; extern enum Resampler ResamplerDefault; diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c index eddd2999..231e2192 100644 --- a/OpenAL32/alState.c +++ b/OpenAL32/alState.c @@ -47,6 +47,12 @@ static const ALchar alErrInvalidValue[] = "Invalid Value"; static const ALchar alErrInvalidOp[] = "Invalid Operation"; static const ALchar alErrOutOfMemory[] = "Out of Memory"; +/* Resampler strings */ +static const ALchar alPointResampler[] = "Zero-Order Hold (Point)"; +static const ALchar alLinearResampler[] = "Linear"; +static const ALchar alSinc4Resampler[] = "4-Point Sinc"; +static const ALchar alBSincResampler[] = "Band-limited Sinc (12/24)"; + AL_API ALvoid AL_APIENTRY alEnable(ALenum capability) { ALCcontext *context; @@ -161,6 +167,15 @@ AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum pname) value = AL_TRUE; break; + case AL_NUM_RESAMPLERS_SOFT: + /* Always non-0. */ + value = AL_TRUE; + break; + + case AL_DEFAULT_RESAMPLER_SOFT: + value = ResamplerDefault ? AL_TRUE : AL_FALSE; + break; + default: SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } @@ -206,6 +221,14 @@ AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname) value = (ALdouble)GAIN_MIX_MAX/context->GainBoost; break; + case AL_NUM_RESAMPLERS_SOFT: + value = (ALdouble)(ResamplerMax + 1); + break; + + case AL_DEFAULT_RESAMPLER_SOFT: + value = (ALdouble)ResamplerDefault; + break; + default: SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } @@ -251,6 +274,14 @@ AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname) value = GAIN_MIX_MAX/context->GainBoost; break; + case AL_NUM_RESAMPLERS_SOFT: + value = (ALfloat)(ResamplerMax + 1); + break; + + case AL_DEFAULT_RESAMPLER_SOFT: + value = (ALfloat)ResamplerDefault; + break; + default: SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } @@ -296,6 +327,14 @@ AL_API ALint AL_APIENTRY alGetInteger(ALenum pname) value = (ALint)(GAIN_MIX_MAX/context->GainBoost); break; + case AL_NUM_RESAMPLERS_SOFT: + value = ResamplerMax + 1; + break; + + case AL_DEFAULT_RESAMPLER_SOFT: + value = ResamplerDefault; + break; + default: SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } @@ -341,6 +380,14 @@ AL_API ALint64SOFT AL_APIENTRY alGetInteger64SOFT(ALenum pname) value = (ALint64SOFT)(GAIN_MIX_MAX/context->GainBoost); break; + case AL_NUM_RESAMPLERS_SOFT: + value = (ALint64SOFT)(ResamplerMax + 1); + break; + + case AL_DEFAULT_RESAMPLER_SOFT: + value = (ALint64SOFT)ResamplerDefault; + break; + default: SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } @@ -365,6 +412,8 @@ AL_API ALvoid AL_APIENTRY alGetBooleanv(ALenum pname, ALboolean *values) case AL_SPEED_OF_SOUND: case AL_DEFERRED_UPDATES_SOFT: case AL_GAIN_LIMIT_SOFT: + case AL_NUM_RESAMPLERS_SOFT: + case AL_DEFAULT_RESAMPLER_SOFT: values[0] = alGetBoolean(pname); return; } @@ -399,6 +448,8 @@ AL_API ALvoid AL_APIENTRY alGetDoublev(ALenum pname, ALdouble *values) case AL_SPEED_OF_SOUND: case AL_DEFERRED_UPDATES_SOFT: case AL_GAIN_LIMIT_SOFT: + case AL_NUM_RESAMPLERS_SOFT: + case AL_DEFAULT_RESAMPLER_SOFT: values[0] = alGetDouble(pname); return; } @@ -433,6 +484,8 @@ AL_API ALvoid AL_APIENTRY alGetFloatv(ALenum pname, ALfloat *values) case AL_SPEED_OF_SOUND: case AL_DEFERRED_UPDATES_SOFT: case AL_GAIN_LIMIT_SOFT: + case AL_NUM_RESAMPLERS_SOFT: + case AL_DEFAULT_RESAMPLER_SOFT: values[0] = alGetFloat(pname); return; } @@ -467,6 +520,8 @@ AL_API ALvoid AL_APIENTRY alGetIntegerv(ALenum pname, ALint *values) case AL_SPEED_OF_SOUND: case AL_DEFERRED_UPDATES_SOFT: case AL_GAIN_LIMIT_SOFT: + case AL_NUM_RESAMPLERS_SOFT: + case AL_DEFAULT_RESAMPLER_SOFT: values[0] = alGetInteger(pname); return; } @@ -499,6 +554,8 @@ AL_API void AL_APIENTRY alGetInteger64vSOFT(ALenum pname, ALint64SOFT *values) case AL_SPEED_OF_SOUND: case AL_DEFERRED_UPDATES_SOFT: case AL_GAIN_LIMIT_SOFT: + case AL_NUM_RESAMPLERS_SOFT: + case AL_DEFAULT_RESAMPLER_SOFT: values[0] = alGetInteger64SOFT(pname); return; } @@ -687,3 +744,36 @@ AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void) ALCcontext_DecRef(context); } + + +AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index) +{ + const char *ResamplerNames[] = { + alPointResampler, alLinearResampler, + alSinc4Resampler, alBSincResampler, + }; + const ALchar *value = NULL; + ALCcontext *context; + + static_assert(COUNTOF(ResamplerNames) == ResamplerMax+1, "Incorrect ResamplerNames list"); + + context = GetContextRef(); + if(!context) return NULL; + + switch(pname) + { + case AL_RESAMPLER_NAME_SOFT: + if(index < 0 || (size_t)index >= COUNTOF(ResamplerNames)) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + value = ResamplerNames[index]; + break; + + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); + } + +done: + ALCcontext_DecRef(context); + + return value; +} |