@ -148,6 +148,12 @@ void S_Shutdown(void)
}
}
if ( sfx_channelGroup )
{
FMOD_ChannelGroup_Release ( sfx_channelGroup ) ;
sfx_channelGroup = NULL ;
}
/ / If we created the FMOD System ( and consequently own it ) , destroy it here
if ( fmod_ownership )
{
@ -221,9 +227,6 @@ static FMOD_RESULT SND_FMOD_Callback(FMOD_CHANNELCONTROL *channelcontrol, FMOD_C
return FMOD_OK ;
}
/ / Clear the channel to signify that it ' s free
userdata - > channel = NULL ;
if ( userdata - > zone )
{
Z_Free ( userdata ) ;
@ -255,6 +258,7 @@ static void SND_FMOD_SetChannelAttributes(FMOD_CHANNEL *channel, sfx_t *sfx, vec
static soundslot_t * SND_PickSoundSlot ( int entnum , int entchannel )
{
soundslot_t * slot ;
unsigned long long dspclock ;
if ( entnum < 0 | | entnum > = MAX_CHANNELS | | entchannel = = 0 | | entchannel > 7 )
{
@ -272,7 +276,10 @@ static soundslot_t *SND_PickSoundSlot(int entnum, int entchannel)
if ( slot - > channel )
{
/ / Stop any sound already playing on this slot
FMOD_Channel_Stop ( slot - > channel ) ;
FMOD_ChannelGroup_GetDSPClock ( sfx_channelGroup , & dspclock , NULL ) ;
FMOD_Channel_SetFadePointRamp ( slot - > channel , dspclock + 64 , 0.0f ) ;
FMOD_Channel_SetMode ( slot - > channel , FMOD_LOOP_OFF ) ;
slot - > channel = NULL ;
}
slot - > zone = false ;
@ -489,6 +496,7 @@ void S_StaticSound(sfx_t *sfx, vec3_t origin, float vol, float attenuation) // N
void S_StopSound ( int entnum , int entchannel )
{
soundslot_t * slot ;
unsigned long long dspclock ;
if ( ! fmod_system )
return ;
@ -499,7 +507,12 @@ void S_StopSound(int entnum, int entchannel)
slot = & entsounds [ entnum ] . slots [ entchannel ] ;
if ( slot - > channel )
{
FMOD_Channel_Stop ( slot - > channel ) ;
/ / Instead of immediately stopping the sound , we fade it down to 0 volume over several samples and let it play out
/ / This prevents an annoying popping noise , which is especially noticeable on rapid - fire weapons
FMOD_ChannelGroup_GetDSPClock ( sfx_channelGroup , & dspclock , NULL ) ;
FMOD_Channel_SetFadePointRamp ( slot - > channel , dspclock + 64 , 0.0f ) ;
FMOD_Channel_SetMode ( slot - > channel , FMOD_LOOP_OFF ) ;
slot - > channel = NULL ;
}
}