Browse Source

Release sounds loaded by FMOD on shutdown, and check FMOD version upon startup

console
Nico de Poel 5 years ago
parent
commit
79ad6f086c
  1. 4
      engine/Quake/snd_dma.c
  2. 23
      engine/Quake/snd_fmod.c

4
engine/Quake/snd_dma.c

@ -65,8 +65,8 @@ portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
#endif // USE_FMOD
#define MAX_SFX 1024
static sfx_t *known_sfx = NULL; // hunk allocated [MAX_SFX]
static int num_sfx;
sfx_t *known_sfx = NULL; // hunk allocated [MAX_SFX]
int num_sfx;
static sfx_t *ambient_sfx[NUM_AMBIENTS];

23
engine/Quake/snd_fmod.c

@ -5,6 +5,8 @@
#include "fmod_errors.h"
extern qboolean sound_started; // in snd_dma.c
extern sfx_t *known_sfx;
extern int num_sfx;
FMOD_SYSTEM *fmod_system = NULL;
static qboolean fmod_ownership = false;
@ -76,6 +78,12 @@ void S_Startup(void)
return;
}
if (version < FMOD_VERSION)
{
Con_Printf("Incorrect FMOD library version, expected: 0x%x, found: 0x%x", FMOD_VERSION, version);
return;
}
result = FMOD_System_GetDriver(fmod_system, &driver);
if (result != FMOD_OK)
{
@ -112,11 +120,24 @@ void S_Startup(void)
void S_Shutdown(void)
{
sfx_t *sfx;
int i;
Con_DPrintf("[FMOD] Shutdown\n");
S_StopAllSounds(true);
// TODO: destroy all FMOD_SOUNDs that are attached to sfx_t's
// Release all sounds that were loaded and attached to sfx_t's
for (i = 0; i < num_sfx; i++)
{
sfx = &known_sfx[i];
if (sfx->sound)
{
FMOD_Sound_Release(sfx->sound);
sfx->sound = NULL;
}
}
// If we created the FMOD System (and consequently own it), destroy it here
if (fmod_ownership)

Loading…
Cancel
Save