diff options
author | thilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2006-08-19 11:02:20 +0000 |
---|---|---|
committer | thilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2006-08-19 11:02:20 +0000 |
commit | 26c463829c60e871818d8e3347c9d6aa3e7274c8 (patch) | |
tree | 5d325d101004961f152a57cf18c759ff2adf29bc | |
parent | 65326c8f5fc9e3780f68b7ec47c835cc09899c3c (diff) | |
download | ioquake3-aero-26c463829c60e871818d8e3347c9d6aa3e7274c8.tar.gz ioquake3-aero-26c463829c60e871818d8e3347c9d6aa3e7274c8.zip |
- Add device enumeration support on windows and make "Generic Software" new default device as that one seems to work more reliably on many platforms.
- Add shfolder.lib library to dependencies in MSVC project files
- update documentation for OpenAL changes.
git-svn-id: svn://svn.icculus.org/quake3/trunk@853 edf5b092-35ff-0310-97b2-ce42778d08ea
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | code/client/snd_openal.c | 75 | ||||
-rw-r--r-- | code/qcommon/cvar.c | 9 | ||||
-rw-r--r-- | code/qcommon/qcommon.h | 1 | ||||
-rw-r--r-- | code/win32/msvc/quake3.vcproj | 14 |
5 files changed, 94 insertions, 7 deletions
@@ -118,6 +118,8 @@ New cvars s_alMaxSpeakerDistance - ET_SPEAKERS beyond this distance are culled s_alDriver - which OpenAL library to use + s_alDevice - which OpenAL device to use + s_alAvailableDevices - list of available OpenAL devices s_sdlBits - SDL bit resolution s_sdlSpeed - SDL sample rate diff --git a/code/client/snd_openal.c b/code/client/snd_openal.c index d4ad7f4..fc7a31a 100644 --- a/code/client/snd_openal.c +++ b/code/client/snd_openal.c @@ -38,6 +38,10 @@ cvar_t *s_alDopplerSpeed; cvar_t *s_alMinDistance; cvar_t *s_alRolloff; cvar_t *s_alDriver; +#ifdef _WIN32 +cvar_t *s_alDevice; +cvar_t *s_alAvailableDevices; +#endif cvar_t *s_alMaxSpeakerDistance; /* @@ -1525,6 +1529,7 @@ static ALCcontext *alContext; #ifdef _WIN32 #define ALDRIVER_DEFAULT "OpenAL32.dll" +#define ALDEVICE_DEFAULT "Generic Software" #elif defined(MACOS_X) #define ALDRIVER_DEFAULT "/System/Library/Frameworks/OpenAL.framework/OpenAL" #else @@ -1672,6 +1677,10 @@ void S_AL_SoundInfo( void ) Com_Printf( " Vendor: %s\n", qalGetString( AL_VENDOR ) ); Com_Printf( " Version: %s\n", qalGetString( AL_VERSION ) ); Com_Printf( " Renderer: %s\n", qalGetString( AL_RENDERER ) ); +#ifdef _WIN32 + if(qalcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) + Com_Printf( " Device: %s\n", qalcGetString(alDevice, ALC_DEVICE_SPECIFIER) ); +#endif Com_Printf( " Extensions: %s\n", qalGetString( AL_EXTENSIONS ) ); } @@ -1713,6 +1722,11 @@ S_AL_Init qboolean S_AL_Init( soundInterface_t *si ) { #if USE_OPENAL + +#ifdef _WIN32 + qboolean enumsupport, founddev = qfalse; +#endif + if( !si ) { return qfalse; } @@ -1736,8 +1750,64 @@ qboolean S_AL_Init( soundInterface_t *si ) return qfalse; } +#ifdef _WIN32 + // Device enumeration support on windows. + if((enumsupport = qalcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT"))) + { + char *devicelist, devicenames[8192] = ""; + char *defaultdevice; + int curlen; + qboolean hasbegun = qfalse; + + // get all available devices + the default device name. + devicelist = qalcGetString(NULL, ALC_DEVICE_SPECIFIER); + defaultdevice = qalcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); + + // check whether the default device is generic hardware. If it is, change to + // 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 + // native hardware acceleration. + if(!strcmp(defaultdevice, "Generic Hardware")) + s_alDevice = Cvar_Get("s_alDevice", ALDEVICE_DEFAULT, CVAR_ARCHIVE | CVAR_LATCH); + else + 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. + while((curlen = strlen(devicelist))) + { + if(hasbegun) + Q_strcat(devicenames, sizeof(devicenames), ", "); + + Q_strcat(devicenames, sizeof(devicenames), devicelist); + hasbegun = qtrue; + + // check whether the device we want to load is available at all. + if(!strcmp(s_alDevice->string, devicelist)) + founddev = qtrue; + + s_alDevice->string; + devicelist += curlen + 1; + } + + s_alAvailableDevices = Cvar_Get("s_alAvailableDevices", devicenames, CVAR_ROM | CVAR_NORESTART); + + if(!founddev) + { + Cvar_ForceReset("s_alDevice"); + founddev = 1; + } + } + + if(founddev) + alDevice = qalcOpenDevice(s_alDevice->string); + else + alDevice = qalcOpenDevice(NULL); +#else // _WIN32 + // Open default device alDevice = qalcOpenDevice( NULL ); +#endif + if( !alDevice ) { QAL_Shutdown( ); @@ -1745,6 +1815,11 @@ qboolean S_AL_Init( soundInterface_t *si ) return qfalse; } +#ifdef _WIN32 + if(enumsupport) + Cvar_Set("s_alDevice", qalcGetString(alDevice, ALC_DEVICE_SPECIFIER)); +#endif + // Create OpenAL context alContext = qalcCreateContext( alDevice, NULL ); if( !alContext ) diff --git a/code/qcommon/cvar.c b/code/qcommon/cvar.c index d9f9e71..e812a83 100644 --- a/code/qcommon/cvar.c +++ b/code/qcommon/cvar.c @@ -451,6 +451,15 @@ void Cvar_Reset( const char *var_name ) { Cvar_Set2( var_name, NULL, qfalse ); } +/* +============ +Cvar_ForceReset +============ +*/ +void Cvar_ForceReset(const char *var_name) +{ + Cvar_Set2(var_name, NULL, qtrue); +} /* ============ diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index 1069434..3c53ae0 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -487,6 +487,7 @@ void Cvar_CommandCompletion( void(*callback)(const char *s) ); // callback with each valid string void Cvar_Reset( const char *var_name ); +void Cvar_ForceReset(const char *var_name); void Cvar_SetCheatState( void ); // reset all testing vars to a safe value diff --git a/code/win32/msvc/quake3.vcproj b/code/win32/msvc/quake3.vcproj index 2234278..449293f 100644 --- a/code/win32/msvc/quake3.vcproj +++ b/code/win32/msvc/quake3.vcproj @@ -37,7 +37,7 @@ Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="winmm.lib wsock32.lib openal32.lib"
+ AdditionalDependencies="winmm.lib wsock32.lib openal32.lib shfolder.lib"
OutputFile="$(OutDir)\ioquake3.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
@@ -105,7 +105,7 @@ Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="winmm.lib wsock32.lib openal32.lib"
+ AdditionalDependencies="winmm.lib wsock32.lib openal32.lib shfolder.lib"
OutputFile="$(OutDir)\ioquake3.exe"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
@@ -176,7 +176,7 @@ Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="winmm.lib wsock32.lib"
+ AdditionalDependencies="winmm.lib wsock32.lib openal32.lib shfolder.lib"
OutputFile="$(OutDir)\ioquake3.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
@@ -243,7 +243,7 @@ Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="winmm.lib wsock32.lib openal32.lib"
+ AdditionalDependencies="winmm.lib wsock32.lib openal32.lib shfolder.lib"
OutputFile="$(OutDir)\ioquake3.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
@@ -310,7 +310,7 @@ Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="winmm.lib wsock32.lib"
+ AdditionalDependencies="winmm.lib wsock32.lib openal32.lib shfolder.lib"
OutputFile="$(OutDir)\ioquake3.exe"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
@@ -380,7 +380,7 @@ Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="winmm.lib wsock32.lib"
+ AdditionalDependencies="winmm.lib wsock32.lib openal32.lib shfolder.lib"
OutputFile="$(OutDir)\ioquake3.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
@@ -447,7 +447,7 @@ Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="winmm.lib wsock32.lib openal32.lib"
+ AdditionalDependencies="winmm.lib wsock32.lib openal32.lib shfolder.lib"
OutputFile="$(OutDir)\ioquake3.exe"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
|