mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2025-01-06 00:40:43 +00:00
don't modify s_alDevice and add fallback to let openAL choose the device
This commit is contained in:
parent
de19303320
commit
b35c63f37a
1 changed files with 15 additions and 24 deletions
|
@ -1715,7 +1715,6 @@ static cvar_t *s_alCapture;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define ALDRIVER_DEFAULT "OpenAL32.dll"
|
#define ALDRIVER_DEFAULT "OpenAL32.dll"
|
||||||
#define ALDEVICE_DEFAULT "Generic Software"
|
|
||||||
#elif defined(MACOS_X)
|
#elif defined(MACOS_X)
|
||||||
#define ALDRIVER_DEFAULT "/System/Library/Frameworks/OpenAL.framework/OpenAL"
|
#define ALDRIVER_DEFAULT "/System/Library/Frameworks/OpenAL.framework/OpenAL"
|
||||||
#else
|
#else
|
||||||
|
@ -1965,8 +1964,7 @@ S_AL_Init
|
||||||
qboolean S_AL_Init( soundInterface_t *si )
|
qboolean S_AL_Init( soundInterface_t *si )
|
||||||
{
|
{
|
||||||
#ifdef USE_OPENAL
|
#ifdef USE_OPENAL
|
||||||
|
const char* device = NULL;
|
||||||
qboolean enumsupport, founddev = qfalse;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if( !si ) {
|
if( !si ) {
|
||||||
|
@ -1992,6 +1990,8 @@ qboolean S_AL_Init( soundInterface_t *si )
|
||||||
|
|
||||||
s_alDriver = Cvar_Get( "s_alDriver", ALDRIVER_DEFAULT, CVAR_ARCHIVE | CVAR_LATCH );
|
s_alDriver = Cvar_Get( "s_alDriver", ALDRIVER_DEFAULT, CVAR_ARCHIVE | CVAR_LATCH );
|
||||||
|
|
||||||
|
s_alDevice = Cvar_Get("s_alDevice", "", CVAR_ARCHIVE | CVAR_LATCH);
|
||||||
|
|
||||||
// Load QAL
|
// Load QAL
|
||||||
if( !QAL_Init( s_alDriver->string ) )
|
if( !QAL_Init( s_alDriver->string ) )
|
||||||
{
|
{
|
||||||
|
@ -1999,8 +1999,12 @@ qboolean S_AL_Init( soundInterface_t *si )
|
||||||
return qfalse;
|
return qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device = s_alDevice->string;
|
||||||
|
if(device && !*device)
|
||||||
|
device = NULL;
|
||||||
|
|
||||||
// Device enumeration support (extension is implemented reasonably only on Windows right now).
|
// Device enumeration support (extension is implemented reasonably only on Windows right now).
|
||||||
if((enumsupport = qalcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")))
|
if(qalcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT"))
|
||||||
{
|
{
|
||||||
char devicenames[1024] = "";
|
char devicenames[1024] = "";
|
||||||
const char *devicelist;
|
const char *devicelist;
|
||||||
|
@ -2016,11 +2020,9 @@ qboolean S_AL_Init( soundInterface_t *si )
|
||||||
// Generic Software as that one works more reliably with various sound systems.
|
// Generic Software as that one works more reliably with various sound systems.
|
||||||
// If it's not, use OpenAL's default selection as we don't want to ignore
|
// If it's not, use OpenAL's default selection as we don't want to ignore
|
||||||
// native hardware acceleration.
|
// native hardware acceleration.
|
||||||
if(!strcmp(defaultdevice, "Generic Hardware"))
|
if(!device && !strcmp(defaultdevice, "Generic Hardware"))
|
||||||
s_alDevice = Cvar_Get("s_alDevice", ALDEVICE_DEFAULT, CVAR_ARCHIVE | CVAR_LATCH);
|
device = "Generic Software";
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
s_alDevice = Cvar_Get("s_alDevice", defaultdevice, CVAR_ARCHIVE | CVAR_LATCH);
|
|
||||||
|
|
||||||
// dump a list of available devices to a cvar for the user to see.
|
// dump a list of available devices to a cvar for the user to see.
|
||||||
while((curlen = strlen(devicelist)))
|
while((curlen = strlen(devicelist)))
|
||||||
|
@ -2028,26 +2030,18 @@ qboolean S_AL_Init( soundInterface_t *si )
|
||||||
Q_strcat(devicenames, sizeof(devicenames), devicelist);
|
Q_strcat(devicenames, sizeof(devicenames), devicelist);
|
||||||
Q_strcat(devicenames, sizeof(devicenames), "\n");
|
Q_strcat(devicenames, sizeof(devicenames), "\n");
|
||||||
|
|
||||||
// check whether the device we want to load is available at all.
|
|
||||||
if(!strcmp(s_alDevice->string, devicelist))
|
|
||||||
founddev = qtrue;
|
|
||||||
|
|
||||||
devicelist += curlen + 1;
|
devicelist += curlen + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_alAvailableDevices = Cvar_Get("s_alAvailableDevices", devicenames, CVAR_ROM | CVAR_NORESTART);
|
s_alAvailableDevices = Cvar_Get("s_alAvailableDevices", devicenames, CVAR_ROM | CVAR_NORESTART);
|
||||||
|
}
|
||||||
|
|
||||||
if(!founddev)
|
alDevice = qalcOpenDevice(device);
|
||||||
|
if( !alDevice && device )
|
||||||
{
|
{
|
||||||
Cvar_ForceReset("s_alDevice");
|
Com_Printf( "Failed to open OpenAL device '%s', trying default.\n", device );
|
||||||
founddev = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(founddev)
|
|
||||||
alDevice = qalcOpenDevice(s_alDevice->string);
|
|
||||||
else
|
|
||||||
alDevice = qalcOpenDevice(NULL);
|
alDevice = qalcOpenDevice(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if( !alDevice )
|
if( !alDevice )
|
||||||
{
|
{
|
||||||
|
@ -2056,9 +2050,6 @@ qboolean S_AL_Init( soundInterface_t *si )
|
||||||
return qfalse;
|
return qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(enumsupport)
|
|
||||||
Cvar_Set("s_alDevice", qalcGetString(alDevice, ALC_DEVICE_SPECIFIER));
|
|
||||||
|
|
||||||
// Create OpenAL context
|
// Create OpenAL context
|
||||||
alContext = qalcCreateContext( alDevice, NULL );
|
alContext = qalcCreateContext( alDevice, NULL );
|
||||||
if( !alContext )
|
if( !alContext )
|
||||||
|
|
Loading…
Reference in a new issue