Skip to content

Commit

Permalink
- Add device enumeration support on windows and make "Generic Softwar…
Browse files Browse the repository at this point in the history
…e" 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.
  • Loading branch information
Thilo Schulz committed Aug 19, 2006
1 parent 4450057 commit 87a3858
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README
Expand Up @@ -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
Expand Down
75 changes: 75 additions & 0 deletions code/client/snd_openal.c
Expand Up @@ -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;

/*
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ) );

}
Expand Down Expand Up @@ -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;
}
Expand All @@ -1736,15 +1750,76 @@ 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( );
Com_Printf( "Failed to open OpenAL device.\n" );
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 )
Expand Down
9 changes: 9 additions & 0 deletions code/qcommon/cvar.c
Expand Up @@ -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);
}

/*
============
Expand Down
1 change: 1 addition & 0 deletions code/qcommon/qcommon.h
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions code/win32/msvc/quake3.vcproj
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 87a3858

Please sign in to comment.