Add a method to enumerate resamplers
This commit is contained in:
parent
26b49c54af
commit
b59359f80f
@ -287,6 +287,8 @@ static const struct {
|
||||
DECL(alBufferSamplesSOFT),
|
||||
DECL(alGetBufferSamplesSOFT),
|
||||
DECL(alIsBufferFormatSupportedSOFT),
|
||||
|
||||
DECL(alGetStringiSOFT),
|
||||
};
|
||||
#undef DECL
|
||||
|
||||
@ -692,6 +694,11 @@ static const struct {
|
||||
DECL(AL_EQUALIZER_HIGH_CUTOFF),
|
||||
|
||||
DECL(AL_DEDICATED_GAIN),
|
||||
|
||||
DECL(AL_NUM_RESAMPLERS_SOFT),
|
||||
DECL(AL_DEFAULT_RESAMPLER_SOFT),
|
||||
DECL(AL_SOURCE_RESAMPLER_SOFT),
|
||||
DECL(AL_RESAMPLER_NAME_SOFT),
|
||||
};
|
||||
#undef DECL
|
||||
|
||||
|
@ -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"
|
||||
|
@ -45,6 +45,8 @@ enum Resampler {
|
||||
LinearResampler,
|
||||
FIR4Resampler,
|
||||
BSincResampler,
|
||||
|
||||
ResamplerMax = BSincResampler
|
||||
};
|
||||
extern enum Resampler ResamplerDefault;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user