partial cleanup. more to come later :)

This commit is contained in:
Bill Currie 2003-01-31 20:51:04 +00:00
parent 48c3e5a6c3
commit 05fb5f9fb2
11 changed files with 111 additions and 107 deletions

View file

@ -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 \
\

View file

@ -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

98
include/snd_render.h Normal file
View file

@ -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;

View file

@ -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;

View file

@ -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 *

View file

@ -38,13 +38,14 @@ static __attribute__ ((unused)) const char rcsid[] =
# include <strings.h>
#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];

View file

@ -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)

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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;