remove looping sounds quirk (#973)

This commit is contained in:
Fabian Greffrath 2023-04-06 07:29:05 +02:00 committed by GitHub
parent 0ff8bdb36b
commit 7338feccef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 14 additions and 68 deletions

View File

@ -2416,10 +2416,6 @@ void G_Ticker(void)
gamestate == GS_INTERMISSION ? WI_Ticker() :
gamestate == GS_FINALE ? F_Ticker() :
gamestate == GS_DEMOSCREEN ? D_PageTicker() : (void) 0;
// [FG] stop looping sounds if P_Ticker() didn't run through
if (leveltime == oldleveltime)
S_StopLoopSounds();
}
//

View File

@ -332,7 +332,7 @@ int I_GetSfxLumpNum(sfxinfo_t *sfx)
// active sounds, which is maintained as a given number
// of internal channels. Returns a free channel.
//
int I_StartSound(sfxinfo_t *sound, int vol, int sep, int pitch, boolean loop)
int I_StartSound(sfxinfo_t *sound, int vol, int sep, int pitch)
{
static unsigned int id = 0;
int channel;
@ -361,7 +361,6 @@ int I_StartSound(sfxinfo_t *sound, int vol, int sep, int pitch, boolean loop)
I_UpdateSoundParams(channel, vol, sep);
alSourcei(source, AL_BUFFER, buffer);
alSourcei(source, AL_LOOPING, loop ? AL_TRUE : AL_FALSE);
if (pitch != NORM_PITCH)
{
alSourcef(source, AL_PITCH, steptable[pitch]);

View File

@ -60,7 +60,7 @@ void I_SetChannels(void);
int I_GetSfxLumpNum(sfxinfo_t *sfxinfo);
// Starts a sound in a particular sound channel.
int I_StartSound(sfxinfo_t *sound, int vol, int sep, int pitch, boolean loop);
int I_StartSound(sfxinfo_t *sound, int vol, int sep, int pitch);
// Stops a sound channel.
void I_StopSound(int handle);

View File

@ -75,7 +75,7 @@ void T_MoveCeiling (ceiling_t* ceiling)
case genSilentCrusher:
break;
default:
S_LoopSound((mobj_t *)&ceiling->sector->soundorg, sfx_stnmov, 8);
S_StartSound((mobj_t *)&ceiling->sector->soundorg, sfx_stnmov);
break;
}
}
@ -139,7 +139,7 @@ void T_MoveCeiling (ceiling_t* ceiling)
case genSilentCrusher:
break;
default:
S_LoopSound((mobj_t *)&ceiling->sector->soundorg, sfx_stnmov, 8);
S_StartSound((mobj_t *)&ceiling->sector->soundorg, sfx_stnmov);
}
}

View File

@ -246,7 +246,7 @@ void T_MoveFloor(floormove_t* floor)
);
if (!(leveltime&7)) // make the floormove sound
S_LoopSound((mobj_t *)&floor->sector->soundorg, sfx_stnmov, 8);
S_StartSound((mobj_t *)&floor->sector->soundorg, sfx_stnmov);
if (res == pastdest) // if destination height is reached
{
@ -393,7 +393,7 @@ void T_MoveElevator(elevator_t* elevator)
// make floor move sound
if (!(leveltime&7))
S_LoopSound((mobj_t *)&elevator->sector->soundorg, sfx_stnmov, 8);
S_StartSound((mobj_t *)&elevator->sector->soundorg, sfx_stnmov);
if (res == pastdest) // if destination height acheived
{

View File

@ -53,7 +53,7 @@ void T_PlatRaise(plat_t* plat)
|| plat->type == raiseToNearestAndChange)
{
if (!(leveltime&7))
S_LoopSound((mobj_t *)&plat->sector->soundorg, sfx_stnmov, 8);
S_StartSound((mobj_t *)&plat->sector->soundorg, sfx_stnmov);
}
// if encountered an obstacle, and not a crush type, reverse direction

View File

@ -60,8 +60,6 @@ typedef struct channel_s
int priority; // current priority value
int singularity; // haleyjd 09/27/06: stored singularity value
int idnum; // haleyjd 09/30/06: unique id num for sound event
boolean loop;
int loop_timeout;
} channel_t;
// the set of channels available
@ -118,20 +116,6 @@ static void S_StopChannel(int cnum)
}
}
void S_StopLoopSounds (void)
{
int cnum;
if (!nosfxparm)
{
for (cnum = 0; cnum < numChannels; ++cnum)
{
if (channels[cnum].sfxinfo && channels[cnum].loop)
S_StopChannel(cnum);
}
}
}
//
// S_AdjustSoundParams
//
@ -220,8 +204,7 @@ static int S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source,
// Note that a higher priority number means lower priority!
//
static int S_getChannel(const mobj_t *origin, sfxinfo_t *sfxinfo,
int priority, int singularity,
boolean loop, int loop_timeout)
int priority, int singularity)
{
// channel number to use
int cnum;
@ -235,19 +218,8 @@ static int S_getChannel(const mobj_t *origin, sfxinfo_t *sfxinfo,
// haleyjd 06/12/08: only if subchannel matches
for (cnum = 0; cnum < numChannels; ++cnum)
{
if (!channels[cnum].sfxinfo)
continue;
// [FG] looping sounds don't interrupt each other
if (channels[cnum].sfxinfo == sfxinfo &&
channels[cnum].origin == origin &&
channels[cnum].loop && loop)
{
channels[cnum].loop_timeout = loop_timeout;
return -1;
}
if (channels[cnum].singularity == singularity &&
if (channels[cnum].sfxinfo &&
channels[cnum].singularity == singularity &&
channels[cnum].origin == origin)
{
S_StopChannel(cnum);
@ -277,15 +249,12 @@ static int S_getChannel(const mobj_t *origin, sfxinfo_t *sfxinfo,
}
static void S_StartSoundEx(const mobj_t *origin, int sfx_id, int loop_timeout)
void S_StartSound(const mobj_t *origin, int sfx_id)
{
int sep, pitch, o_priority, priority, singularity, cnum, handle;
int volumeScale = 127;
int volume = snd_SfxVolume;
sfxinfo_t *sfx;
const boolean loop = loop_timeout > 0;
loop_timeout += gametic;
//jff 1/22/98 return if sound is not enabled
if(nosfxparm)
@ -361,7 +330,7 @@ static void S_StartSoundEx(const mobj_t *origin, int sfx_id, int loop_timeout)
}
// try to find a channel
if((cnum = S_getChannel(origin, sfx, priority, singularity, loop, loop_timeout)) < 0)
if((cnum = S_getChannel(origin, sfx, priority, singularity)) < 0)
return;
#ifdef RANGECHECK
@ -376,7 +345,7 @@ static void S_StartSoundEx(const mobj_t *origin, int sfx_id, int loop_timeout)
sfx = sfx->link; // sf: skip thru link(s)
// Assigns the handle to one of the channels in the mix/output buffer.
handle = I_StartSound(sfx, volume, sep, pitch, loop);
handle = I_StartSound(sfx, volume, sep, pitch);
// haleyjd: check to see if the sound was started
if(handle >= 0)
@ -392,23 +361,11 @@ static void S_StartSoundEx(const mobj_t *origin, int sfx_id, int loop_timeout)
channels[cnum].priority = priority; // scaled priority
channels[cnum].singularity = singularity;
channels[cnum].idnum = I_SoundID(handle); // unique instance id
channels[cnum].loop = loop;
channels[cnum].loop_timeout = loop_timeout;
}
else // haleyjd: the sound didn't start, so clear the channel info
memset(&channels[cnum], 0, sizeof(channel_t));
}
void S_StartSound(const mobj_t *origin, int sfx_id)
{
S_StartSoundEx(origin, sfx_id, 0);
}
void S_LoopSound(const mobj_t *origin, int sfx_id, int timeout)
{
S_StartSoundEx(origin, sfx_id, timeout);
}
//
// S_StopSound
//
@ -506,11 +463,7 @@ void S_UpdateSounds(const mobj_t *listener)
if(sfx)
{
if (c->loop && gametic > c->loop_timeout)
{
S_StopChannel(cnum);
}
else if (I_SoundIsPlaying(c->handle))
if (I_SoundIsPlaying(c->handle))
{
// initialize parameters
int volume = snd_SfxVolume;

View File

@ -41,11 +41,9 @@ void S_Start(void);
// using <sound_id> from sounds.h
//
void S_StartSound(const mobj_t *origin, int sound_id);
void S_LoopSound(const mobj_t *origin, int sound_id, int timeout);
// Stop sound for thing at <origin>
void S_StopSound(const mobj_t *origin);
void S_StopLoopSounds(void);
// [FG] play sounds in full length
extern boolean full_sounds;