void S_SoundList(void);
void S_Update_();
-void S_ClearBuffer (void);
-
// =======================================================================
// Internal sound data & structures
// Functions
// ====================================================================
+void S_FreeSfx (sfx_t *sfx, qboolean force);
+
+
void S_SoundInfo_f(void)
{
if (!sound_started)
sound_started = true;
Con_DPrintf("Sound sampling rate: %i\n", shm->format.speed);
-
- S_StopAllSounds ();
}
void S_Shutdown(void)
}
+/*
+================
+S_Terminate
+
+Shutdown and free all resources
+================
+*/
+void S_Terminate (void)
+{
+ S_Shutdown ();
+ OGG_CloseLibrary ();
+
+ // Free all SFXs
+ while (known_sfx != NULL)
+ S_FreeSfx (known_sfx, true);
+
+ Cvar_SetValueQuick (&snd_initialized, false);
+ Mem_FreePool (&snd_mempool);
+}
+
+
// =======================================================================
// Load a sound
// =======================================================================
if (!snd_initialized.integer)
return NULL;
- // Add the default sound directory to the path
if (strlen (name) >= sizeof (sfx->name))
Host_Error ("S_FindName: sound name too long (%s)", name);
==================
*/
-void S_FreeSfx (sfx_t *sfx)
+void S_FreeSfx (sfx_t *sfx, qboolean force)
{
- // Never free a locked sfx
- if (sfx->locks > 0 || (sfx->flags & SFXFLAG_PERMANENTLOCK))
+ // Never free a locked sfx unless forced
+ if (!force && (sfx->locks > 0 || (sfx->flags & SFXFLAG_PERMANENTLOCK)))
return;
Con_DPrintf ("S_FreeSfx: freeing %s\n", sfx->name);
void S_ServerSounds (char serversound [][MAX_QPATH], unsigned int numsounds)
{
sfx_t *sfx;
+ sfx_t *sfxnext;
unsigned int i;
// Start the ambient sounds and make them loop
}
// Free all unlocked sfx
- sfx = known_sfx;
- while (sfx != NULL)
+ for (sfx = known_sfx;sfx;sfx = sfxnext)
{
- sfx_t* crtsfx;
-
- // We may lose the "next" pointer after S_FreeSfx
- crtsfx = sfx;
- sfx = sfx->next;
-
- S_FreeSfx (crtsfx);
+ sfxnext = sfx->next;
+ S_FreeSfx (sfx, false);
}
}
// Free the sfx if the file didn't exist
if (ch_ind < 0)
- S_FreeSfx (sfx);
+ S_FreeSfx (sfx, false);
else
channels[ch_ind].flags |= CHANNELFLAG_LOCALSOUND;
}