Skip to content

Commit

Permalink
- tweak enumeration support, remove win32 dependency
Browse files Browse the repository at this point in the history
- fix two typos in status message in snd_main.c
  • Loading branch information
Thilo Schulz committed Aug 19, 2006
1 parent 87a3858 commit b2b17e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
4 changes: 2 additions & 2 deletions code/client/snd_main.c
Expand Up @@ -404,9 +404,9 @@ void S_Init( void )
}

S_SoundInfo( );
Com_Printf( "Sound intialization successful.\n" );
Com_Printf( "Sound initialization successful.\n" );
} else {
Com_Printf( "Sound intialization failed.\n" );
Com_Printf( "Sound initialization failed.\n" );
}
}

Expand Down
21 changes: 4 additions & 17 deletions code/client/snd_openal.c
Expand Up @@ -38,10 +38,8 @@ 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 @@ -1677,10 +1675,8 @@ 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 @@ -1723,9 +1719,7 @@ qboolean S_AL_Init( soundInterface_t *si )
{
#if USE_OPENAL

#ifdef _WIN32
qboolean enumsupport, founddev = qfalse;
#endif

if( !si ) {
return qfalse;
Expand All @@ -1750,11 +1744,10 @@ qboolean S_AL_Init( soundInterface_t *si )
return qfalse;
}

#ifdef _WIN32
// Device enumeration support on windows.
// Device enumeration support (extension currently only exists for windows).
if((enumsupport = qalcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")))
{
char *devicelist, devicenames[8192] = "";
char *devicelist, devicenames[1024] = "";
char *defaultdevice;
int curlen;
qboolean hasbegun = qfalse;
Expand All @@ -1763,13 +1756,15 @@ qboolean S_AL_Init( soundInterface_t *si )
devicelist = qalcGetString(NULL, ALC_DEVICE_SPECIFIER);
defaultdevice = qalcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);

#ifdef _WIN32
// 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
#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.
Expand All @@ -1785,7 +1780,6 @@ qboolean S_AL_Init( soundInterface_t *si )
if(!strcmp(s_alDevice->string, devicelist))
founddev = qtrue;

s_alDevice->string;
devicelist += curlen + 1;
}

Expand All @@ -1802,11 +1796,6 @@ qboolean S_AL_Init( soundInterface_t *si )
alDevice = qalcOpenDevice(s_alDevice->string);
else
alDevice = qalcOpenDevice(NULL);
#else // _WIN32

// Open default device
alDevice = qalcOpenDevice( NULL );
#endif

if( !alDevice )
{
Expand All @@ -1815,10 +1804,8 @@ 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 );
Expand Down

0 comments on commit b2b17e3

Please sign in to comment.