- Separated low level sound code from all high level dependencies.
SVN r1228 (trunk)
This commit is contained in:
parent
5d9483b632
commit
d1f8518a79
10 changed files with 203 additions and 152 deletions
|
|
@ -49,7 +49,6 @@ extern HWND Window;
|
|||
#include "fmodsound.h"
|
||||
#include "c_cvars.h"
|
||||
#include "i_system.h"
|
||||
#include "w_wad.h"
|
||||
#include "i_music.h"
|
||||
#include "v_text.h"
|
||||
#include "v_video.h"
|
||||
|
|
@ -1328,7 +1327,7 @@ SoundStream *FMODSoundRenderer::OpenStream(const char *filename_or_data, int fla
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FSoundChan *FMODSoundRenderer::StartSound(SoundHandle sfx, float vol, int pitch, int chanflags, FSoundChan *reuse_chan)
|
||||
FISoundChannel *FMODSoundRenderer::StartSound(SoundHandle sfx, float vol, int pitch, int flags, FISoundChannel *reuse_chan)
|
||||
{
|
||||
FMOD_RESULT result;
|
||||
FMOD_MODE mode;
|
||||
|
|
@ -1356,18 +1355,18 @@ FSoundChan *FMODSoundRenderer::StartSound(SoundHandle sfx, float vol, int pitch,
|
|||
mode = FMOD_SOFTWARE;
|
||||
}
|
||||
mode = (mode & ~FMOD_3D) | FMOD_2D;
|
||||
if (chanflags & CHAN_LOOP)
|
||||
if (flags & SNDF_LOOP)
|
||||
{
|
||||
mode = (mode & ~FMOD_LOOP_OFF) | FMOD_LOOP_NORMAL;
|
||||
}
|
||||
chan->setMode(mode);
|
||||
chan->setChannelGroup((chanflags & (CHAN_UI | CHAN_NOPAUSE)) ? SfxGroup : PausableSfx);
|
||||
chan->setChannelGroup((flags & SNDF_NOPAUSE) ? SfxGroup : PausableSfx);
|
||||
if (freq != 0)
|
||||
{
|
||||
chan->setFrequency(freq);
|
||||
}
|
||||
chan->setVolume(vol);
|
||||
HandleChannelDelay(chan, reuse_chan, freq);
|
||||
HandleChannelDelay(chan, reuse_chan, !!(flags & SNDF_ABSTIME), freq);
|
||||
chan->setPaused(false);
|
||||
return CommonChannelSetup(chan, reuse_chan);
|
||||
}
|
||||
|
|
@ -1384,10 +1383,10 @@ FSoundChan *FMODSoundRenderer::StartSound(SoundHandle sfx, float vol, int pitch,
|
|||
|
||||
CVAR(Float, snd_3dspread, 180, 0)
|
||||
|
||||
FSoundChan *FMODSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener *listener, float vol,
|
||||
FISoundChannel *FMODSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener *listener, float vol,
|
||||
FRolloffInfo *rolloff, float distscale,
|
||||
int pitch, int priority, const FVector3 &pos, const FVector3 &vel,
|
||||
int channum, int chanflags, FSoundChan *reuse_chan)
|
||||
int channum, int flags, FISoundChannel *reuse_chan)
|
||||
{
|
||||
FMOD_RESULT result;
|
||||
FMOD_MODE mode;
|
||||
|
|
@ -1443,13 +1442,13 @@ FSoundChan *FMODSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener *list
|
|||
{
|
||||
mode = FMOD_3D | FMOD_SOFTWARE;
|
||||
}
|
||||
if (chanflags & CHAN_LOOP)
|
||||
if (flags & SNDF_LOOP)
|
||||
{
|
||||
mode = (mode & ~FMOD_LOOP_OFF) | FMOD_LOOP_NORMAL;
|
||||
}
|
||||
mode = SetChanHeadSettings(listener, chan, pos, channum, chanflags, mode);
|
||||
mode = SetChanHeadSettings(listener, chan, pos, !!(flags & SNDF_AREA), mode);
|
||||
chan->setMode(mode);
|
||||
chan->setChannelGroup((chanflags & (CHAN_UI | CHAN_NOPAUSE)) ? SfxGroup : PausableSfx);
|
||||
chan->setChannelGroup((flags & SNDF_NOPAUSE) ? SfxGroup : PausableSfx);
|
||||
|
||||
if (freq != 0)
|
||||
{
|
||||
|
|
@ -1461,9 +1460,9 @@ FSoundChan *FMODSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener *list
|
|||
chan->set3DAttributes((FMOD_VECTOR *)&pos[0], (FMOD_VECTOR *)&vel[0]);
|
||||
chan->set3DSpread(snd_3dspread);
|
||||
}
|
||||
HandleChannelDelay(chan, reuse_chan, freq);
|
||||
HandleChannelDelay(chan, reuse_chan, !!(flags & SNDF_ABSTIME), freq);
|
||||
chan->setPaused(false);
|
||||
FSoundChan *schan = CommonChannelSetup(chan, reuse_chan);
|
||||
FISoundChannel *schan = CommonChannelSetup(chan, reuse_chan);
|
||||
schan->Rolloff = *rolloff;
|
||||
return schan;
|
||||
}
|
||||
|
|
@ -1482,7 +1481,7 @@ FSoundChan *FMODSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener *list
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FMODSoundRenderer::HandleChannelDelay(FMOD::Channel *chan, FSoundChan *reuse_chan, float freq) const
|
||||
void 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
|
||||
|
|
@ -1490,9 +1489,9 @@ void FMODSoundRenderer::HandleChannelDelay(FMOD::Channel *chan, FSoundChan *reus
|
|||
QWORD_UNION nowtime;
|
||||
chan->getDelay(FMOD_DELAYTYPE_DSPCLOCK_START, &nowtime.Hi, &nowtime.Lo);
|
||||
|
||||
// If CHAN_ABSTIME is set, the sound is being restored, and
|
||||
// If abstime is set, the sound is being restored, and
|
||||
// the channel's start time is actually its seek position.
|
||||
if (reuse_chan->ChanFlags & CHAN_ABSTIME)
|
||||
if (abstime)
|
||||
{
|
||||
unsigned int seekpos = reuse_chan->StartTime.Lo;
|
||||
if (seekpos > 0)
|
||||
|
|
@ -1500,7 +1499,6 @@ void FMODSoundRenderer::HandleChannelDelay(FMOD::Channel *chan, FSoundChan *reus
|
|||
chan->setPosition(seekpos, FMOD_TIMEUNIT_PCM);
|
||||
}
|
||||
reuse_chan->StartTime.AsOne = QWORD(nowtime.AsOne - seekpos * OutputRate / freq);
|
||||
reuse_chan->ChanFlags &= ~CHAN_ABSTIME;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1528,7 +1526,7 @@ void FMODSoundRenderer::HandleChannelDelay(FMOD::Channel *chan, FSoundChan *reus
|
|||
//==========================================================================
|
||||
|
||||
FMOD_MODE FMODSoundRenderer::SetChanHeadSettings(SoundListener *listener, FMOD::Channel *chan,
|
||||
const FVector3 &pos, int channum, int chanflags,
|
||||
const FVector3 &pos, bool areasound,
|
||||
FMOD_MODE oldmode) const
|
||||
{
|
||||
if (!listener->valid)
|
||||
|
|
@ -1539,7 +1537,7 @@ FMOD_MODE FMODSoundRenderer::SetChanHeadSettings(SoundListener *listener, FMOD::
|
|||
|
||||
cpos = listener->position;
|
||||
|
||||
if (chanflags & CHAN_AREA)
|
||||
if (areasound)
|
||||
{
|
||||
float level, old_level;
|
||||
|
||||
|
|
@ -1589,14 +1587,13 @@ FMOD_MODE FMODSoundRenderer::SetChanHeadSettings(SoundListener *listener, FMOD::
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FSoundChan *FMODSoundRenderer::CommonChannelSetup(FMOD::Channel *chan, FSoundChan *reuse_chan) const
|
||||
FISoundChannel *FMODSoundRenderer::CommonChannelSetup(FMOD::Channel *chan, FISoundChannel *reuse_chan) const
|
||||
{
|
||||
FSoundChan *schan;
|
||||
FISoundChannel *schan;
|
||||
|
||||
if (reuse_chan != NULL)
|
||||
{
|
||||
schan = reuse_chan;
|
||||
schan->ChanFlags &= ~CHAN_EVICTED;
|
||||
schan->SysChannel = chan;
|
||||
}
|
||||
else
|
||||
|
|
@ -1616,7 +1613,7 @@ FSoundChan *FMODSoundRenderer::CommonChannelSetup(FMOD::Channel *chan, FSoundCha
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FMODSoundRenderer::StopChannel(FSoundChan *chan)
|
||||
void FMODSoundRenderer::StopChannel(FISoundChannel *chan)
|
||||
{
|
||||
if (chan != NULL && chan->SysChannel != NULL)
|
||||
{
|
||||
|
|
@ -1632,7 +1629,7 @@ void FMODSoundRenderer::StopChannel(FSoundChan *chan)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
unsigned int FMODSoundRenderer::GetPosition(FSoundChan *chan)
|
||||
unsigned int FMODSoundRenderer::GetPosition(FISoundChannel *chan)
|
||||
{
|
||||
unsigned int pos;
|
||||
|
||||
|
|
@ -1697,7 +1694,7 @@ void FMODSoundRenderer::SetInactive(bool inactive)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FMODSoundRenderer::UpdateSoundParams3D(SoundListener *listener, FSoundChan *chan, const FVector3 &pos, const FVector3 &vel)
|
||||
void FMODSoundRenderer::UpdateSoundParams3D(SoundListener *listener, FISoundChannel *chan, bool areasound, const FVector3 &pos, const FVector3 &vel)
|
||||
{
|
||||
if (chan == NULL || chan->SysChannel == NULL)
|
||||
return;
|
||||
|
|
@ -1709,7 +1706,7 @@ void FMODSoundRenderer::UpdateSoundParams3D(SoundListener *listener, FSoundChan
|
|||
{
|
||||
oldmode = FMOD_3D | FMOD_SOFTWARE;
|
||||
}
|
||||
mode = SetChanHeadSettings(listener, fchan, pos, chan->EntChannel, chan->ChanFlags, oldmode);
|
||||
mode = SetChanHeadSettings(listener, fchan, pos, areasound, oldmode);
|
||||
if (mode != oldmode)
|
||||
{ // Only set the mode if it changed.
|
||||
fchan->setMode(mode);
|
||||
|
|
@ -2017,7 +2014,7 @@ FMOD_RESULT F_CALLBACK FMODSoundRenderer::ChannelEndCallback
|
|||
{
|
||||
assert(type == FMOD_CHANNEL_CALLBACKTYPE_END);
|
||||
FMOD::Channel *chan = (FMOD::Channel *)channel;
|
||||
FSoundChan *schan;
|
||||
FISoundChannel *schan;
|
||||
|
||||
if (chan->getUserData((void **)&schan) == FMOD_OK && schan != NULL)
|
||||
{
|
||||
|
|
@ -2038,7 +2035,7 @@ FMOD_RESULT F_CALLBACK FMODSoundRenderer::ChannelEndCallback
|
|||
float F_CALLBACK FMODSoundRenderer::RolloffCallback(FMOD_CHANNEL *channel, float distance)
|
||||
{
|
||||
FMOD::Channel *chan = (FMOD::Channel *)channel;
|
||||
FSoundChan *schan;
|
||||
FISoundChannel *schan;
|
||||
|
||||
if (GRolloff != NULL)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue