New module based sound system engine
diff --git a/src/engine/API/soundSystem_api.hpp b/src/engine/API/soundSystem_api.hpp
new file mode 100644
index 0000000..5adef0d
--- /dev/null
+++ b/src/engine/API/soundSystem_api.hpp
@@ -0,0 +1,151 @@
+////////////////////////////////////////////////////////////////////////////////////////
+// Copyright(C) 1999 - 2010 id Software LLC, a ZeniMax Media company.
+// Copyright(C) 2011 - 2021 Dusan Jocic <dusanjocic@msn.com>
+//
+// This file is part of the OpenWolf GPL Source Code.
+// OpenWolf Source Code is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// OpenWolf Source Code is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with OpenWolf Source Code. If not, see <http://www.gnu.org/licenses/>.
+//
+// In addition, the OpenWolf Source Code is also subject to certain additional terms.
+// You should have received a copy of these additional terms immediately following the
+// terms and conditions of the GNU General Public License which accompanied the
+// OpenWolf Source Code. If not, please request a copy in writing from id Software
+// at the address below.
+//
+// If you have questions concerning this license or the applicable additional terms,
+// you may contact in writing id Software LLC, c/o ZeniMax Media Inc.,
+// Suite 120, Rockville, Maryland 20850 USA.
+//
+// -------------------------------------------------------------------------------------
+// File name: soundSystem_api.hpp
+// Created:
+// Compilers: Microsoft (R) C/C++ Optimizing Compiler Version 19.26.28806 for x64,
+// gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
+// Description:
+// -------------------------------------------------------------------------------------
+////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef __SOUND_API_H__
+#define __SOUND_API_H__
+
+#define SND_API_VERSION 1
+
+//
+// idSoundSystem
+//
+class idSoundSystem
+{
+public:
+ virtual void Init( void ) = 0;
+ virtual void Shutdown( void ) = 0;
+ // if origin is nullptr, the sound will be dynamically sourced from the entity
+ virtual void StartSound( vec3_t origin, sint entnum, sint entchannel, sfxHandle_t sfx ) = 0;
+ virtual void StartLocalSound( sfxHandle_t sfx, sint channelNum ) = 0;
+ virtual void StartBackgroundTrack( pointer intro, pointer loop ) = 0;
+ virtual void StopBackgroundTrack( void ) = 0;
+ // cinematics and voice-over-network will send raw samples
+ // 1.0 volume will be direct output of source samples
+ virtual void RawSamples( sint stream, sint samples, sint rate, sint width, sint channels, const uchar8* data, float32 volume, sint entityNum ) = 0;
+ // stop all sounds and the background track
+ virtual void StopAllSounds( void ) = 0;
+ // all continuous looping sounds must be added before calling S_Update
+ virtual void ClearLoopingSounds( bool killall ) = 0;
+ virtual void AddLoopingSound( sint entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ) = 0;
+ virtual void AddRealLoopingSound( sint entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ) = 0;
+ virtual void StopLoopingSound( sint entityNum ) = 0;
+ // recompute the reletive volumes for all running sounds
+ // reletive to the given entityNum / orientation
+ virtual void Respatialize( sint entityNum, const vec3_t origin, vec3_t axis[3], sint inwater ) = 0;
+ // let the sound system know where an entity currently is
+ virtual void UpdateEntityPosition( sint entityNum, const vec3_t origin ) = 0;
+ virtual void Update( void ) = 0;
+ virtual void DisableSounds( void ) = 0;
+ virtual void BeginRegistration( void ) = 0;
+ // RegisterSound will allways return a valid sample, even if it
+ // has to create a placeholder. This prevents continuous filesystem
+ // checks for missing files
+ virtual sfxHandle_t RegisterSound( pointer sample, bool compressed ) = 0;
+ virtual void DisplayFreeMemory( void ) = 0;
+ virtual void ClearSoundBuffer( void ) = 0;
+ virtual sint SoundDuration( sfxHandle_t handle ) = 0;
+ virtual sint GetSoundLength( sfxHandle_t sfxHandle ) = 0;
+ virtual void Reload( void ) = 0;
+ virtual sint GetCurrentSoundTime( void ) = 0;
+ virtual void* codec_load( pointer filename, snd_info_t* info ) = 0;
+ virtual snd_stream_t* codec_open( pointer filename ) = 0;
+ virtual void codec_close( snd_stream_t* stream ) = 0;
+ virtual sint codec_read( snd_stream_t* stream, sint bytes, void* buffer ) = 0;
+};
+
+extern idSoundSystem* soundSystem;
+
+class idAudioOpenALSystem
+{
+public:
+ virtual bool Init( void ) = 0;
+ virtual void Shutdown( void ) = 0;
+ virtual void StartSound( vec3_t origin, sint entnum, sint entchannel, sfxHandle_t sfx ) = 0;
+ virtual void StartLocalSound( sfxHandle_t sfx, sint channelNum ) = 0;
+ virtual void StartBackgroundTrack( pointer intro, pointer loop ) = 0;
+ virtual void StopBackgroundTrack( void ) = 0;
+ virtual void RawSamples( sint stream, sint samples, sint rate, sint width, sint channels, const uchar8* data, float32 volume, sint entityNum ) = 0;
+ virtual void StopAllSounds( void ) = 0;
+ virtual void ClearLoopingSounds( bool killall ) = 0;
+ virtual void AddLoopingSound( sint entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ) = 0;
+ virtual void AddRealLoopingSound( sint entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ) = 0;
+ virtual void StopLoopingSound( sint entityNum ) = 0;
+ virtual void Respatialize( sint entityNum, const vec3_t origin, vec3_t axis[3], sint inwater ) = 0;
+ virtual void UpdateEntityPosition( sint entityNum, const vec3_t origin ) = 0;
+ virtual void Update( void ) = 0;
+ virtual void DisableSounds( void ) = 0;
+ virtual void BeginRegistration( void ) = 0;
+ virtual sfxHandle_t RegisterSound( pointer sample, bool compressed ) = 0;
+ virtual void ClearSoundBuffer( void ) = 0;
+ virtual sint SoundDuration( sfxHandle_t sfx ) = 0;
+ virtual sint GetVoiceAmplitude( sint entnum ) = 0;
+ virtual sint GetSoundLength( sfxHandle_t sfxHandle ) = 0;
+ virtual sint GetCurrentSoundTime( void ) = 0;
+};
+
+extern idAudioOpenALSystem* soundOpenALSystem;
+
+// Imported functions
+typedef struct openALImports_s
+{
+ void ( QDECL* Printf )( sint printLevel, pointer fmt, ... ) __attribute__( ( format( printf, 2, 3 ) ) );
+ void ( QDECL* Error )( sint errorLevel, pointer fmt, ... ) __attribute__( ( format( printf, 2, 3 ) ) );
+#ifdef HUNK_DEBUG
+ void* ( *Hunk_AllocDebug )( uint64 size, ha_pref preference, valueType* label, valueType* file, sint line );
+#else
+ void* ( *Hunk_Alloc )( uint64 size, ha_pref preference );
+#endif
+ void* ( *Hunk_AllocateTempMemory )( uint64 size );
+ void ( *Hunk_FreeTempMemory )( void* block );
+
+ // dynamic memory allocator for things that need to be freed
+ void* ( *Malloc )( uint64 size );
+ void ( *Free )( void* buf );
+
+#if !defined (DEDICATED)
+ idAudioOpenALSystem* soundOpenALSystem;
+ idSoundSystem* soundSystem;
+ idFileSystem* fileSystem;
+ idCVarSystem* cvarSystem;
+ idCmdSystem* cmdSystem;
+ idParseSystem* parseSystem;
+ idSystem* idsystem;
+#endif
+} openALImports_t;
+
+#endif // !__SOUND_API_H__
+
diff --git a/src/engine/API/sound_api.hpp b/src/engine/API/sound_api.hpp
deleted file mode 100644
index 125f27c..0000000
--- a/src/engine/API/sound_api.hpp
+++ /dev/null
@@ -1,86 +0,0 @@
[... diff too long, it was truncated ...]
GitHub
sha: 7c1d2b56