- minor sound code cleanup

# Conflicts:
#	src/sound/backend/oalsound.cpp
This commit is contained in:
Christoph Oelckers 2020-04-11 18:26:58 +02:00
parent cd9e2d3795
commit 50e1efa965
9 changed files with 26 additions and 21 deletions

View file

@ -2679,6 +2679,7 @@ static int D_DoomMain_Internal (void)
else if (batchout != NULL && *batchout != 0)
{
batchrun = true;
nosound = true;
execLogfile(batchout, true);
Printf("Command line: ");
for (int i = 0; i < Args->NumArgs(); i++)

View file

@ -50,7 +50,7 @@
EXTERN_CVAR (Float, snd_sfxvolume)
EXTERN_CVAR (Float, snd_musicvolume)
EXTERN_CVAR(Float, snd_musicvolume)
CVAR (Int, snd_samplerate, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR (Int, snd_buffersize, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR (Int, snd_hrtf, -1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
@ -84,7 +84,7 @@ void I_CloseSound ();
// Maximum volume of all audio
//==========================================================================
CUSTOM_CVAR(Float, snd_mastervolume, 1.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CUSTOM_CVAR(Float, snd_mastervolume, 1.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
if (self < 0.f)
self = 0.f;
@ -250,10 +250,9 @@ void I_InitSound ()
nosfx = !!Args->CheckParm ("-nosfx");
GSnd = NULL;
if (nosound || batchrun)
if (nosound)
{
GSnd = new NullSoundRenderer;
I_InitMusic ();
return;
}
@ -277,7 +276,6 @@ void I_InitSound ()
GSnd = new NullSoundRenderer;
Printf (TEXTCOLOR_RED"Sound init failed. Using nosound.\n");
}
I_InitMusic ();
snd_sfxvolume.Callback ();
}
@ -372,9 +370,9 @@ SoundHandle SoundRenderer::LoadSoundVoc(uint8_t *sfxdata, int length)
case 1: // Sound data
if (/*noextra &*/ (codec == -1 || codec == sfxdata[i + 1])) // NAM contains a VOC where a valid data block follows an extra block.
{
frequency = 1000000/(256 - sfxdata[i]);
frequency = 1000000 / (256 - sfxdata[i]);
channels = 1;
codec = sfxdata[i+1];
codec = sfxdata[i + 1];
if (codec == 0)
bits = 8;
else if (codec == 4)

View file

@ -169,5 +169,6 @@ void I_CloseSound();
extern ReverbContainer *DefaultEnvironments[26];
bool IsOpenALPresent();
void S_SoundReset();
#endif

View file

@ -18,6 +18,8 @@ enum EChanFlag
CHANF_AREA = 128, // Sound plays from all around. Only valid with sector sounds.
CHANF_LOOP = 256,
CHANF_PICKUP = CHANF_MAYBE_LOCAL,
CHANF_NONE = 0,
CHANF_IS3D = 1, // internal: Sound is 3D.
CHANF_EVICTED = 2, // internal: Sound was evicted.
@ -28,6 +30,7 @@ enum EChanFlag
CHANF_NOSTOP = 4096, // only for A_PlaySound. Does not start if channel is playing something.
CHANF_OVERLAP = 8192, // [MK] Does not stop any sounds in the channel and instead plays over them.
CHANF_LOCAL = 16384, // only plays locally for the calling actor
CHANF_TRANSIENT = 32768, // Do not record in savegames - used for sounds that get restarted outside the sound system (e.g. ambients in SW and Blood)
};
typedef TFlags<EChanFlag> EChanFlags;

View file

@ -52,6 +52,11 @@ FModule OpenALModule{"OpenAL"};
#include "oalload.h"
CUSTOM_CVAR(Int, snd_channels, 128, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // number of channels available
{
if (self < 64) self = 64;
}
CVAR(Bool, snd_waterreverb, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR (String, snd_aldevice, "Default", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR (Bool, snd_efx, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR (String, snd_alresampler, "Default", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)

View file

@ -8,7 +8,7 @@
#include <unordered_map>
#include "i_sound.h"
#include "s_sound.h"
#include "s_soundinternal.h"
#ifndef NO_OPENAL

View file

@ -70,11 +70,6 @@
FBoolCVar noisedebug("noise", false, 0); // [RH] Print sound debugging info?
CUSTOM_CVAR(Int, snd_channels, 128, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // number of channels available
{
if (self < 64) self = 64;
}
CVAR(Bool, snd_waterreverb, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
static FString LastLocalSndInfo;
@ -218,6 +213,7 @@ void S_Init()
}
I_InitSound();
I_InitMusic();
// Heretic and Hexen have sound curve lookup tables. Doom does not.
int curvelump = fileSystem.CheckNumForName("SNDCURVE");
@ -1526,13 +1522,6 @@ CCMD (snd_reset)
S_SoundReset();
}
void S_SoundReset()
{
S_StopMusic(true);
soundEngine->Reset();
S_RestartMusic();
}
CCMD (snd_listdrivers)
{
GSnd->PrintDriversList ();

View file

@ -35,7 +35,6 @@
#include "s_soundinternal.h"
#include "sc_man.h"
#include "templates.h"
#include "m_misc.h"
#include "cmdlib.h"

View file

@ -40,6 +40,7 @@
#include "s_soundinternal.h"
#include "m_swap.h"
#include "superfasthash.h"
#include "s_music.h"
enum
@ -1694,3 +1695,11 @@ void SoundEngine::AddRandomSound(int Owner, TArray<uint32_t> list)
S_sfx[Owner].bRandomHeader = true;
S_sfx[Owner].NearLimit = -1;
}
void S_SoundReset()
{
S_StopMusic(true);
soundEngine->Reset();
S_RestartMusic();
}