Reworked sound system shutdown - placed single shutdown point in CL_ShutdownRef(), code cleanup
This commit is contained in:
parent
425dd7139f
commit
365929adb2
|
@ -985,7 +985,8 @@ void CL_ShutdownAll( void ) {
|
|||
#ifdef USE_CURL
|
||||
CL_cURL_Shutdown();
|
||||
#endif
|
||||
// clear sounds
|
||||
|
||||
// clear and mute all sounds until next registration
|
||||
S_DisableSounds();
|
||||
|
||||
// shutdown VMs
|
||||
|
@ -994,19 +995,16 @@ void CL_ShutdownAll( void ) {
|
|||
// shutdown the renderer
|
||||
if ( re.Shutdown ) {
|
||||
if ( CL_GameSwitch() ) {
|
||||
// shutdown sound system before renderer
|
||||
S_Shutdown();
|
||||
cls.soundStarted = qfalse;
|
||||
CL_ShutdownRef( REF_DESTROY_WINDOW ); // shutdown renderer & GLimp
|
||||
} else {
|
||||
re.Shutdown( REF_KEEP_CONTEXT ); // don't destroy window or context
|
||||
}
|
||||
}
|
||||
|
||||
cls.uiStarted = qfalse;
|
||||
cls.cgameStarted = qfalse;
|
||||
cls.rendererStarted = qfalse;
|
||||
cls.soundRegistered = qfalse;
|
||||
|
||||
SCR_Done();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1776,36 +1774,32 @@ static void CL_Vid_Restart( qboolean keepWindow ) {
|
|||
if ( clc.demorecording )
|
||||
CL_StopRecord_f();
|
||||
|
||||
// don't let them loop during the restart
|
||||
S_StopAllSounds();
|
||||
// clear and mute all sounds until next registration
|
||||
S_DisableSounds();
|
||||
|
||||
// shutdown VMs
|
||||
CL_ShutdownVMs();
|
||||
// shutdown sound system
|
||||
S_Shutdown();
|
||||
|
||||
// shutdown the renderer and clear the renderer interface
|
||||
CL_ShutdownRef( keepWindow ? REF_KEEP_WINDOW : REF_DESTROY_WINDOW );
|
||||
|
||||
// client is no longer pure until new checksums are sent
|
||||
CL_ResetPureClientAtServer();
|
||||
|
||||
// clear pak references
|
||||
FS_ClearPakReferences( FS_UI_REF | FS_CGAME_REF );
|
||||
|
||||
// reinitialize the filesystem if the game directory or checksum has changed
|
||||
if ( !clc.demoplaying ) // -EC-
|
||||
FS_ConditionalRestart( clc.checksumFeed, qfalse );
|
||||
|
||||
cls.rendererStarted = qfalse;
|
||||
cls.uiStarted = qfalse;
|
||||
cls.cgameStarted = qfalse;
|
||||
cls.soundRegistered = qfalse;
|
||||
cls.soundStarted = qfalse;
|
||||
|
||||
// unpause so the cgame definitely gets a snapshot and renders a frame
|
||||
Cvar_Set( "cl_paused", "0" );
|
||||
|
||||
CL_ClearMemory();
|
||||
|
||||
// initialize the renderer interface
|
||||
CL_InitRef();
|
||||
|
||||
// startup all the client stuff
|
||||
CL_StartHunkUsers();
|
||||
|
||||
|
@ -1842,21 +1836,6 @@ static void CL_Vid_Restart_f( void ) {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_Snd_Restart
|
||||
|
||||
Restart the sound subsystem
|
||||
=================
|
||||
*/
|
||||
static void CL_Snd_Shutdown( void )
|
||||
{
|
||||
S_StopAllSounds();
|
||||
S_Shutdown();
|
||||
cls.soundStarted = qfalse;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_Snd_Restart_f
|
||||
|
@ -1868,7 +1847,7 @@ handles will be invalid
|
|||
*/
|
||||
static void CL_Snd_Restart_f( void )
|
||||
{
|
||||
CL_Snd_Shutdown();
|
||||
S_Shutdown();
|
||||
|
||||
// sound will be reinitialized by vid_restart
|
||||
CL_Vid_Restart( qtrue );
|
||||
|
@ -3148,6 +3127,17 @@ static void CL_ShutdownRef( refShutdownCode_t code ) {
|
|||
}
|
||||
#endif
|
||||
|
||||
// clear and mute all sounds until next registration
|
||||
// S_DisableSounds();
|
||||
|
||||
if ( code >= REF_DESTROY_WINDOW ) { // +REF_UNLOAD_DLL
|
||||
// shutdown sound system before renderer
|
||||
// because it may depend from window handle
|
||||
S_Shutdown();
|
||||
}
|
||||
|
||||
SCR_Done();
|
||||
|
||||
if ( re.Shutdown ) {
|
||||
re.Shutdown( code );
|
||||
}
|
||||
|
@ -3160,6 +3150,8 @@ static void CL_ShutdownRef( refShutdownCode_t code ) {
|
|||
#endif
|
||||
|
||||
Com_Memset( &re, 0, sizeof( re ) );
|
||||
|
||||
cls.rendererStarted = qfalse;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3191,6 +3183,8 @@ static void CL_InitRenderer( void ) {
|
|||
cls.scale = cls.glconfig.vidWidth * (1.0/640.0);
|
||||
cls.biasY = 0.5 * ( cls.glconfig.vidHeight - ( cls.glconfig.vidWidth * (480.0/640) ) );
|
||||
}
|
||||
|
||||
SCR_Init();
|
||||
}
|
||||
|
||||
|
||||
|
@ -3203,11 +3197,8 @@ This is the only place that any of these functions are called from
|
|||
============================
|
||||
*/
|
||||
void CL_StartHunkUsers( void ) {
|
||||
if (!com_cl_running) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !com_cl_running->integer ) {
|
||||
if ( !com_cl_running || !com_cl_running->integer ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3951,12 +3942,6 @@ void CL_Init( void ) {
|
|||
#endif
|
||||
Cmd_AddCommand( "modelist", CL_ModeList_f );
|
||||
|
||||
CL_InitRef();
|
||||
|
||||
SCR_Init();
|
||||
|
||||
//Cbuf_Execute ();
|
||||
|
||||
Cvar_Set( "cl_running", "1" );
|
||||
#ifdef USE_MD5
|
||||
CL_GenerateQKey();
|
||||
|
@ -3971,6 +3956,8 @@ void CL_Init( void ) {
|
|||
/*
|
||||
===============
|
||||
CL_Shutdown
|
||||
|
||||
Called on fatal error, quit and dedicated mode switch
|
||||
===============
|
||||
*/
|
||||
void CL_Shutdown( const char *finalmsg, qboolean quit ) {
|
||||
|
@ -3991,9 +3978,10 @@ void CL_Shutdown( const char *finalmsg, qboolean quit ) {
|
|||
noGameRestart = quit;
|
||||
CL_Disconnect( qfalse );
|
||||
|
||||
CL_ShutdownVMs();
|
||||
// clear and mute all sounds until next registration
|
||||
S_DisableSounds();
|
||||
|
||||
S_Shutdown();
|
||||
CL_ShutdownVMs();
|
||||
|
||||
CL_ShutdownRef( quit ? REF_UNLOAD_DLL : REF_DESTROY_WINDOW );
|
||||
|
||||
|
|
|
@ -495,6 +495,16 @@ void SCR_Init( void ) {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
SCR_Done
|
||||
==================
|
||||
*/
|
||||
void SCR_Done( void ) {
|
||||
scr_initialized = qfalse;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================
|
||||
|
||||
/*
|
||||
|
|
|
@ -517,8 +517,9 @@ void CL_SaveConsoleHistory( void );
|
|||
//
|
||||
// cl_scrn.c
|
||||
//
|
||||
void SCR_Init (void);
|
||||
void SCR_UpdateScreen (void);
|
||||
void SCR_Init( void );
|
||||
void SCR_Done( void );
|
||||
void SCR_UpdateScreen( void );
|
||||
|
||||
void SCR_DebugGraph( float value );
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ static void S_Base_StopAllSounds( void );
|
|||
static void S_Base_StopBackgroundTrack( void );
|
||||
static void S_memoryLoad( sfx_t *sfx );
|
||||
|
||||
snd_stream_t *s_backgroundStream = NULL;
|
||||
static char s_backgroundLoop[MAX_QPATH];
|
||||
static snd_stream_t *s_backgroundStream = NULL;
|
||||
static char s_backgroundLoop[MAX_QPATH];
|
||||
//static char s_backgroundMusic[MAX_QPATH]; //TTimo: unused
|
||||
|
||||
static byte buffer2[ 0x10000 ]; // for muted painting
|
||||
|
@ -77,11 +77,11 @@ int s_paintedtime; // sample PAIRS
|
|||
|
||||
// MAX_SFX may be larger than MAX_SOUNDS because
|
||||
// of custom player sounds
|
||||
#define MAX_SFX 4096
|
||||
sfx_t s_knownSfx[MAX_SFX];
|
||||
int s_numSfx = 0;
|
||||
#define MAX_SFX 4096
|
||||
static sfx_t s_knownSfx[MAX_SFX];
|
||||
static int s_numSfx = 0;
|
||||
|
||||
#define LOOP_HASH 128
|
||||
#define LOOP_HASH 128
|
||||
static sfx_t *sfxHash[LOOP_HASH];
|
||||
|
||||
cvar_t *s_testsound;
|
||||
|
@ -1467,6 +1467,8 @@ static void S_Base_Shutdown( void ) {
|
|||
dma_buffer2 = NULL;
|
||||
|
||||
Cmd_RemoveCommand( "s_info" );
|
||||
|
||||
cls.soundRegistered = qfalse;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ S_BeginRegistration
|
|||
*/
|
||||
void S_BeginRegistration( void )
|
||||
{
|
||||
if( si.BeginRegistration ) {
|
||||
if ( si.BeginRegistration ) {
|
||||
si.BeginRegistration();
|
||||
}
|
||||
}
|
||||
|
@ -481,4 +481,6 @@ void S_Shutdown( void )
|
|||
Cmd_RemoveCommand( "s_info" );
|
||||
|
||||
S_CodecShutdown();
|
||||
|
||||
cls.soundStarted = qfalse;
|
||||
}
|
||||
|
|
|
@ -3044,8 +3044,6 @@ void Com_GameRestart( int checksumFeed, qboolean clientRestart )
|
|||
Com_ExecuteCfg();
|
||||
|
||||
#ifndef DEDICATED
|
||||
// Restart sound subsystem so old handles are flushed
|
||||
//CL_Snd_Restart();
|
||||
if ( clientRestart )
|
||||
CL_StartHunkUsers();
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue