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.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/client/snd_openal.c b/src/client/snd_openal.c
index b0e7cae6..6f48713f 100644
--- a/src/client/snd_openal.c
+++ b/src/client/snd_openal.c
@@ -128,6 +128,7 @@ typedef struct alSfx_s
snd_info_t info; // information for this sound like rate, sample count..
qboolean isDefault; // Couldn't be loaded - use default FX
+ qboolean isDefaultChecked; // Sound has been check if it isDefault
qboolean inMemory; // Sound is stored in memory
qboolean isLocked; // Sound is locked (can not be unloaded)
int lastUsedTime; // Time last used
@@ -294,7 +295,7 @@ static qboolean S_AL_BufferEvict( void )
S_AL_BufferLoad
=================
*/
-static void S_AL_BufferLoad(sfxHandle_t sfx)
+static void S_AL_BufferLoad(sfxHandle_t sfx, qboolean cache)
{
ALenum error;
ALuint format;
@@ -302,7 +303,6 @@ static void S_AL_BufferLoad(sfxHandle_t sfx)
void *data;
snd_info_t info;
alSfx_t *curSfx = &knownSfx[sfx];
- int size_per_sec;
// Nothing?
if(curSfx->filename[0] == '\0')
@@ -313,7 +313,7 @@ static void S_AL_BufferLoad(sfxHandle_t sfx)
return;
// Already done?
- if((curSfx->inMemory) || (curSfx->isDefault))
+ if((curSfx->inMemory) || (curSfx->isDefault) || (!cache && curSfx->isDefaultChecked))
return;
// Try to load
@@ -324,9 +324,14 @@ static void S_AL_BufferLoad(sfxHandle_t sfx)
return;
}
- size_per_sec = info.rate * info.channels * info.width;
- if( size_per_sec > 0 )
- curSfx->duration = (int)(1000.0f * ((double)info.size / size_per_sec));
+ curSfx->isDefaultChecked = qtrue;
+
+ if (!cache)
+ {
+ // Don't create AL cache
+ Z_Free(data);
+ return;
+ }
format = S_AL_Format(info.width, info.channels);
@@ -402,7 +407,7 @@ void S_AL_BufferUse(sfxHandle_t sfx)
return;
if((!knownSfx[sfx].inMemory) && (!knownSfx[sfx].isDefault))
- S_AL_BufferLoad(sfx);
+ S_AL_BufferLoad(sfx, qtrue);
knownSfx[sfx].lastUsedTime = Sys_Milliseconds();
}
@@ -468,10 +473,14 @@ sfxHandle_t S_AL_RegisterSound( const char *sample, qboolean compressed )
{
sfxHandle_t sfx = S_AL_BufferFind(sample);
- if( s_alPrecache->integer && (!knownSfx[sfx].inMemory) && (!knownSfx[sfx].isDefault))
- S_AL_BufferLoad(sfx);
+ if((!knownSfx[sfx].inMemory) && (!knownSfx[sfx].isDefault))
+ S_AL_BufferLoad(sfx, s_alPrecache->integer);
knownSfx[sfx].lastUsedTime = Com_Milliseconds();
+ if (knownSfx[sfx].isDefault) {
+ return 0;
+ }
+
return sfx;
}