engine: move soundlib onto client, only leave snd_utils with some functions that's engine core or server are dependent on

This commit is contained in:
Alibek Omarov 2024-12-02 19:30:55 +03:00
parent 2d52dae69c
commit 6d00aef398
33 changed files with 28 additions and 32 deletions

View file

@ -15,9 +15,6 @@ GNU General Public License for more details.
#include "soundlib.h"
// global sound variables
sndlib_t sound;
static void Sound_Reset( void )
{
// reset global variables

View file

@ -18,6 +18,9 @@ GNU General Public License for more details.
#include <SDL_audio.h>
#endif // XASH_SDL
// global sound variables
sndlib_t sound;
/*
=============================================================================
@ -25,14 +28,9 @@ GNU General Public License for more details.
=============================================================================
*/
// stub
static const loadwavfmt_t load_null[] =
{
{ NULL, NULL, NULL }
};
static const loadwavfmt_t load_game[] =
{
#ifndef XASH_DEDICATED
{ DEFAULT_SOUNDPATH "%s%s.%s", "wav", Sound_LoadWAV },
{ "%s%s.%s", "wav", Sound_LoadWAV },
{ DEFAULT_SOUNDPATH "%s%s.%s", "mp3", Sound_LoadMPG },
@ -41,7 +39,13 @@ static const loadwavfmt_t load_game[] =
{ "%s%s.%s", "ogg", Sound_LoadOggVorbis },
{ DEFAULT_SOUNDPATH "%s%s.%s", "opus", Sound_LoadOggOpus },
{ "%s%s.%s", "opus", Sound_LoadOggOpus },
{ NULL, NULL, NULL }
#else // we only need extensions
{ NULL, "wav" },
{ NULL, "mp3" },
{ NULL, "ogg" },
{ NULL, "opus" },
#endif
{ NULL },
};
/*
@ -51,19 +55,20 @@ static const loadwavfmt_t load_game[] =
=============================================================================
*/
// stub
static const streamfmt_t stream_null[] =
{
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
static const streamfmt_t stream_game[] =
{
#ifndef XASH_DEDICATED
{ "%s%s.%s", "mp3", Stream_OpenMPG, Stream_ReadMPG, Stream_SetPosMPG, Stream_GetPosMPG, Stream_FreeMPG },
{ "%s%s.%s", "wav", Stream_OpenWAV, Stream_ReadWAV, Stream_SetPosWAV, Stream_GetPosWAV, Stream_FreeWAV },
{ "%s%s.%s", "ogg", Stream_OpenOggVorbis, Stream_ReadOggVorbis, Stream_SetPosOggVorbis, Stream_GetPosOggVorbis, Stream_FreeOggVorbis },
{ "%s%s.%s", "opus", Stream_OpenOggOpus, Stream_ReadOggOpus, Stream_SetPosOggOpus, Stream_GetPosOggOpus, Stream_FreeOggOpus },
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL }
#else // we only need extensions
{ NULL, "mp3" },
{ NULL, "wav" },
{ NULL, "ogg" },
{ NULL, "opus" },
#endif
{ NULL },
};
void Sound_Init( void )
@ -71,18 +76,10 @@ void Sound_Init( void )
// init pools
host.soundpool = Mem_AllocPool( "SoundLib Pool" );
// install image formats (can be re-install later by Sound_Setup)
switch( host.type )
{
case HOST_NORMAL:
sound.loadformats = load_game;
sound.streamformat = stream_game;
break;
default: // all other instances not using soundlib or will be reinstalling later
sound.loadformats = load_null;
sound.streamformat = stream_null;
break;
}
// install sound formats
sound.loadformats = load_game;
sound.streamformat = stream_game;
sound.tempbuffer = NULL;
}

View file

@ -148,7 +148,6 @@ def build(bld):
'common/*.c',
'common/imagelib/*.c',
'common/soundlib/*.c',
'common/soundlib/libmpg/*.c',
'server/*.c'])
if bld.env.ENGINE_TESTS:
@ -234,7 +233,10 @@ def build(bld):
source += bld.path.ant_glob([
'client/*.c',
'client/vgui/*.c',
'client/avi/*.c'])
'client/avi/*.c',
'client/soundlib/*.c',
'client/soundlib/libmpg/*.c',
])
is_cxx_link = True
libs += ['bzip2', 'MultiEmulator']
@ -264,7 +266,7 @@ def build(bld):
bld(source = source,
target = 'xash',
features = features,
includes = 'server client client/vgui',
includes = 'server client client/vgui common/soundlib',
use = libs,
install_path = install_path,
nro_install_path = bld.env.BINDIR,