From 7338fecceff0d53a688583880e9937b2c9d28e20 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Thu, 6 Apr 2023 07:29:05 +0200 Subject: [PATCH] remove looping sounds quirk (#973) --- src/g_game.c | 4 ---- src/i_sound.c | 3 +-- src/i_sound.h | 2 +- src/p_ceilng.c | 4 ++-- src/p_floor.c | 4 ++-- src/p_plats.c | 2 +- src/s_sound.c | 61 ++++++-------------------------------------------- src/s_sound.h | 2 -- 8 files changed, 14 insertions(+), 68 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 484a63352..65e693203 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -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(); } // diff --git a/src/i_sound.c b/src/i_sound.c index 5b15b880f..fedf625a3 100644 --- a/src/i_sound.c +++ b/src/i_sound.c @@ -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]); diff --git a/src/i_sound.h b/src/i_sound.h index a334c9001..d8bce43ab 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -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); diff --git a/src/p_ceilng.c b/src/p_ceilng.c index e1a0d8198..84fe355d9 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -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); } } diff --git a/src/p_floor.c b/src/p_floor.c index cd0bb28a5..774777f87 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -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 { diff --git a/src/p_plats.c b/src/p_plats.c index 61fde5177..cca25b621 100644 --- a/src/p_plats.c +++ b/src/p_plats.c @@ -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 diff --git a/src/s_sound.c b/src/s_sound.c index 7cf041170..541322600 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -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; diff --git a/src/s_sound.h b/src/s_sound.h index 5da2afcb7..2b09ef5d9 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -41,11 +41,9 @@ void S_Start(void); // using 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 void S_StopSound(const mobj_t *origin); -void S_StopLoopSounds(void); // [FG] play sounds in full length extern boolean full_sounds;