- Removed GC barriers from the sound channels. If we must, we can always

do it the old way and scan every channel to see if it matches an actor/
  entchannel pair.
- Fixed: S_RelinkSounds() did not move the SoundChans bitfield to the new
  actor.
- Fixed: Stolen channels could be kept around by the high-level channels
  indefinitely.


SVN r1289 (trunk)
This commit is contained in:
Randy Heit 2008-11-15 01:01:04 +00:00
parent 9430001425
commit 3b4479df44
5 changed files with 36 additions and 12 deletions

View file

@ -1,4 +1,11 @@
November 14, 2008
- Removed GC barriers from the sound channels. If we must, we can always
do it the old way and scan every channel to see if it matches an actor/
entchannel pair.
- Fixed: S_RelinkSounds() did not move the SoundChans bitfield to the new
actor.
- Fixed: Stolen channels could be kept around by the high-level channels
indefinitely.
- Fixed: AMageStaffFX2::IsOkayToAttack() / A_MStaffAttack aimed at friendlies.
- Added kill count awareness to A_ChangeFlag.
- P_NightmareRespawn() now clears the MTF_AMBUSH flag, so respawned monsters

View file

@ -1057,7 +1057,7 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO
chan->SourceType = type;
switch (type)
{
case SOURCE_Actor: chan->Actor = actor; actor->SoundChans |= 1 << channel; GC::WriteBarrier(actor); break;
case SOURCE_Actor: chan->Actor = actor; actor->SoundChans |= 1 << channel; break;
case SOURCE_Sector: chan->Sector = sec; break;
case SOURCE_Polyobj: chan->Poly = poly; break;
case SOURCE_Unattached: chan->Point[0] = pt->X; chan->Point[1] = pt->Y; chan->Point[2] = pt->Z; break;
@ -1497,7 +1497,6 @@ void S_RelinkSound (AActor *from, AActor *to)
if (to != NULL)
{
chan->Actor = to;
GC::WriteBarrier(to);
}
else if (!(chan->ChanFlags & CHAN_LOOP))
{
@ -1509,11 +1508,15 @@ void S_RelinkSound (AActor *from, AActor *to)
}
else
{
chan->Actor = NULL;
S_StopChannel(chan);
}
}
}
if (to != NULL)
{
to->SoundChans = from->SoundChans;
}
from->SoundChans = 0;
}
//==========================================================================
@ -1698,6 +1701,10 @@ void S_RestoreEvictedChannel(FSoundChan *chan)
}
}
}
else if (chan->SysChannel == NULL && (chan->ChanFlags & (CHAN_FORGETTABLE | CHAN_LOOP)) == CHAN_FORGETTABLE)
{
S_ReturnChannel(chan);
}
}
//==========================================================================

View file

@ -178,10 +178,9 @@ struct FSoundChan : public FISoundChannel
SBYTE Priority;
SWORD NearLimit;
BYTE SourceType;
TObjPtr<AActor> Actor;
union
{
//AActor *Actor; // Used for position and velocity.
AActor *Actor; // Used for position and velocity.
const sector_t *Sector; // Sector for area sounds.
const FPolyObj *Poly; // Polyobject sound source.
float Point[3]; // Sound is not attached to any source.

View file

@ -1367,7 +1367,11 @@ FISoundChannel *FMODSoundRenderer::StartSound(SoundHandle sfx, float vol, int pi
chan->setFrequency(freq);
}
chan->setVolume(vol);
HandleChannelDelay(chan, reuse_chan, !!(flags & SNDF_ABSTIME), freq);
if (!HandleChannelDelay(chan, reuse_chan, !!(flags & SNDF_ABSTIME), freq))
{
chan->stop();
return NULL;
}
chan->setPaused(false);
return CommonChannelSetup(chan, reuse_chan);
}
@ -1461,7 +1465,11 @@ FISoundChannel *FMODSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener *
chan->set3DAttributes((FMOD_VECTOR *)&pos[0], (FMOD_VECTOR *)&vel[0]);
chan->set3DSpread(snd_3dspread);
}
HandleChannelDelay(chan, reuse_chan, !!(flags & SNDF_ABSTIME), freq);
if (!HandleChannelDelay(chan, reuse_chan, !!(flags & SNDF_ABSTIME), freq))
{
chan->stop();
return NULL;
}
chan->setPaused(false);
FISoundChannel *schan = CommonChannelSetup(chan, reuse_chan);
schan->Rolloff = *rolloff;
@ -1477,12 +1485,14 @@ FISoundChannel *FMODSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener *
//
// FMODSoundRenderer :: HandleChannelDelay
//
// If the sound is restarting, seek it to its proper place.
// Otherwise, record its starting time.
// If the sound is restarting, seek it to its proper place. Returns false
// if the sound would have ended.
//
// Otherwise, record its starting time, and return true.
//
//==========================================================================
void FMODSoundRenderer::HandleChannelDelay(FMOD::Channel *chan, FISoundChannel *reuse_chan, bool abstime, float freq) const
bool FMODSoundRenderer::HandleChannelDelay(FMOD::Channel *chan, FISoundChannel *reuse_chan, bool abstime, float freq) const
{
if (reuse_chan != NULL)
{ // Sound is being restarted, so seek it to the position
@ -1506,7 +1516,7 @@ void FMODSoundRenderer::HandleChannelDelay(FMOD::Channel *chan, FISoundChannel *
QWORD difftime = nowtime.AsOne - reuse_chan->StartTime.AsOne;
if (difftime > 0)
{
chan->setPosition((unsigned int)(difftime / OutputRate), FMOD_TIMEUNIT_MS);
return chan->setPosition((unsigned int)(difftime / OutputRate), FMOD_TIMEUNIT_MS) == FMOD_OK;
}
}
}
@ -1514,6 +1524,7 @@ void FMODSoundRenderer::HandleChannelDelay(FMOD::Channel *chan, FISoundChannel *
{
chan->setDelay(FMOD_DELAYTYPE_DSPCLOCK_START, DSPClock.Hi, DSPClock.Lo);
}
return true;
}
//==========================================================================

View file

@ -68,7 +68,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);
void HandleChannelDelay(FMOD::Channel *chan, FISoundChannel *reuse_chan, bool abstime, float freq) const;
bool HandleChannelDelay(FMOD::Channel *chan, FISoundChannel *reuse_chan, bool abstime, 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;