r853 - in trunk: . code/client code/qcommon code/win32/msvc
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sat Aug 19 07:02:21 EDT 2006
Author: thilo
Date: 2006-08-19 07:02:20 -0400 (Sat, 19 Aug 2006)
New Revision: 853
Modified:
trunk/README
trunk/code/client/snd_openal.c
trunk/code/qcommon/cvar.c
trunk/code/qcommon/qcommon.h
trunk/code/win32/msvc/quake3.vcproj
Log:
- 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.
Modified: trunk/README
===================================================================
--- trunk/README 2006-08-18 09:21:01 UTC (rev 852)
+++ trunk/README 2006-08-19 11:02:20 UTC (rev 853)
@@ -118,6 +118,8 @@
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
Modified: trunk/code/client/snd_openal.c
===================================================================
--- trunk/code/client/snd_openal.c 2006-08-18 09:21:01 UTC (rev 852)
+++ trunk/code/client/snd_openal.c 2006-08-19 11:02:20 UTC (rev 853)
@@ -38,6 +38,10 @@
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 @@
#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 @@
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 @@
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 @@
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 @@
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 )
Modified: trunk/code/qcommon/cvar.c
===================================================================
--- trunk/code/qcommon/cvar.c 2006-08-18 09:21:01 UTC (rev 852)
+++ trunk/code/qcommon/cvar.c 2006-08-19 11:02:20 UTC (rev 853)
@@ -451,6 +451,15 @@
Cvar_Set2( var_name, NULL, qfalse );
}
+/*
+============
+Cvar_ForceReset
+============
+*/
+void Cvar_ForceReset(const char *var_name)
+{
+ Cvar_Set2(var_name, NULL, qtrue);
+}
/*
============
Modified: trunk/code/qcommon/qcommon.h
===================================================================
--- trunk/code/qcommon/qcommon.h 2006-08-18 09:21:01 UTC (rev 852)
+++ trunk/code/qcommon/qcommon.h 2006-08-19 11:02:20 UTC (rev 853)
@@ -487,6 +487,7 @@
// 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
Modified: trunk/code/win32/msvc/quake3.vcproj
===================================================================
--- trunk/code/win32/msvc/quake3.vcproj 2006-08-18 09:21:01 UTC (rev 852)
+++ trunk/code/win32/msvc/quake3.vcproj 2006-08-19 11:02:20 UTC (rev 853)
@@ -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"
More information about the quake3-commits
mailing list