summaryrefslogtreecommitdiff
path: root/src/client/snd_openal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/snd_openal.c')
-rw-r--r--src/client/snd_openal.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/src/client/snd_openal.c b/src/client/snd_openal.c
index 912006d8..1f91ae95 100644
--- a/src/client/snd_openal.c
+++ b/src/client/snd_openal.c
@@ -1419,6 +1419,8 @@ S_AL_StreamDie
static
void S_AL_StreamDie( int stream )
{
+ int numBuffers;
+
if ((stream < 0) || (stream >= MAX_RAW_STREAMS))
return;
@@ -1427,6 +1429,16 @@ void S_AL_StreamDie( int stream )
streamPlaying[stream] = qfalse;
qalSourceStop(streamSources[stream]);
+
+ // Un-queue any buffers, and delete them
+ qalGetSourcei( streamSources[stream], AL_BUFFERS_PROCESSED, &numBuffers );
+ while( numBuffers-- )
+ {
+ ALuint buffer;
+ qalSourceUnqueueBuffers(streamSources[stream], 1, &buffer);
+ qalDeleteBuffers(1, &buffer);
+ }
+
S_AL_FreeStreamChannel(stream);
}
@@ -1726,7 +1738,6 @@ static cvar_t *s_alCapture;
#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
@@ -1976,8 +1987,7 @@ S_AL_Init
qboolean S_AL_Init( soundInterface_t *si )
{
#ifdef USE_OPENAL
-
- qboolean enumsupport, founddev = qfalse;
+ const char* device = NULL;
int i;
if( !si ) {
@@ -2001,7 +2011,9 @@ qboolean S_AL_Init( soundInterface_t *si )
s_alRolloff = Cvar_Get( "s_alRolloff", "2", CVAR_CHEAT);
s_alGraceDistance = Cvar_Get("s_alGraceDistance", "512", CVAR_CHEAT);
- s_alDriver = Cvar_Get( "s_alDriver", ALDRIVER_DEFAULT, CVAR_ARCHIVE );
+ s_alDriver = Cvar_Get( "s_alDriver", ALDRIVER_DEFAULT, CVAR_ARCHIVE | CVAR_LATCH );
+
+ s_alDevice = Cvar_Get("s_alDevice", "", CVAR_ARCHIVE | CVAR_LATCH);
// Load QAL
if( !QAL_Init( s_alDriver->string ) )
@@ -2010,8 +2022,12 @@ qboolean S_AL_Init( soundInterface_t *si )
return qfalse;
}
+ device = s_alDevice->string;
+ if(device && !*device)
+ device = NULL;
+
// 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] = "";
const char *devicelist;
@@ -2027,11 +2043,9 @@ qboolean S_AL_Init( soundInterface_t *si )
// 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
+ if(!device && !strcmp(defaultdevice, "Generic Hardware"))
+ device = "Generic Software";
#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.
while((curlen = strlen(devicelist)))
@@ -2039,26 +2053,18 @@ qboolean S_AL_Init( soundInterface_t *si )
Q_strcat(devicenames, sizeof(devicenames), devicelist);
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;
}
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(device);
+ if( !alDevice && device )
+ {
+ Com_Printf( "Failed to open OpenAL device '%s', trying default.\n", device );
alDevice = qalcOpenDevice(NULL);
+ }
if( !alDevice )
{
@@ -2067,9 +2073,6 @@ qboolean S_AL_Init( soundInterface_t *si )
return qfalse;
}
- if(enumsupport)
- Cvar_Set("s_alDevice", qalcGetString(alDevice, ALC_DEVICE_SPECIFIER));
-
// Create OpenAL context
alContext = qalcCreateContext( alDevice, NULL );
if( !alContext )