From 45ac1cc78ae7ad71f4b4827b0fb6f0ac9da84a8c Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Mon, 20 May 2024 11:19:24 +0300 Subject: [PATCH] Cleanup headers in sndlib Moving common macros into ssl_lib.h --- Descent3/spew.h | 2 + netgames/includes/gamedll_header.h | 4 +- sndlib/ddlnxsound.h | 72 ------------------------------ sndlib/ds3dlib_internal.h | 34 +------------- sndlib/hlsoundlib.cpp | 11 +++-- sndlib/mixer.cpp | 4 +- sndlib/mixer.h | 32 ------------- sndlib/sdlsound.cpp | 25 ++++------- sndlib/{lnxsound.h => sdlsound.h} | 1 - sndlib/sndrender.cpp | 9 ++-- sndlib/soundload.cpp | 9 +--- sndlib/ssl_lib.cpp | 4 +- sndlib/ssl_lib.h | 35 ++++++++++++++- 13 files changed, 62 insertions(+), 180 deletions(-) delete mode 100644 sndlib/ddlnxsound.h rename sndlib/{lnxsound.h => sdlsound.h} (99%) diff --git a/Descent3/spew.h b/Descent3/spew.h index 28c73388..e8171bbd 100644 --- a/Descent3/spew.h +++ b/Descent3/spew.h @@ -76,6 +76,8 @@ #ifndef __SPEW_H_ #define __SPEW_H_ +#include "vecmat.h" + #define SF_FORCEUPDATE 0x01 // this spew needs to do an update no matter what next time it spews (gunpoint) #define SF_UPDATEDFORFRAME 0x02 // thie spew has already updated it's position for this frame, no need to do it again #define SF_UPDATEEVERYFRAME 0x04 diff --git a/netgames/includes/gamedll_header.h b/netgames/includes/gamedll_header.h index 5862e68b..5d2e81bc 100644 --- a/netgames/includes/gamedll_header.h +++ b/netgames/includes/gamedll_header.h @@ -19,7 +19,6 @@ #ifndef GAMEDLL_HEADER_H #define GAMEDLL_HEADER_H -#include "hlsoundlib.h" //for MAX_GAME_VOLUME #include "spew.h" #include "gamefont.h" #include "hud.h" @@ -54,6 +53,9 @@ #define CEXTERN(a) extern a #endif +// From ssl_lib.h +#define MAX_GAME_VOLUME 1.0f + #if defined(__LINUX__) #define DMFCDLLOUT(x) extern "C" x #else diff --git a/sndlib/ddlnxsound.h b/sndlib/ddlnxsound.h deleted file mode 100644 index 058816aa..00000000 --- a/sndlib/ddlnxsound.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -* Descent 3 -* Copyright (C) 2024 Parallax Software -* -* This program 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. -* -* This program 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 this program. If not, see . -*/ - -#ifndef __LNX__DD_SOUND_H_ -#define __LNX__DD_SOUND_H_ - -// #include -#include "SDL_thread.h" - -// Sound Library Internal Error Codes -#define SSL_OK 0 -#define SSL_ERROR_GENERIC -1 -#define SSL_ERROR_SAMPLE_NODATA -2 -#define SSL_ERROR_STREAMMIXER -3 - -// Sound Status -#define SSF_UNUSED 0 -#define SSF_PLAY_NORMAL 1 -#define SSF_PLAY_LOOPING 2 -#define SSF_PAUSED 4 -#define SSF_PLAY_STREAMING 8 -#define SSF_BUFFERED_LOOP 64 -#define SSF_BUFFERED_STRM 128 - -#define SBT_PRIMARY 0 -#define SBT_2D 1 -#define SBT_3D 2 - -// looping methods -#define DSLOOP_SMART_METHOD 0 -#define DSLOOP_BUFFER_METHOD 1 -#define DSLOOP_STREAM_METHOD 2 - -#define DSBUFLOOP_INIT_STEP -1 -#define DSBUFLOOP_LOOP_STEP 0 -#define DSBUFLOOP_FINISH_STEP 1 - -// used to time threads. -#define DSPB_TICK_INTERVAL .01 // Primary buffer update rate (in seconds) -#define DSPB_TICK_MILLISECONDS (DSPB_TICK_INTERVAL * 1000) - -typedef struct LNXSTREAMTAG { - // pthread_t thread_id; - SDL_Thread *thread_id; - unsigned int thread_handle; - volatile bool thread_request_kill; - volatile bool thread_alive; - volatile bool thread_waiting_for_death; - - int *sound_device; - - void (*fp_SetError)(int code); - void (*fp_ErrorText)(const char *fmt, ...); - int *p_error_code; -} LNXSTREAM; - -#endif diff --git a/sndlib/ds3dlib_internal.h b/sndlib/ds3dlib_internal.h index c251eff1..b3ffff63 100644 --- a/sndlib/ds3dlib_internal.h +++ b/sndlib/ds3dlib_internal.h @@ -65,41 +65,9 @@ #include #include -#include "win\directx\dsound.h" +#include "win/directx/dsound.h" #include "ssl_lib.h" -// Sound Library Internal Error Codes -#define SSL_OK 0 -#define SSL_ERROR_GENERIC -1 -#define SSL_ERROR_SAMPLE_NODATA -2 -#define SSL_ERROR_STREAMMIXER -3 - -// Sound Status -#define SSF_UNUSED 0 -#define SSF_PLAY_NORMAL 1 -#define SSF_PLAY_LOOPING 2 -#define SSF_PAUSED 4 -#define SSF_PLAY_STREAMING 8 -#define SSF_BUFFERED_LOOP 64 -#define SSF_BUFFERED_STRM 128 - -#define SBT_PRIMARY 0 -#define SBT_2D 1 -#define SBT_3D 2 - -// looping methods -#define DSLOOP_SMART_METHOD 0 -#define DSLOOP_BUFFER_METHOD 1 -#define DSLOOP_STREAM_METHOD 2 - -#define DSBUFLOOP_INIT_STEP -1 -#define DSBUFLOOP_LOOP_STEP 0 -#define DSBUFLOOP_FINISH_STEP 1 - -// used to time threads. -#define DSPB_TICK_INTERVAL .01 // Primary buffer update rate (in seconds) -#define DSPB_TICK_MILLISECONDS (DSPB_TICK_INTERVAL * 1000) - class win_llsSystem; typedef struct DSLOOPSTREAM { diff --git a/sndlib/hlsoundlib.cpp b/sndlib/hlsoundlib.cpp index 25bc14ad..b164b635 100644 --- a/sndlib/hlsoundlib.cpp +++ b/sndlib/hlsoundlib.cpp @@ -444,11 +444,11 @@ */ // High level sound object. This code is 100% machine independant and // completely encapsulates the lowel-level machine-dependant sound code. -#include "soundload.h" + +#include + #include "hlsoundlib.h" #include "ssl_lib.h" -#include -#include #include "mono.h" #include "pserror.h" #include "vecmat.h" @@ -457,7 +457,6 @@ #include "game.h" #include "room.h" #include "BOA.h" -#include "mem.h" #include "streamaudio.h" #include "doorway.h" #include "dedicated_server.h" @@ -468,9 +467,9 @@ #if defined(WIN32) #include "ds3dlib.h" #elif defined(__LINUX__) -#include "lnxsound.h" +#include "sdlsound.h" #endif -#include + hlsSystem Sound_system; char Sound_quality = SQT_NORMAL; char Sound_mixer = SOUND_MIXER_SOFTWARE_16; diff --git a/sndlib/mixer.cpp b/sndlib/mixer.cpp index d4cab7fb..2388fac1 100644 --- a/sndlib/mixer.cpp +++ b/sndlib/mixer.cpp @@ -16,9 +16,9 @@ * along with this program. If not, see . */ +#include #include -#include -#include + #include "mono.h" #include "ssl_lib.h" #include "mixer.h" diff --git a/sndlib/mixer.h b/sndlib/mixer.h index cd098dcb..eebc2a22 100644 --- a/sndlib/mixer.h +++ b/sndlib/mixer.h @@ -21,38 +21,6 @@ #include "ssl_lib.h" -// Sound Library Internal Error Codes -#define SSL_OK 0 -#define SSL_ERROR_GENERIC -1 -#define SSL_ERROR_SAMPLE_NODATA -2 -#define SSL_ERROR_STREAMMIXER -3 - -// Sound Status -#define SSF_UNUSED 0 -#define SSF_PLAY_NORMAL 1 -#define SSF_PLAY_LOOPING 2 -#define SSF_PAUSED 4 -#define SSF_PLAY_STREAMING 8 -#define SSF_BUFFERED_LOOP 64 -#define SSF_BUFFERED_STRM 128 - -#define SBT_PRIMARY 0 -#define SBT_2D 1 -#define SBT_3D 2 - -// looping methods -#define DSLOOP_SMART_METHOD 0 -#define DSLOOP_BUFFER_METHOD 1 -#define DSLOOP_STREAM_METHOD 2 - -#define DSBUFLOOP_INIT_STEP -1 -#define DSBUFLOOP_LOOP_STEP 0 -#define DSBUFLOOP_FINISH_STEP 1 - -// This is the update rate at which to call sound_mixer::DoFrame() -// (sleep this amount each frame of the thread) -#define MIXER_TICK_INTERVAL 0.01f - class sound_buffer { public: virtual int GetNumBufferBytes(void) = 0; diff --git a/sndlib/sdlsound.cpp b/sndlib/sdlsound.cpp index 1fda5e9b..508da683 100644 --- a/sndlib/sdlsound.cpp +++ b/sndlib/sdlsound.cpp @@ -16,28 +16,20 @@ * along with this program. If not, see . */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cfile.h" +#include +#include +#include +#include + +#include + #include "pserror.h" #include "mono.h" -#include "soundload.h" #include "ssl_lib.h" -#include "mem.h" #include "application.h" -#include "lnxsound.h" -#include "ddlnxsound.h" +#include "sdlsound.h" #include "mixer.h" #include "ddio.h" -#include "SDL.h" -#include "SDL_thread.h" #include "args.h" #define SOUNDLIB_SAMPLE_RATE 22050 @@ -50,7 +42,6 @@ static sound_buffer_info sound_cache[MAX_SOUNDS_PLAYING_AT_ONCE]; static int sound_buffer_size = MAX_SOUNDS_PLAYING_AT_ONCE; -LNXSTREAM m_sb_info; lnxsound *ll_sound_ptr; // A peroidic mixer that uses the primary buffer as a stream buffer diff --git a/sndlib/lnxsound.h b/sndlib/sdlsound.h similarity index 99% rename from sndlib/lnxsound.h rename to sndlib/sdlsound.h index fe9908f5..9fb39e4b 100644 --- a/sndlib/lnxsound.h +++ b/sndlib/sdlsound.h @@ -19,7 +19,6 @@ #ifndef __LINUX_DD_SOUND_H_ #define __LINUX_DD_SOUND_H_ -#include #include "ssl_lib.h" #include "mixer.h" diff --git a/sndlib/sndrender.cpp b/sndlib/sndrender.cpp index c8f6bbb9..0d9ffc34 100644 --- a/sndlib/sndrender.cpp +++ b/sndlib/sndrender.cpp @@ -49,20 +49,19 @@ * */ +#ifdef LINUX +#include +#endif + #include "hlsoundlib.h" #include "ddsndgeometry.h" #include "sndrender.h" #include "room.h" #include "object.h" -#include "descent.h" #include "application.h" -#include "ddio.h" #include "soundload.h" #include "gametexture.h" -#ifdef LINUX -#include -#endif static llsGeometry *Geometry = NULL; static short Sound_room_list[SOUND_RENDER_ROOM_LIMIT + 1]; diff --git a/sndlib/soundload.cpp b/sndlib/soundload.cpp index 87960d31..d446e903 100644 --- a/sndlib/soundload.cpp +++ b/sndlib/soundload.cpp @@ -227,20 +227,15 @@ * $NoKeywords: $ */ -#include "pstypes.h" +#include + #include "pserror.h" -#include -#include -#include #include "ssl_lib.h" #include "object.h" -#include "cfile.h" #include "ddio.h" #include "soundload.h" #include "weapon.h" #include "ship.h" -#include "pstypes.h" -#include "mem.h" #include "door.h" #include "room.h" #include "doorway.h" diff --git a/sndlib/ssl_lib.cpp b/sndlib/ssl_lib.cpp index a222856f..42dc0276 100644 --- a/sndlib/ssl_lib.cpp +++ b/sndlib/ssl_lib.cpp @@ -39,11 +39,9 @@ #include #include +#include #include "ssl_lib.h" -#include "pserror.h" - -#include llsSystem::llsSystem() { m_lib_error_code = SSL_OK; diff --git a/sndlib/ssl_lib.h b/sndlib/ssl_lib.h index 00f73b8e..5125fbeb 100644 --- a/sndlib/ssl_lib.h +++ b/sndlib/ssl_lib.h @@ -262,7 +262,7 @@ class oeApplication; // reference to oeApplication class. -#define MAX_GAME_VOLUME (float)1.0 // helps against clipping +#define MAX_GAME_VOLUME 1.0f // helps against clipping // Size of streaming buffers #define STREAM_BUFFER_SIZE 4096 //(4 * 1024) @@ -408,6 +408,39 @@ typedef struct sound_info { // Sound Library Internal Error Codes #define SSL_OK 0 +#define SSL_ERROR_GENERIC (-1) +#define SSL_ERROR_SAMPLE_NODATA (-2) +#define SSL_ERROR_STREAMMIXER (-3) + +// Sound Status +#define SSF_UNUSED 0 +#define SSF_PLAY_NORMAL 1 +#define SSF_PLAY_LOOPING 2 +#define SSF_PAUSED 4 +#define SSF_PLAY_STREAMING 8 +#define SSF_BUFFERED_LOOP 64 +#define SSF_BUFFERED_STRM 128 + +#define SBT_PRIMARY 0 +#define SBT_2D 1 +#define SBT_3D 2 + +// looping methods +#define DSLOOP_SMART_METHOD 0 +#define DSLOOP_BUFFER_METHOD 1 +#define DSLOOP_STREAM_METHOD 2 + +#define DSBUFLOOP_INIT_STEP (-1) +#define DSBUFLOOP_LOOP_STEP 0 +#define DSBUFLOOP_FINISH_STEP 1 + +// used to time threads. + +// This is the update rate at which to call sound_mixer::DoFrame() +// (sleep this amount each frame of the thread) +#define DSPB_TICK_INTERVAL .01 // Primary buffer update rate (in seconds) +#define DSPB_TICK_MILLISECONDS (DSPB_TICK_INTERVAL * 1000) + // structure to get and set environment values #define ENV3DVALF_DOPPLER 1