From 50b0340a565baf40692f175783a692d1445fe41c Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 30 Oct 2009 02:18:07 +0000 Subject: [PATCH] - Fixed: S_EvictAllChannels() must replace the channel's start time with its position when evicting sounds, because restarting the sound system causes the DSP clock to restart at 0, so start times that were recorded before the reset are no longer applicable after the reset. - Fixed: S_StopChannel() always set the channel's actor to NULL, eliminating origin information when resetting the sound system. SVN r1949 (trunk) --- docs/rh-log.txt | 8 ++++++++ src/s_sound.cpp | 15 +++++++++------ src/sound/fmodsound.cpp | 8 ++++---- src/sound/fmodsound.h | 2 +- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index defe86fad..2162575de 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,11 @@ +October 29, 2009 +- Fixed: S_EvictAllChannels() must replace the channel's start time with its + position when evicting sounds, because restarting the sound system causes + the DSP clock to restart at 0, so start times that were recorded before + the reset are no longer applicable after the reset. +- Fixed: S_StopChannel() always set the channel's actor to NULL, eliminating + origin information when resetting the sound system. + October 28, 2009 - Added Gez's patch for IWAD detection of Blasphemer and Action Doom 2. - Fixed: 0 damage projectiles did not call P_DamageMobj. diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 099565925..e294b6efb 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1741,6 +1741,11 @@ void S_EvictAllChannels() chan->ChanFlags |= CHAN_EVICTED; if (chan->SysChannel != NULL) { + if (!(chan->ChanFlags & CHAN_ABSTIME)) + { + chan->StartTime.AsOne = GSnd ? GSnd->GetPosition(chan) : 0; + chan->ChanFlags |= CHAN_ABSTIME; + } S_StopChannel(chan); } // assert(chan->NextChan == next); @@ -2016,13 +2021,11 @@ void S_StopChannel(FSoundChan *chan) if (!(chan->ChanFlags & CHAN_EVICTED)) { chan->ChanFlags |= CHAN_FORGETTABLE; + if (chan->SourceType == SOURCE_Actor) + { + chan->Actor = NULL; + } } - - if (chan->SourceType == SOURCE_Actor) - { - chan->Actor = NULL; - } - GSnd->StopChannel(chan); } else diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index 2fc37322d..2a1ad2b9c 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -1541,7 +1541,7 @@ FISoundChannel *FMODSoundRenderer::StartSound(SoundHandle sfx, float vol, int pi chan->setFrequency(freq); } chan->setVolume(vol); - if (!HandleChannelDelay(chan, reuse_chan, !!(flags & SNDF_ABSTIME), freq)) + if (!HandleChannelDelay(chan, reuse_chan, flags & (SNDF_ABSTIME | SNDF_LOOP), freq)) { chan->stop(); return NULL; @@ -1648,7 +1648,7 @@ FISoundChannel *FMODSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener * chan->set3DAttributes((FMOD_VECTOR *)&pos[0], (FMOD_VECTOR *)&vel[0]); chan->set3DSpread(snd_3dspread); } - if (!HandleChannelDelay(chan, reuse_chan, !!(flags & SNDF_ABSTIME), freq)) + if (!HandleChannelDelay(chan, reuse_chan, flags & (SNDF_ABSTIME | SNDF_LOOP), freq)) { chan->stop(); return NULL; @@ -1685,7 +1685,7 @@ FISoundChannel *FMODSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener * // //========================================================================== -bool FMODSoundRenderer::HandleChannelDelay(FMOD::Channel *chan, FISoundChannel *reuse_chan, bool abstime, float freq) const +bool FMODSoundRenderer::HandleChannelDelay(FMOD::Channel *chan, FISoundChannel *reuse_chan, int flags, float freq) const { if (reuse_chan != NULL) { // Sound is being restarted, so seek it to the position @@ -1695,7 +1695,7 @@ bool FMODSoundRenderer::HandleChannelDelay(FMOD::Channel *chan, FISoundChannel * // If abstime is set, the sound is being restored, and // the channel's start time is actually its seek position. - if (abstime) + if (flags & SNDF_ABSTIME) { unsigned int seekpos = reuse_chan->StartTime.Lo; if (seekpos > 0) diff --git a/src/sound/fmodsound.h b/src/sound/fmodsound.h index 2fe497365..5febda3e2 100644 --- a/src/sound/fmodsound.h +++ b/src/sound/fmodsound.h @@ -69,7 +69,7 @@ private: static FMOD_RESULT F_CALLBACK ChannelCallback(FMOD_CHANNEL *channel, FMOD_CHANNEL_CALLBACKTYPE type, void *data1, void *data2); static float F_CALLBACK RolloffCallback(FMOD_CHANNEL *channel, float distance); - bool HandleChannelDelay(FMOD::Channel *chan, FISoundChannel *reuse_chan, bool abstime, float freq) const; + bool HandleChannelDelay(FMOD::Channel *chan, FISoundChannel *reuse_chan, int flags, float freq) const; FISoundChannel *CommonChannelSetup(FMOD::Channel *chan, FISoundChannel *reuse_chan) const; FMOD_MODE SetChanHeadSettings(SoundListener *listener, FMOD::Channel *chan, const FVector3 &pos, bool areasound, FMOD_MODE oldmode) const;