Skip to content

Commit

Permalink
- cleaned the includes of the sound backend code of unwanted content.
Browse files Browse the repository at this point in the history
Also simplified the sound init decision making. With FMod gone there is no reason to be pedantic here. Even the check of snd_backend for the Null device could be omitted here, its only realistic use is '-nosound'.
  • Loading branch information
coelckers committed Dec 8, 2019
1 parent 83349be commit 6725cfc
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 91 deletions.
5 changes: 5 additions & 0 deletions src/console/c_dispatch.cpp
Expand Up @@ -1134,6 +1134,11 @@ FString BuildString (int argc, FString *argv)
//
//===========================================================================

void FConsoleCommand::PrintCommand()
{
Printf("%s\n", m_Name);
}

FString SubstituteAliasParams (FString &command, FCommandLine &args)
{
// Do substitution by replacing %x with the argument x.
Expand Down
8 changes: 5 additions & 3 deletions src/console/c_dispatch.h
Expand Up @@ -34,7 +34,9 @@
#ifndef __C_DISPATCH_H__
#define __C_DISPATCH_H__

#include "doomtype.h"
#include <stdint.h>
#include "tarray.h"
#include "zstring.h"

class FConfigFile;

Expand Down Expand Up @@ -63,7 +65,7 @@ struct FExecList
TArray<FString> Commands;
TArray<FString> Pullins;

void AddCommand(const char *cmd, const char *file = NULL);
void AddCommand(const char *cmd, const char *file = nullptr);
void ExecCommands() const;
void AddPullins(TArray<FString> &wads) const;
};
Expand Down Expand Up @@ -107,7 +109,7 @@ class FConsoleCommand
FConsoleCommand (const char *name, CCmdRun RunFunc);
virtual ~FConsoleCommand ();
virtual bool IsAlias ();
void PrintCommand () { Printf ("%s\n", m_Name); }
void PrintCommand();

virtual void Run (FCommandLine &args, AActor *instigator, int key);
static FConsoleCommand* FindByName (const char* name);
Expand Down
1 change: 1 addition & 0 deletions src/console/c_expr.cpp
Expand Up @@ -40,6 +40,7 @@

#include "c_dispatch.h"
#include "c_cvars.h"
#include "doomtype.h"

// MACROS ------------------------------------------------------------------

Expand Down
1 change: 0 additions & 1 deletion src/gamedata/fonts/v_text.h
Expand Up @@ -34,7 +34,6 @@
#ifndef __V_TEXT_H__
#define __V_TEXT_H__

#include "doomtype.h"
#include "v_font.h"

struct FBrokenLines
Expand Down
1 change: 1 addition & 0 deletions src/r_data/r_vanillatrans.cpp
Expand Up @@ -28,6 +28,7 @@
#include "templates.h"
#include "c_cvars.h"
#include "w_wad.h"
#include "doomtype.h"
#ifdef _DEBUG
#include "c_dispatch.h"
#endif
Expand Down
18 changes: 2 additions & 16 deletions src/sound/backend/i_sound.cpp
Expand Up @@ -47,7 +47,6 @@
#include "v_text.h"
#include "c_cvars.h"
#include "stats.h"
#include "s_music.h"
#include "zmusic/zmusic.h"


Expand Down Expand Up @@ -259,20 +258,12 @@ void I_InitSound ()
return;
}

#ifndef NO_OPENAL
// Simplify transition to OpenAL backend
if (stricmp(snd_backend, "fmod") == 0)
{
Printf (TEXTCOLOR_ORANGE "FMOD Ex sound system was removed, switching to OpenAL\n");
snd_backend = "openal";
}
#endif // NO_OPENAL

// Keep it simple: let everything except "null" init the sound.
if (stricmp(snd_backend, "null") == 0)
{
GSnd = new NullSoundRenderer;
}
else if(stricmp(snd_backend, "openal") == 0)
else
{
#ifndef NO_OPENAL
if (IsOpenALPresent())
Expand All @@ -281,11 +272,6 @@ void I_InitSound ()
}
#endif
}
else
{
Printf (TEXTCOLOR_RED"%s: Unknown sound system specified\n", *snd_backend);
snd_backend = "null";
}
if (!GSnd || !GSnd->IsValid ())
{
I_CloseSound();
Expand Down
1 change: 0 additions & 1 deletion src/sound/backend/i_soundinternal.h
Expand Up @@ -3,7 +3,6 @@

#include <stdio.h>

#include "doomtype.h"
#include "vectors.h"
#include "tarray.h"
#include "zmusic/sounddecoder.h"
Expand Down
113 changes: 59 additions & 54 deletions src/sound/backend/oalsound.cpp
Expand Up @@ -35,17 +35,18 @@
#include <functional>
#include <chrono>

#include "doomstat.h"
#include "c_cvars.h"
#include "templates.h"
#include "oalsound.h"
#include "c_dispatch.h"
#include "v_text.h"
#include "i_module.h"
#include "cmdlib.h"
#include "menu/menu.h"
#include "m_fixed.h"
#include "zmusic/sounddecoder.h"
#include "filereadermusicinterface.h"


const char *GetSampleTypeName(SampleType type);
const char *GetChannelConfigName(ChannelConfig chan);

Expand Down Expand Up @@ -96,58 +97,6 @@ bool IsOpenALPresent()



void I_BuildALDeviceList(FOptionValues *opt)
{
opt->mValues.Resize(1);
opt->mValues[0].TextValue = "Default";
opt->mValues[0].Text = "Default";

#ifndef NO_OPENAL
if (IsOpenALPresent())
{
const ALCchar *names = (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") ?
alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER) :
alcGetString(NULL, ALC_DEVICE_SPECIFIER));
if (!names)
Printf("Failed to get device list: %s\n", alcGetString(NULL, alcGetError(NULL)));
else while (*names)
{
unsigned int i = opt->mValues.Reserve(1);
opt->mValues[i].TextValue = names;
opt->mValues[i].Text = names;

names += strlen(names) + 1;
}
}
#endif
}

void I_BuildALResamplersList(FOptionValues *opt)
{
opt->mValues.Resize(1);
opt->mValues[0].TextValue = "Default";
opt->mValues[0].Text = "Default";

#ifndef NO_OPENAL
if (!IsOpenALPresent())
return;
if (!alcGetCurrentContext() || !alIsExtensionPresent("AL_SOFT_source_resampler"))
return;

LPALGETSTRINGISOFT alGetStringiSOFT = reinterpret_cast<LPALGETSTRINGISOFT>(alGetProcAddress("alGetStringiSOFT"));
ALint num_resamplers = alGetInteger(AL_NUM_RESAMPLERS_SOFT);

unsigned int idx = opt->mValues.Reserve(num_resamplers);
for(ALint i = 0;i < num_resamplers;++i)
{
const ALchar *name = alGetStringiSOFT(AL_RESAMPLER_NAME_SOFT, i);
opt->mValues[idx].TextValue = name;
opt->mValues[idx].Text = name;
++idx;
}
#endif
}


ReverbContainer *ForcedEnvironment;

Expand Down Expand Up @@ -2359,4 +2308,60 @@ FSoundChan *OpenALSoundRenderer::FindLowestChannel()
return lowest;
}


#include "menu/menu.h"

void I_BuildALDeviceList(FOptionValues* opt)
{
opt->mValues.Resize(1);
opt->mValues[0].TextValue = "Default";
opt->mValues[0].Text = "Default";

#ifndef NO_OPENAL
if (IsOpenALPresent())
{
const ALCchar* names = (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") ?
alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER) :
alcGetString(NULL, ALC_DEVICE_SPECIFIER));
if (!names)
Printf("Failed to get device list: %s\n", alcGetString(NULL, alcGetError(NULL)));
else while (*names)
{
unsigned int i = opt->mValues.Reserve(1);
opt->mValues[i].TextValue = names;
opt->mValues[i].Text = names;

names += strlen(names) + 1;
}
}
#endif
}

void I_BuildALResamplersList(FOptionValues* opt)
{
opt->mValues.Resize(1);
opt->mValues[0].TextValue = "Default";
opt->mValues[0].Text = "Default";

#ifndef NO_OPENAL
if (!IsOpenALPresent())
return;
if (!alcGetCurrentContext() || !alIsExtensionPresent("AL_SOFT_source_resampler"))
return;

LPALGETSTRINGISOFT alGetStringiSOFT = reinterpret_cast<LPALGETSTRINGISOFT>(alGetProcAddress("alGetStringiSOFT"));
ALint num_resamplers = alGetInteger(AL_NUM_RESAMPLERS_SOFT);

unsigned int idx = opt->mValues.Reserve(num_resamplers);
for (ALint i = 0; i < num_resamplers; ++i)
{
const ALchar* name = alGetStringiSOFT(AL_RESAMPLER_NAME_SOFT, i);
opt->mValues[idx].TextValue = name;
opt->mValues[idx].Text = name;
++idx;
}
#endif
}


#endif // NO_OPENAL
16 changes: 3 additions & 13 deletions src/sound/s_environment.cpp
Expand Up @@ -32,21 +32,11 @@
**
*/

#include "doomtype.h"
#include "s_sound.h"
#include "s_soundinternal.h"
#include "sc_man.h"
#include "cmdlib.h"
#include "templates.h"
#include "w_wad.h"
#include "i_system.h"
#include "m_misc.h"

#include "c_cvars.h"
#include "c_dispatch.h"
#include "vm.h"
#include "dobject.h"
#include "menu/menu.h"


FReverbField ReverbFields[] =
{
Expand Down Expand Up @@ -526,7 +516,7 @@ void S_ReadReverbDef (FScanner &sc)

while (sc.GetString ())
{
name = copystring (sc.String);
name = strdup (sc.String);
sc.MustGetNumber ();
id1 = sc.Number;
sc.MustGetNumber ();
Expand Down Expand Up @@ -627,7 +617,7 @@ void S_UnloadReverbDef ()
if (!probe->Builtin)
{
if (pNext != NULL) *pNext = probe->Next;
delete[] const_cast<char *>(probe->Name);
free(const_cast<char *>(probe->Name));
delete probe;
}
else
Expand Down
4 changes: 1 addition & 3 deletions src/sound/s_sound.cpp
Expand Up @@ -39,9 +39,7 @@
#include <io.h>
#endif

#include "i_system.h"
#include "i_sound.h"
#include "s_sound.h"
#include "s_soundinternal.h"
#include "m_swap.h"
#include "superfasthash.h"

Expand Down

0 comments on commit 6725cfc

Please sign in to comment.