mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Move alext functions out of qal.h
Functions from extensions shouldn't be hardcoded, instead make them optional
This commit is contained in:
parent
50e3aa1f61
commit
382b6b3ade
3 changed files with 44 additions and 33 deletions
|
@ -88,9 +88,6 @@ LPALGETBUFFERI qalGetBufferi;
|
||||||
LPALDOPPLERFACTOR qalDopplerFactor;
|
LPALDOPPLERFACTOR qalDopplerFactor;
|
||||||
LPALSPEEDOFSOUND qalSpeedOfSound;
|
LPALSPEEDOFSOUND qalSpeedOfSound;
|
||||||
LPALDISTANCEMODEL qalDistanceModel;
|
LPALDISTANCEMODEL qalDistanceModel;
|
||||||
#ifdef AL_SOFT_source_resampler
|
|
||||||
LPALGETSTRINGISOFT qalGetStringiSOFT;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LPALCCREATECONTEXT qalcCreateContext;
|
LPALCCREATECONTEXT qalcCreateContext;
|
||||||
LPALCMAKECONTEXTCURRENT qalcMakeContextCurrent;
|
LPALCMAKECONTEXTCURRENT qalcMakeContextCurrent;
|
||||||
|
@ -212,9 +209,6 @@ qboolean QAL_Init(const char *libname)
|
||||||
qalDopplerFactor = GPA("alDopplerFactor");
|
qalDopplerFactor = GPA("alDopplerFactor");
|
||||||
qalSpeedOfSound = GPA("alSpeedOfSound");
|
qalSpeedOfSound = GPA("alSpeedOfSound");
|
||||||
qalDistanceModel = GPA("alDistanceModel");
|
qalDistanceModel = GPA("alDistanceModel");
|
||||||
#ifdef AL_SOFT_source_resampler
|
|
||||||
qalGetStringiSOFT = GPA("alGetStringiSOFT");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
qalcCreateContext = GPA("alcCreateContext");
|
qalcCreateContext = GPA("alcCreateContext");
|
||||||
qalcMakeContextCurrent = GPA("alcMakeContextCurrent");
|
qalcMakeContextCurrent = GPA("alcMakeContextCurrent");
|
||||||
|
|
|
@ -135,9 +135,6 @@ extern LPALGETBUFFERIV qalGetBufferiv;
|
||||||
extern LPALDOPPLERFACTOR qalDopplerFactor;
|
extern LPALDOPPLERFACTOR qalDopplerFactor;
|
||||||
extern LPALSPEEDOFSOUND qalSpeedOfSound;
|
extern LPALSPEEDOFSOUND qalSpeedOfSound;
|
||||||
extern LPALDISTANCEMODEL qalDistanceModel;
|
extern LPALDISTANCEMODEL qalDistanceModel;
|
||||||
#ifdef AL_SOFT_source_resampler
|
|
||||||
extern LPALGETSTRINGISOFT qalGetStringiSOFT;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern LPALCCREATECONTEXT qalcCreateContext;
|
extern LPALCCREATECONTEXT qalcCreateContext;
|
||||||
extern LPALCMAKECONTEXTCURRENT qalcMakeContextCurrent;
|
extern LPALCMAKECONTEXTCURRENT qalcMakeContextCurrent;
|
||||||
|
|
|
@ -128,6 +128,13 @@ static ALuint S_OPENAL_Format(float width, int channels);
|
||||||
# define ALDRIVER_DEFAULT "libopenal.so.1"
|
# define ALDRIVER_DEFAULT "libopenal.so.1"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// alext
|
||||||
|
//
|
||||||
|
#ifdef AL_SOFT_source_resampler
|
||||||
|
LPALGETSTRINGISOFT qalGetStringiSOFT;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==============
|
==============
|
||||||
__alDieIfError
|
__alDieIfError
|
||||||
|
@ -268,8 +275,6 @@ static bool S_OPENAL_InitContext()
|
||||||
{
|
{
|
||||||
const char *dev;
|
const char *dev;
|
||||||
int attrlist[10];
|
int attrlist[10];
|
||||||
size_t i;
|
|
||||||
size_t numResamplers;
|
|
||||||
|
|
||||||
Com_DPrintf("OpenAL: Context initialization\n");
|
Com_DPrintf("OpenAL: Context initialization\n");
|
||||||
|
|
||||||
|
@ -427,23 +432,6 @@ static bool S_OPENAL_InitContext()
|
||||||
qalcMakeContextCurrent(al_context_id);
|
qalcMakeContextCurrent(al_context_id);
|
||||||
alDieIfError();
|
alDieIfError();
|
||||||
|
|
||||||
#ifdef AL_SOFT_source_resampler
|
|
||||||
al_default_resampler_index = qalGetInteger(AL_DEFAULT_RESAMPLER_SOFT);
|
|
||||||
alDieIfError();
|
|
||||||
al_resampler_index = al_default_resampler_index;
|
|
||||||
numResamplers = qalGetInteger(AL_NUM_RESAMPLERS_SOFT);
|
|
||||||
alDieIfError();
|
|
||||||
|
|
||||||
for (i = 0; i < numResamplers; i++) {
|
|
||||||
const ALchar* resamplerName = qalGetStringiSOFT(AL_RESAMPLER_NAME_SOFT, i);
|
|
||||||
if (Q_stristr(resamplerName, "spline")) {
|
|
||||||
Com_Printf("OpenAL: Using %s as the resampler.\n", resamplerName);
|
|
||||||
al_resampler_index = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Com_Printf("AL_VENDOR: %s\n", qalGetString(AL_VENDOR));
|
Com_Printf("AL_VENDOR: %s\n", qalGetString(AL_VENDOR));
|
||||||
alDieIfError();
|
alDieIfError();
|
||||||
|
|
||||||
|
@ -472,11 +460,7 @@ S_OPENAL_InitExtensions
|
||||||
*/
|
*/
|
||||||
static bool S_OPENAL_InitExtensions()
|
static bool S_OPENAL_InitExtensions()
|
||||||
{
|
{
|
||||||
ima4_ext = qalIsExtensionPresent("AL_EXT_IMA4");
|
/*
|
||||||
soft_block_align = qalIsExtensionPresent("AL_SOFT_block_alignment");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
extensions_table_t extensions_table[4] = {
|
extensions_table_t extensions_table[4] = {
|
||||||
"alutLoadMP3_LOKI",
|
"alutLoadMP3_LOKI",
|
||||||
(void **)&_alutLoadMP3_LOKI,
|
(void **)&_alutLoadMP3_LOKI,
|
||||||
|
@ -488,6 +472,17 @@ static bool S_OPENAL_InitExtensions()
|
||||||
(void **)&_alReverbDelay_LOKI,
|
(void **)&_alReverbDelay_LOKI,
|
||||||
true
|
true
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
extensions_table_t extensions_table[] = {
|
||||||
|
#ifdef AL_SOFT_source_resampler
|
||||||
|
extensions_table_t {
|
||||||
|
"alGetStringiSOFT", (void **)&qalGetStringiSOFT,
|
||||||
|
false, },
|
||||||
|
#endif
|
||||||
|
extensions_table_t {NULL, NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
extensions_table_t *i;
|
extensions_table_t *i;
|
||||||
|
|
||||||
for (i = extensions_table; i->funcname; ++i) {
|
for (i = extensions_table; i->funcname; ++i) {
|
||||||
|
@ -510,6 +505,9 @@ static bool S_OPENAL_InitExtensions()
|
||||||
Com_Printf("...found.\n");
|
Com_Printf("...found.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ima4_ext = qalIsExtensionPresent("AL_EXT_IMA4");
|
||||||
|
soft_block_align = qalIsExtensionPresent("AL_SOFT_block_alignment");
|
||||||
|
|
||||||
qalGetError();
|
qalGetError();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -630,6 +628,28 @@ qboolean S_OPENAL_Init()
|
||||||
qalListenerf(AL_GAIN, al_current_volume);
|
qalListenerf(AL_GAIN, al_current_volume);
|
||||||
alDieIfError();
|
alDieIfError();
|
||||||
|
|
||||||
|
#ifdef AL_SOFT_source_resampler
|
||||||
|
if (qalGetStringiSOFT) {
|
||||||
|
size_t numResamplers;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
al_default_resampler_index = qalGetInteger(AL_DEFAULT_RESAMPLER_SOFT);
|
||||||
|
alDieIfError();
|
||||||
|
al_resampler_index = al_default_resampler_index;
|
||||||
|
numResamplers = qalGetInteger(AL_NUM_RESAMPLERS_SOFT);
|
||||||
|
alDieIfError();
|
||||||
|
|
||||||
|
for (i = 0; i < numResamplers; i++) {
|
||||||
|
const ALchar *resamplerName = qalGetStringiSOFT(AL_RESAMPLER_NAME_SOFT, i);
|
||||||
|
if (Q_stristr(resamplerName, "spline")) {
|
||||||
|
Com_Printf("OpenAL: Using %s as the resampler.\n", resamplerName);
|
||||||
|
al_resampler_index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < MAX_SOUNDSYSTEM_CHANNELS_3D; i++) {
|
for (i = 0; i < MAX_SOUNDSYSTEM_CHANNELS_3D; i++) {
|
||||||
if (!S_OPENAL_InitChannel(i, &openal.chan_3D[i])) {
|
if (!S_OPENAL_InitChannel(i, &openal.chan_3D[i])) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue