From 05fb5f9fb2f1d07c161a1804ecc41f686957d127 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 31 Jan 2003 20:51:04 +0000 Subject: [PATCH] partial cleanup. more to come later :) --- include/Makefile.am | 4 +- include/QF/sound.h | 98 ------------------------------- include/snd_render.h | 98 +++++++++++++++++++++++++++++++ libs/audio/renderer/snd_dma.c | 5 ++ libs/audio/renderer/snd_mem.c | 2 + libs/audio/renderer/snd_mix.c | 5 +- libs/audio/renderer/vorbis.c | 1 + libs/audio/snd.c | 2 - libs/audio/targets/snd_alsa_0_5.c | 1 - libs/audio/targets/snd_alsa_0_9.c | 1 - libs/audio/targets/snd_disk.c | 1 - 11 files changed, 111 insertions(+), 107 deletions(-) create mode 100644 include/snd_render.h diff --git a/include/Makefile.am b/include/Makefile.am index 54af6ab9e..b2895f683 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -6,8 +6,8 @@ EXTRA_DIST = asm_i386.h alsa_funcs_list.h adivtab.h anorm_dots.h anorms.h \ context_x11.h d_iface.h d_ifacea.h d_local.h dga_check.h exp.h fbset.h \ getopt.h gl_warp_sin.h in_win.h logos.h menu.h old_keys.h ops.h qstring.h \ quakeasm.h regex.h r_cvar.h r_dynamic.h r_local.h r_screen.h r_shared.h \ - sbar.h skin_stencil.h varrays.h vgamodes.h view.h vregset.h winquake.h \ - world.h \ + sbar.h skin_stencil.h snd_render.h varrays.h vgamodes.h view.h vregset.h \ + winquake.h world.h \ \ win32/fnmatch.h \ \ diff --git a/include/QF/sound.h b/include/QF/sound.h index 8443ce13a..f7d6865f4 100644 --- a/include/QF/sound.h +++ b/include/QF/sound.h @@ -43,31 +43,12 @@ #define DEFAULT_SOUND_PACKET_VOLUME 255 #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0 -// !!! if this is changed, it must be changed in asm_i386.h too !!! -typedef struct -{ - int left; - int right; -} portable_samplepair_t; - typedef struct sfx_s { char name[MAX_QPATH]; cache_user_t cache; } sfx_t; -// !!! if this is changed, it much be changed in asm_i386.h too !!! -typedef struct -{ - int length; - int loopstart; - int speed; - int width; - int stereo; - int bytes; - byte data[4]; // variable sized -} sfxcache_t; - typedef struct { qboolean gamealive; @@ -82,34 +63,6 @@ typedef struct unsigned char *buffer; } dma_t; -// !!! if this is changed, it much be changed in asm_i386.h too !!! -typedef struct -{ - sfx_t *sfx; // sfx number - int leftvol; // 0-255 volume - int rightvol; // 0-255 volume - int end; // end time in global paintsamples - int pos; // sample position in sfx - int looping; // where to loop, -1 = no looping - int entnum; // to allow overriding a specific sound - int entchannel; // - vec3_t origin; // origin of sound effect - vec_t dist_mult; // distance multiplier (attenuation/clipK) - int master_vol; // 0-255 master volume - int phase; // phase shift between l-r in samples - int oldphase; // phase shift between l-r in samples -} channel_t; - -typedef struct -{ - int rate; - int width; - int channels; - int loopstart; - int samples; - int dataofs; // chunk starts this many bytes from file start -} wavinfo_t; - struct model_s; void S_Init (struct model_s **worldmodel, int *viewentity, double *host_frametime); @@ -133,40 +86,7 @@ void S_TouchSound (const char *sample); void S_ClearPrecache (void); void S_BeginPrecaching (void); void S_EndPrecaching (void); -void SND_PaintChannels(int endtime); -void SND_Init (void); -void SND_Shutdown (void); -void SND_AmbientOff (void); -void SND_AmbientOn (void); -void SND_TouchSound (const char *sample); -void SND_ClearBuffer (void); -void SND_StaticSound (sfx_t *sfx, const vec3_t origin, float vol, - float attenuation); -void SND_StartSound (int entnum, int entchannel, sfx_t *sfx, - const vec3_t origin, float fvol, float attenuation); -void SND_StopSound (int entnum, int entchannel); -sfx_t *SND_PrecacheSound (const char *sample); -void SND_ClearPrecache (void); -void SND_Update (const vec3_t origin, const vec3_t v_forward, - const vec3_t v_right, const vec3_t v_up); -void SND_StopAllSounds (qboolean clear); -void SND_BeginPrecaching (void); -void SND_EndPrecaching (void); -void SND_ExtraUpdate (void); -void SND_LocalSound (const char *s); -void SND_BlockSound (void); -void SND_UnblockSound (void); - -void SND_ResampleSfx (sfxcache_t *sc, byte * data); -sfxcache_t *SND_GetCache (long samples, int rate, int inwidth, int channels, - sfx_t *sfx, cache_allocator_t allocator); - -void SND_InitScaletable (void); -// picks a channel based on priorities, empty slots, number of channels -channel_t *SND_PickChannel(int entnum, int entchannel); -// spatializes a channel -void SND_Spatialize(channel_t *ch); // ==================================================================== // User-setable variables @@ -175,13 +95,6 @@ void SND_Spatialize(channel_t *ch); #define MAX_CHANNELS 256 #define MAX_DYNAMIC_CHANNELS 8 -extern channel_t channels[MAX_CHANNELS]; -// 0 to MAX_DYNAMIC_CHANNELS-1 = normal entity sounds -// MAX_DYNAMIC_CHANNELS to MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS -1 = water, etc -// MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS to total_channels = static sounds - -extern int total_channels; - // // Fake dma is a synchronous faking of the DMA progress used for // isolating performance in the renderer. The fakedma_updates is @@ -216,21 +129,10 @@ extern qboolean snd_initialized; extern int snd_blocked; void S_LocalSound (const char *s); -sfxcache_t *S_LoadSound (sfx_t *s); - -wavinfo_t GetWavinfo (const char *name, byte *wav, int wavlength); void S_AmbientOff (void); void S_AmbientOn (void); extern struct model_s **snd_worldmodel; -void SND_CallbackLoad (void *object, cache_allocator_t allocator); -sfxcache_t *SND_LoadOgg (QFile *file, sfx_t *sfx, cache_allocator_t allocator); -wavinfo_t SND_GetWavinfo (const char *name, byte * wav, int wavlength); - -void SND_WriteLinearBlastStereo16 (void); -void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count); -void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count); - #endif // _SOUND_H diff --git a/include/snd_render.h b/include/snd_render.h new file mode 100644 index 000000000..4eb66ce5a --- /dev/null +++ b/include/snd_render.h @@ -0,0 +1,98 @@ + +// !!! if this is changed, it must be changed in asm_i386.h too !!! +typedef struct +{ + int left; + int right; +} portable_samplepair_t; + +// !!! if this is changed, it much be changed in asm_i386.h too !!! +typedef struct +{ + int length; + int loopstart; + int speed; + int width; + int stereo; + int bytes; + byte data[4]; // variable sized +} sfxcache_t; + +// !!! if this is changed, it much be changed in asm_i386.h too !!! +typedef struct +{ + sfx_t *sfx; // sfx number + int leftvol; // 0-255 volume + int rightvol; // 0-255 volume + int end; // end time in global paintsamples + int pos; // sample position in sfx + int looping; // where to loop, -1 = no looping + int entnum; // to allow overriding a specific sound + int entchannel; // + vec3_t origin; // origin of sound effect + vec_t dist_mult; // distance multiplier (attenuation/clipK) + int master_vol; // 0-255 master volume + int phase; // phase shift between l-r in samples + int oldphase; // phase shift between l-r in samples +} channel_t; + +typedef struct +{ + int rate; + int width; + int channels; + int loopstart; + int samples; + int dataofs; // chunk starts this many bytes from file start +} wavinfo_t; + +void SND_PaintChannels(int endtime); +void SND_Init (void); +void SND_Shutdown (void); +void SND_AmbientOff (void); +void SND_AmbientOn (void); +void SND_TouchSound (const char *sample); +void SND_ClearBuffer (void); +void SND_StaticSound (sfx_t *sfx, const vec3_t origin, float vol, + float attenuation); +void SND_StartSound (int entnum, int entchannel, sfx_t *sfx, + const vec3_t origin, float fvol, float attenuation); +void SND_StopSound (int entnum, int entchannel); +sfx_t *SND_PrecacheSound (const char *sample); +void SND_ClearPrecache (void); +void SND_Update (const vec3_t origin, const vec3_t v_forward, + const vec3_t v_right, const vec3_t v_up); +void SND_StopAllSounds (qboolean clear); +void SND_BeginPrecaching (void); +void SND_EndPrecaching (void); +void SND_ExtraUpdate (void); +void SND_LocalSound (const char *s); +void SND_BlockSound (void); +void SND_UnblockSound (void); + +void SND_ResampleSfx (sfxcache_t *sc, byte * data); +sfxcache_t *SND_GetCache (long samples, int rate, int inwidth, int channels, + sfx_t *sfx, cache_allocator_t allocator); + +void SND_InitScaletable (void); +// picks a channel based on priorities, empty slots, number of channels +channel_t *SND_PickChannel(int entnum, int entchannel); +// spatializes a channel +void SND_Spatialize(channel_t *ch); + +void SND_CallbackLoad (void *object, cache_allocator_t allocator); +sfxcache_t *SND_LoadOgg (QFile *file, sfx_t *sfx, cache_allocator_t allocator); +wavinfo_t SND_GetWavinfo (const char *name, byte * wav, int wavlength); + +void SND_WriteLinearBlastStereo16 (void); +void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count); +void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count); + +wavinfo_t GetWavinfo (const char *name, byte *wav, int wavlength); + +extern channel_t channels[MAX_CHANNELS]; +// 0 to MAX_DYNAMIC_CHANNELS-1 = normal entity sounds +// MAX_DYNAMIC_CHANNELS to MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS -1 = water, etc +// MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS to total_channels = static sounds + +extern int total_channels; diff --git a/libs/audio/renderer/snd_dma.c b/libs/audio/renderer/snd_dma.c index c5e92fd3e..04c1ca7be 100644 --- a/libs/audio/renderer/snd_dma.c +++ b/libs/audio/renderer/snd_dma.c @@ -50,8 +50,13 @@ static __attribute__ ((unused)) const char rcsid[] = #include "QF/sound.h" #include "QF/plugin.h" +#include "snd_render.h" + // Internal sound data & structures =========================================== +channel_t channels[MAX_CHANNELS]; +int total_channels; + int snd_blocked = 0; static qboolean snd_ambient = 1; diff --git a/libs/audio/renderer/snd_mem.c b/libs/audio/renderer/snd_mem.c index 63c60e5b3..511180840 100644 --- a/libs/audio/renderer/snd_mem.c +++ b/libs/audio/renderer/snd_mem.c @@ -44,6 +44,8 @@ static __attribute__ ((unused)) const char rcsid[] = #include "QF/qendian.h" #include "QF/quakefs.h" +#include "snd_render.h" + int cache_full_cycle; sfxcache_t * diff --git a/libs/audio/renderer/snd_mix.c b/libs/audio/renderer/snd_mix.c index 77120f882..f5d390e12 100644 --- a/libs/audio/renderer/snd_mix.c +++ b/libs/audio/renderer/snd_mix.c @@ -38,13 +38,14 @@ static __attribute__ ((unused)) const char rcsid[] = # include #endif +#include "winquake.h" + #include "QF/cvar.h" #include "QF/sound.h" #include "QF/sys.h" #include "compat.h" - -#include "winquake.h" +#include "snd_render.h" #define PAINTBUFFER_SIZE 512 portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE * 2]; diff --git a/libs/audio/renderer/vorbis.c b/libs/audio/renderer/vorbis.c index c79f9341a..6532f61b7 100644 --- a/libs/audio/renderer/vorbis.c +++ b/libs/audio/renderer/vorbis.c @@ -51,6 +51,7 @@ static __attribute__ ((unused)) const char rcsid[] = #include "QF/sound.h" #include "QF/sys.h" +#include "snd_render.h" static size_t read_func (void *ptr, size_t size, size_t nmemb, void *datasource) diff --git a/libs/audio/snd.c b/libs/audio/snd.c index 093bfc7df..56e5940ed 100644 --- a/libs/audio/snd.c +++ b/libs/audio/snd.c @@ -43,8 +43,6 @@ static __attribute__ ((unused)) const char rcsid[] = // Various variables also defined in snd_dma.c // FIXME - should be put in one place // ======================================================================= -channel_t channels[MAX_CHANNELS]; -int total_channels; volatile dma_t *shm = 0; cvar_t *snd_loadas8bit; int paintedtime; // sample PAIRS diff --git a/libs/audio/targets/snd_alsa_0_5.c b/libs/audio/targets/snd_alsa_0_5.c index eb4c2c74f..b82d1e6db 100644 --- a/libs/audio/targets/snd_alsa_0_5.c +++ b/libs/audio/targets/snd_alsa_0_5.c @@ -316,7 +316,6 @@ SNDDMA_Init (void) Sys_Printf ("%5d submission_chunk\n", shm->submission_chunk); Sys_Printf ("%5d speed\n", shm->speed); Sys_Printf ("0x%x dma buffer\n", (int) shm->buffer); - Sys_Printf ("%5d total_channels\n", total_channels); snd_inited = 1; return 1; diff --git a/libs/audio/targets/snd_alsa_0_9.c b/libs/audio/targets/snd_alsa_0_9.c index 6afffc19f..0a159e75b 100644 --- a/libs/audio/targets/snd_alsa_0_9.c +++ b/libs/audio/targets/snd_alsa_0_9.c @@ -273,7 +273,6 @@ SNDDMA_Init (void) Sys_Printf ("%5d submission_chunk\n", shm->submission_chunk); Sys_Printf ("%5d speed\n", shm->speed); Sys_Printf ("0x%x dma buffer\n", (int) shm->buffer); - Sys_Printf ("%5d total_channels\n", total_channels); snd_inited = 1; return 1; diff --git a/libs/audio/targets/snd_disk.c b/libs/audio/targets/snd_disk.c index bff9f9f92..438d92f39 100644 --- a/libs/audio/targets/snd_disk.c +++ b/libs/audio/targets/snd_disk.c @@ -93,7 +93,6 @@ SNDDMA_Init (void) Sys_Printf ("%5d submission_chunk\n", shm->submission_chunk); Sys_Printf ("%5d speed\n", shm->speed); Sys_Printf ("0x%x dma buffer\n", (int) shm->buffer); - Sys_Printf ("%5d total_channels\n", total_channels); if (!(snd_file = Qopen ("qf.raw", "wb"))) return 0;