diff options
-rw-r--r-- | src/client/cl_main.c | 9 | ||||
-rw-r--r-- | src/client/snd_codec_ogg.c | 4 | ||||
-rw-r--r-- | src/client/snd_codec_wav.c | 2 | ||||
-rw-r--r-- | src/client/snd_dma.c | 7 | ||||
-rw-r--r-- | src/client/snd_local.h | 1 | ||||
-rw-r--r-- | src/client/snd_mem.c | 8 | ||||
-rw-r--r-- | src/client/snd_openal.c | 16 | ||||
-rw-r--r-- | src/null/null_client.c | 2 | ||||
-rw-r--r-- | src/qcommon/common.c | 6 | ||||
-rw-r--r-- | src/qcommon/qcommon.h | 2 |
10 files changed, 34 insertions, 23 deletions
diff --git a/src/client/cl_main.c b/src/client/cl_main.c index 2507614a..296662fc 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -1797,10 +1797,10 @@ CL_Snd_Restart Restart the sound subsystem ================= */ -void CL_Snd_Restart(void) +void CL_Snd_Shutdown(void) { S_Shutdown(); - S_Init(); + cls.soundStarted = qfalse; } /* @@ -1814,7 +1814,8 @@ handles will be invalid */ void CL_Snd_Restart_f(void) { - CL_Snd_Restart(); + CL_Snd_Shutdown(); + // sound will be reinitialized by vid_restart CL_Vid_Restart_f(); } @@ -3565,7 +3566,7 @@ void CL_Shutdown( char *finalmsg ) { CL_Disconnect( qtrue ); - S_Shutdown(); + CL_Snd_Shutdown(); CL_ShutdownRef(); CL_ShutdownUI(); diff --git a/src/client/snd_codec_ogg.c b/src/client/snd_codec_ogg.c index 70ff3009..4a01c9a8 100644 --- a/src/client/snd_codec_ogg.c +++ b/src/client/snd_codec_ogg.c @@ -451,7 +451,7 @@ void *S_OGG_CodecLoad(const char *filename, snd_info_t *info) // allocate a buffer // this buffer must be free-ed by the caller of this function - buffer = Z_Malloc(info->size); + buffer = Hunk_AllocateTempMemory(info->size); if(!buffer) { S_OGG_CodecCloseStream(stream); @@ -465,7 +465,7 @@ void *S_OGG_CodecLoad(const char *filename, snd_info_t *info) // we don't even have read a single byte if(bytesRead <= 0) { - Z_Free(buffer); + Hunk_FreeTempMemory(buffer); S_OGG_CodecCloseStream(stream); return NULL; diff --git a/src/client/snd_codec_wav.c b/src/client/snd_codec_wav.c index adba7568..140bc10d 100644 --- a/src/client/snd_codec_wav.c +++ b/src/client/snd_codec_wav.c @@ -219,7 +219,7 @@ void *S_WAV_CodecLoad(const char *filename, snd_info_t *info) } // Allocate some memory - buffer = Z_Malloc(info->size); + buffer = Hunk_AllocateTempMemory(info->size); if(!buffer) { FS_FCloseFile(file); diff --git a/src/client/snd_dma.c b/src/client/snd_dma.c index 9ff76503..fd6edf03 100644 --- a/src/client/snd_dma.c +++ b/src/client/snd_dma.c @@ -407,9 +407,8 @@ void S_Base_BeginRegistration( void ) { if (s_numSfx == 0) { SND_setup(); - s_numSfx = 0; - Com_Memset( s_knownSfx, 0, sizeof( s_knownSfx ) ); - Com_Memset(sfxHash, 0, sizeof(sfx_t *)*LOOP_HASH); + Com_Memset(s_knownSfx, '\0', sizeof(s_knownSfx)); + Com_Memset(sfxHash, '\0', sizeof(sfx_t *) * LOOP_HASH); S_Base_RegisterSound("sound/feedback/hit.wav", qfalse); // changed to a sound in baseq3 } @@ -1483,8 +1482,10 @@ void S_Base_Shutdown( void ) { } SNDDMA_Shutdown(); + SND_shutdown(); s_soundStarted = 0; + s_numSfx = 0; Cmd_RemoveCommand("s_info"); } diff --git a/src/client/snd_local.h b/src/client/snd_local.h index 53ddbca4..4cf31774 100644 --- a/src/client/snd_local.h +++ b/src/client/snd_local.h @@ -205,6 +205,7 @@ qboolean S_LoadSound( sfx_t *sfx ); void SND_free(sndBuffer *v); sndBuffer* SND_malloc( void ); void SND_setup( void ); +void SND_shutdown(void); void S_PaintChannels(int endtime); diff --git a/src/client/snd_mem.c b/src/client/snd_mem.c index f3d90dd1..43d4ef19 100644 --- a/src/client/snd_mem.c +++ b/src/client/snd_mem.c @@ -101,6 +101,12 @@ void SND_setup(void) { Com_Printf("Sound memory manager started\n"); } +void SND_shutdown(void) +{ + free(sfxScratchBuffer); + free(buffer); +} + /* ================ ResampleSfx @@ -260,7 +266,7 @@ qboolean S_LoadSound( sfx_t *sfx ) } Hunk_FreeTempMemory(samples); - Z_Free(data); + Hunk_FreeTempMemory(data); return qtrue; } diff --git a/src/client/snd_openal.c b/src/client/snd_openal.c index 63c4f772..f57a6016 100644 --- a/src/client/snd_openal.c +++ b/src/client/snd_openal.c @@ -151,7 +151,7 @@ static qboolean alBuffersInitialised = qfalse; // Sound effect storage, data structures #define MAX_SFX 4096 static alSfx_t knownSfx[MAX_SFX]; -static int numSfx = 0; +static sfxHandle_t numSfx = 0; static sfxHandle_t default_sfx; @@ -335,7 +335,7 @@ static void S_AL_BufferLoad(sfxHandle_t sfx, qboolean cache) if (!cache) { // Don't create AL cache - Z_Free(data); + Hunk_FreeTempMemory(data); return; } @@ -347,7 +347,7 @@ static void S_AL_BufferLoad(sfxHandle_t sfx, qboolean cache) if((error = qalGetError()) != AL_NO_ERROR) { S_AL_BufferUseDefault(sfx); - Z_Free(data); + Hunk_FreeTempMemory(data); Com_Printf( S_COLOR_RED "ERROR: Can't create a sound buffer for %s - %s\n", curSfx->filename, S_AL_ErrorMsg(error)); return; @@ -372,7 +372,7 @@ static void S_AL_BufferLoad(sfxHandle_t sfx, qboolean cache) if( !S_AL_BufferEvict( ) ) { S_AL_BufferUseDefault(sfx); - Z_Free(data); + Hunk_FreeTempMemory(data); Com_Printf( S_COLOR_RED "ERROR: Out of memory loading %s\n", curSfx->filename); return; } @@ -386,7 +386,7 @@ static void S_AL_BufferLoad(sfxHandle_t sfx, qboolean cache) if(error != AL_NO_ERROR) { S_AL_BufferUseDefault(sfx); - Z_Free(data); + Hunk_FreeTempMemory(data); Com_Printf( S_COLOR_RED "ERROR: Can't fill sound buffer for %s - %s\n", curSfx->filename, S_AL_ErrorMsg(error)); return; @@ -395,7 +395,7 @@ static void S_AL_BufferLoad(sfxHandle_t sfx, qboolean cache) curSfx->info = info; // Free the memory - Z_Free(data); + Hunk_FreeTempMemory(data); // Woo! curSfx->inMemory = qtrue; @@ -463,7 +463,7 @@ void S_AL_BufferShutdown( void ) S_AL_BufferUnload(i); // Clear the tables - memset(knownSfx, 0, sizeof(knownSfx)); + numSfx = 0; // All undone alBuffersInitialised = qfalse; @@ -2224,6 +2224,8 @@ S_AL_BeginRegistration static void S_AL_BeginRegistration( void ) { + if(!numSfx) + S_AL_BufferInit(); } /* diff --git a/src/null/null_client.c b/src/null/null_client.c index aca14061..87f72629 100644 --- a/src/null/null_client.c +++ b/src/null/null_client.c @@ -86,7 +86,7 @@ void CL_FlushMemory( void ) { void CL_StartHunkUsers( qboolean rendererOnly ) { } -void CL_Snd_Restart(void) +void CL_Snd_Shutdown(void) { } diff --git a/src/qcommon/common.c b/src/qcommon/common.c index 02689141..9a9ca12d 100644 --- a/src/qcommon/common.c +++ b/src/qcommon/common.c @@ -2407,10 +2407,10 @@ void Com_GameRestart(int checksumFeed, qboolean clientRestart) // Clean out any user and VM created cvars Cvar_Restart(qtrue); Com_ExecuteCfg(); - - // Restart sound subsystem so old handles are flushed - CL_Snd_Restart(); + // shut down sound system before restart + CL_Snd_Shutdown(); + if(clientRestart) CL_StartHunkUsers(qfalse); diff --git a/src/qcommon/qcommon.h b/src/qcommon/qcommon.h index 2cf2b27b..4b1d48c2 100644 --- a/src/qcommon/qcommon.h +++ b/src/qcommon/qcommon.h @@ -975,7 +975,7 @@ void CL_FlushMemory( void ); void CL_StartHunkUsers( qboolean rendererOnly ); // start all the client stuff using the hunk -void CL_Snd_Restart(void); +void CL_Snd_Shutdown(void); // Restart sound subsystem void Key_KeynameCompletion( void(*callback)(const char *s) ); |