From f157f088d1ab23f7a952a9de7f20de222f785749 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Thu, 30 Dec 2010 21:10:26 +0000 Subject: [PATCH] sync several sound-related files with uhexen2 a little: move DEFAULT_SOUND_PACKET_VOLUME and DEFAULT_SOUND_PACKET_ATTENUATION from sound.h to protocol.h. remove unused gamealive, soundalive and splitbuffer members from the dma_t structure. make SNDDMA_Init() to take a dma_t* parameter and make sn static to snd_dma.c. copy over LordHavoc's S_StartSound skip calculation fixes from uhexen2. make many functions/data static to their respective files. many whitespace/formatting clean-ups. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@356 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/cdaudio.h | 14 ++--- Quake/protocol.h | 6 +- Quake/q_sound.h | 160 +++++++++++++++++++++-------------------------- Quake/snd_dma.c | 100 ++++++++++++++--------------- Quake/snd_mem.c | 50 +++++++-------- Quake/snd_mix.c | 16 +++-- Quake/snd_sdl.c | 6 +- 7 files changed, 167 insertions(+), 185 deletions(-) diff --git a/Quake/cdaudio.h b/Quake/cdaudio.h index 7f9264fc..58fea542 100644 --- a/Quake/cdaudio.h +++ b/Quake/cdaudio.h @@ -22,13 +22,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __CDAUDIO_H #define __CDAUDIO_H -int CDAudio_Init(void); -void CDAudio_Play(byte track, qboolean looping); -void CDAudio_Stop(void); -void CDAudio_Pause(void); -void CDAudio_Resume(void); -void CDAudio_Shutdown(void); -void CDAudio_Update(void); +int CDAudio_Init (void); +void CDAudio_Play (byte track, qboolean looping); +void CDAudio_Stop (void); +void CDAudio_Pause (void); +void CDAudio_Resume (void); +void CDAudio_Shutdown (void); +void CDAudio_Update (void); #endif /* __CDAUDIO_H */ diff --git a/Quake/protocol.h b/Quake/protocol.h index 64756b51..5322539c 100644 --- a/Quake/protocol.h +++ b/Quake/protocol.h @@ -98,8 +98,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // a sound with no channel is a local only sound #define SND_VOLUME (1<<0) // a byte -#define SND_ATTENUATION (1<<1) // a byte +#define SND_ATTENUATION (1<<1) // a byte #define SND_LOOPING (1<<2) // a long + +#define DEFAULT_SOUND_PACKET_VOLUME 255 +#define DEFAULT_SOUND_PACKET_ATTENUATION 1.0 + //johnfitz -- PROTOCOL_FITZQUAKE -- new bits #define SND_LARGEENTITY (1<<3) // a short + byte (instead of just a short) #define SND_LARGESOUND (1<<4) // a short soundindex (instead of a byte) diff --git a/Quake/q_sound.h b/Quake/q_sound.h index c100b66c..139c5fb2 100644 --- a/Quake/q_sound.h +++ b/Quake/q_sound.h @@ -24,10 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __QUAKE_SOUND__ #define __QUAKE_SOUND__ -#define DEFAULT_SOUND_PACKET_VOLUME 255 -#define DEFAULT_SOUND_PACKET_ATTENUATION 1.0 - -// !!! if this is changed, it much be changed in asm_i386.h too !!! +/* !!! if this is changed, it must be changed in asm_i386.h too !!! */ typedef struct { int left; @@ -36,72 +33,69 @@ typedef struct typedef struct sfx_s { - char name[MAX_QPATH]; + char name[MAX_QPATH]; cache_user_t cache; } sfx_t; -// !!! if this is changed, it much be changed in asm_i386.h too !!! +/* !!! if this is changed, it must be changed in asm_i386.h too !!! */ typedef struct { - int length; - int loopstart; - int speed; - int width; - int stereo; - byte data[1]; // variable sized + int length; + int loopstart; + int speed; + int width; + int stereo; + byte data[1]; /* variable sized */ } sfxcache_t; typedef struct { - qboolean gamealive; - qboolean soundalive; - qboolean splitbuffer; - int channels; - int samples; // mono samples in buffer - int submission_chunk; // don't mix less than this # - int samplepos; // in mono samples - int samplebits; - int speed; + int channels; + int samples; /* mono samples in buffer */ + int submission_chunk; /* don't mix less than this # */ + int samplepos; /* in mono samples */ + int samplebits; + int speed; unsigned char *buffer; } dma_t; -// !!! if this is changed, it much be changed in asm_i386.h too !!! +/* !!! if this is changed, it must 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 + 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 */ } channel_t; #define WAV_FORMAT_PCM 1 typedef struct { - int rate; - int width; - int channels; - int loopstart; - int samples; - int dataofs; // chunk starts this many bytes from file start + int rate; + int width; + int channels; + int loopstart; + int samples; + int dataofs; /* chunk starts this many bytes from file start */ } wavinfo_t; void S_Init (void); void S_Startup (void); void S_Shutdown (void); -void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation); +void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation); void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation); void S_StopSound (int entnum, int entchannel); void S_StopAllSounds(qboolean clear); void S_ClearBuffer (void); -void S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up); +void S_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up); void S_ExtraUpdate (void); void S_BlockSound (void); @@ -112,28 +106,28 @@ void S_TouchSound (const char *sample); void S_ClearPrecache (void); void S_BeginPrecaching (void); void S_EndPrecaching (void); -void S_PaintChannels(int endtime); +void S_PaintChannels (int endtime); void S_InitPaintChannels (void); -// picks a channel based on priorities, empty slots, number of channels -channel_t *SND_PickChannel(int entnum, int entchannel); +/* 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); +/* spatializes a channel */ +void SND_Spatialize (channel_t *ch); -// music stream support +/* music stream support */ void S_RawSamples(int samples, int rate, int width, int channels, byte * data, float volume); -// returns file's extension including the dot, or NULL +/* returns file's extension including the dot, or NULL */ const char *S_FileExtension (const char *name); -// initializes cycling through a DMA buffer and returns information on it -qboolean SNDDMA_Init(void); +/* initializes cycling through a DMA buffer and returns information on it */ +qboolean SNDDMA_Init(dma_t *dma); -// gets the current DMA position +/* gets the current DMA position */ int SNDDMA_GetDMAPos(void); -// shutdown the DMA xfer. +/* shutdown the DMA xfer. */ void SNDDMA_Shutdown(void); /* validates & locks the dma buffer */ @@ -148,59 +142,47 @@ void SNDDMA_BlockSound(void); /* unblocks the output upon window focus gain */ void SNDDMA_UnblockSound(void); -// ==================================================================== -// User-setable variables -// ==================================================================== - -#define MAX_CHANNELS 512 //johnfitz -- was 128 -#define MAX_DYNAMIC_CHANNELS 128 //johnfitz -- was 8 +/* ==================================================================== + * User-setable variables + * ==================================================================== + */ +#define MAX_CHANNELS 512 /* johnfitz -- was 128 */ +#define MAX_DYNAMIC_CHANNELS 128 /* johnfitz -- was 8 */ extern channel_t snd_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 +/* 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; +extern volatile dma_t *shm; -// -// Fake dma is a synchronous faking of the DMA progress used for -// isolating performance in the renderer. The fakedma_updates is -// number of times S_Update() is called per second. -// +extern int total_channels; +extern int soundtime; +extern int paintedtime; +extern int s_rawend; -extern qboolean fakedma; -extern int fakedma_updates; -extern int paintedtime; -extern int s_rawend; -extern vec3_t listener_origin; -extern vec3_t listener_forward; -extern vec3_t listener_right; -extern vec3_t listener_up; -extern volatile dma_t *shm; -extern volatile dma_t sn; +extern vec3_t listener_origin; +extern vec3_t listener_forward; +extern vec3_t listener_right; +extern vec3_t listener_up; + +extern cvar_t sndspeed; +extern cvar_t sfxvolume; +extern cvar_t loadas8bit; #define MAX_RAW_SAMPLES 8192 extern portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES]; -extern cvar_t loadas8bit; -extern cvar_t bgmvolume; -extern cvar_t sfxvolume; -extern cvar_t sndspeed; +extern cvar_t bgmvolume; -extern qboolean snd_initialized; - -extern int snd_blocked; - -void S_LocalSound (const char *s); +void S_LocalSound (const char *name); sfxcache_t *S_LoadSound (sfx_t *s); wavinfo_t GetWavinfo (const char *name, byte *wav, int wavlength); void SND_InitScaletable (void); -void S_AmbientOff (void); -void S_AmbientOn (void); - #endif /* __QUAKE_SOUND__ */ diff --git a/Quake/snd_dma.c b/Quake/snd_dma.c index 4cff70f3..d1175521 100644 --- a/Quake/snd_dma.c +++ b/Quake/snd_dma.c @@ -23,12 +23,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" -void S_Play(void); -void S_PlayVol(void); -void S_SoundList(void); -void S_Update_(); -void S_StopAllSounds(qboolean clear); -void S_StopAllSoundsC(void); +static void S_Play (void); +static void S_PlayVol (void); +static void S_SoundList (void); +static void S_Update_ (void); +void S_StopAllSounds (qboolean clear); +static void S_StopAllSoundsC (void); // ======================================================================= // Internal sound data & structures @@ -37,10 +37,10 @@ void S_StopAllSoundsC(void); channel_t snd_channels[MAX_CHANNELS]; int total_channels; -int snd_blocked = 0; -qboolean snd_initialized = false; +static int snd_blocked = 0; +static qboolean snd_initialized = false; -volatile dma_t sn; +static dma_t sn; volatile dma_t *shm = NULL; vec3_t listener_origin; @@ -58,31 +58,32 @@ portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES]; #define MAX_SFX 512 -sfx_t *known_sfx; // hunk allocated [MAX_SFX] -int num_sfx; +static sfx_t *known_sfx = NULL; // hunk allocated [MAX_SFX] +static int num_sfx; -sfx_t *ambient_sfx[NUM_AMBIENTS]; +static sfx_t *ambient_sfx[NUM_AMBIENTS]; -qboolean sound_started = false; +static qboolean sound_started = false; -static float oldvolume = -1.0; +cvar_t bgmvolume = {"bgmvolume", "1", true}; +cvar_t sfxvolume = {"volume", "0.7", true}; -cvar_t bgmvolume = {"bgmvolume", "1", true}; -cvar_t sfxvolume = {"volume", "0.7", true}; +cvar_t precache = {"precache", "1"}; +cvar_t loadas8bit = {"loadas8bit", "0"}; -cvar_t nosound = {"nosound", "0"}; -cvar_t precache = {"precache", "1"}; -cvar_t loadas8bit = {"loadas8bit", "0"}; -cvar_t bgmbuffer = {"bgmbuffer", "4096"}; -cvar_t ambient_level = {"ambient_level", "0.3"}; -cvar_t ambient_fade = {"ambient_fade", "100"}; -cvar_t snd_noextraupdate = {"snd_noextraupdate", "0"}; -cvar_t snd_show = {"snd_show", "0"}; -cvar_t _snd_mixahead = {"_snd_mixahead", "0.1", true}; -cvar_t sndspeed = {"sndspeed", "11025"}; +cvar_t sndspeed = {"sndspeed", "11025"}; + +static float oldvolume = -1.0; + +static cvar_t nosound = {"nosound", "0"}; +static cvar_t ambient_level = {"ambient_level", "0.3"}; +static cvar_t ambient_fade = {"ambient_fade", "100"}; +static cvar_t snd_noextraupdate = {"snd_noextraupdate", "0"}; +static cvar_t snd_show = {"snd_show", "0"}; +static cvar_t _snd_mixahead = {"_snd_mixahead", "0.1", true}; -void S_SoundInfo_f(void) +static void S_SoundInfo_f (void) { if (!sound_started || !shm) { @@ -110,7 +111,7 @@ void S_Startup (void) if (!snd_initialized) return; - sound_started = SNDDMA_Init(); + sound_started = SNDDMA_Init(&sn); if (!sound_started) { @@ -144,7 +145,6 @@ void S_Init (void) Cvar_RegisterVariable(&precache, NULL); Cvar_RegisterVariable(&loadas8bit, NULL); Cvar_RegisterVariable(&bgmvolume, NULL); - Cvar_RegisterVariable(&bgmbuffer, NULL); Cvar_RegisterVariable(&ambient_level, NULL); Cvar_RegisterVariable(&ambient_fade, NULL); Cvar_RegisterVariable(&snd_noextraupdate, NULL); @@ -155,7 +155,7 @@ void S_Init (void) if (safemode || COM_CheckParm("-nosound")) return; - Con_Printf("Sound Initialization\n"); + Con_Printf("\nSound Initialization\n"); Cmd_AddCommand("play", S_Play); Cmd_AddCommand("playvol", S_PlayVol); @@ -204,8 +204,6 @@ void S_Shutdown (void) if (!sound_started) return; - if (shm) - shm->gamealive = 0; sound_started = 0; snd_blocked = 0; @@ -224,7 +222,7 @@ S_FindName ================== */ -sfx_t *S_FindName (const char *name) +static sfx_t *S_FindName (const char *name) { int i; sfx_t *sfx; @@ -476,9 +474,17 @@ void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float continue; if (check->sfx == sfx && !check->pos) { - skip = rand () % (int)(0.1*shm->speed); + /* + skip = rand () % (int)(0.1 * shm->speed); if (skip >= target_chan->end) skip = target_chan->end - 1; + */ + /* LordHavoc: fixed skip calculations */ + skip = 0.1 * shm->speed; /* 0.1 * sc->speed */ + if (skip > sc->length) + skip = sc->length; + if (skip > 0) + skip = rand() % skip; target_chan->pos += skip; target_chan->end -= skip; break; @@ -523,7 +529,7 @@ void S_StopAllSounds (qboolean clear) S_ClearBuffer (); } -void S_StopAllSoundsC (void) +static void S_StopAllSoundsC (void) { S_StopAllSounds (true); } @@ -601,17 +607,15 @@ void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation) S_UpdateAmbientSounds =================== */ -void S_UpdateAmbientSounds (void) +static void S_UpdateAmbientSounds (void) { mleaf_t *l; int vol, ambient_channel; channel_t *chan; - //johnfitz -- no ambients when disconnected +// no ambients when disconnected if (cls.state != ca_connected) return; - //johnfitz - // calc ambient sound levels if (!cl.worldmodel) return; @@ -856,7 +860,7 @@ void S_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) S_Update_(); } -void GetSoundtime (void) +static void GetSoundtime (void) { int samplepos; static int buffers; @@ -872,7 +876,6 @@ void GetSoundtime (void) #else samplepos = SNDDMA_GetDMAPos(); - if (samplepos < oldsamplepos) { buffers++; // buffer wrapped @@ -892,15 +895,13 @@ void GetSoundtime (void) void S_ExtraUpdate (void) { - if (snd_noextraupdate.value) return; // don't pollute timings S_Update_(); } -void S_Update_(void) +static void S_Update_ (void) { -#if 1 unsigned int endtime; int samps; @@ -929,7 +930,6 @@ void S_Update_(void) S_PaintChannels (endtime); SNDDMA_Submit (); -#endif } void S_BlockSound (void) @@ -966,7 +966,7 @@ console functions =============================================================================== */ -void S_Play (void) +static void S_Play (void) { static int hash = 345; int i; @@ -989,7 +989,7 @@ void S_Play (void) } } -void S_PlayVol (void) +static void S_PlayVol (void) { static int hash = 543; int i; @@ -1010,11 +1010,11 @@ void S_PlayVol (void) sfx = S_PrecacheSound(name); vol = Q_atof(Cmd_Argv(i + 1)); S_StartSound(hash++, 0, sfx, listener_origin, vol, 1.0); - i+=2; + i += 2; } } -void S_SoundList (void) +static void S_SoundList (void) { int i; sfx_t *sfx; @@ -1033,7 +1033,7 @@ void S_SoundList (void) Con_SafePrintf ("L"); //johnfitz -- was Con_Printf else Con_SafePrintf (" "); //johnfitz -- was Con_Printf - Con_SafePrintf("(%2db) %6i : %s\n",sc->width*8, size, sfx->name); //johnfitz -- was Con_Printf + Con_SafePrintf("(%2db) %6i : %s\n", sc->width*8, size, sfx->name); //johnfitz -- was Con_Printf } Con_Printf ("%i sounds, %i bytes\n", num_sfx, total); //johnfitz -- added count } diff --git a/Quake/snd_mem.c b/Quake/snd_mem.c index 553c1987..b9cf7bb9 100644 --- a/Quake/snd_mem.c +++ b/Quake/snd_mem.c @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ResampleSfx ================ */ -void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data) +static void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data) { int outcount; int srcsample; @@ -59,16 +59,15 @@ void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data) if (stepscale == 1 && inwidth == 1 && sc->width == 1) { // fast special case - for (i=0 ; idata)[i] - = (int)( (unsigned char)(data[i]) - 128); + for (i = 0; i < outcount; i++) + ((signed char *)sc->data)[i] = (int)( (unsigned char)(data[i]) - 128); } else { // general case samplefrac = 0; fracstep = stepscale*256; - for (i=0 ; i> 8; samplefrac += fracstep; @@ -112,7 +111,7 @@ sfxcache_t *S_LoadSound (sfx_t *s) Q_strcpy(namebuffer, "sound/"); Q_strcat(namebuffer, s->name); -// Con_Printf ("loading %s\n", namebuffer); +// Con_Printf ("loading %s\n",namebuffer); data = COM_LoadStackFile(namebuffer, stackbuf, sizeof(stackbuf)); @@ -171,15 +170,13 @@ WAV loading =============================================================================== */ +static byte *data_p; +static byte *iff_end; +static byte *last_chunk; +static byte *iff_data; +static int iff_chunk_len; -byte *data_p; -byte *iff_end; -byte *last_chunk; -byte *iff_data; -int iff_chunk_len; - - -short GetLittleShort(void) +static short GetLittleShort (void) { short val = 0; val = *data_p; @@ -188,7 +185,7 @@ short GetLittleShort(void) return val; } -int GetLittleLong(void) +static int GetLittleLong (void) { int val = 0; val = *data_p; @@ -199,7 +196,7 @@ int GetLittleLong(void) return val; } -void FindNextChunk(const char *name) +static void FindNextChunk (const char *name) { while (1) { @@ -225,14 +222,14 @@ void FindNextChunk(const char *name) } } -void FindChunk(const char *name) +static void FindChunk (const char *name) { last_chunk = iff_data; FindNextChunk (name); } #if 0 -void DumpChunks(void) +static void DumpChunks (void) { char str[5]; @@ -243,7 +240,7 @@ void DumpChunks(void) memcpy (str, data_p, 4); data_p += 4; iff_chunk_len = GetLittleLong(); - Con_Printf ("%p : %s (%d)\n", (data_p - 4), str, iff_chunk_len); + Con_Printf ("0x%x : %s (%d)\n", (int)(data_p - 4), str, iff_chunk_len); data_p += (iff_chunk_len + 1) & ~1; } while (data_p < iff_end); } @@ -257,9 +254,9 @@ GetWavinfo wavinfo_t GetWavinfo (const char *name, byte *wav, int wavlength) { wavinfo_t info; - int i; - int format; - int samples; + int i; + int format; + int samples; memset (&info, 0, sizeof(info)); @@ -299,7 +296,7 @@ wavinfo_t GetWavinfo (const char *name, byte *wav, int wavlength) info.channels = GetLittleShort(); info.rate = GetLittleLong(); - data_p += 4+2; + data_p += 4 + 2; info.width = GetLittleShort() / 8; // get cue chunk @@ -308,6 +305,7 @@ wavinfo_t GetWavinfo (const char *name, byte *wav, int wavlength) { data_p += 32; info.loopstart = GetLittleLong(); + // Con_Printf("loopstart=%d\n", sfx->loopstart); // if the next chunk is a LIST chunk, look for a cue length marker FindNextChunk ("LIST"); @@ -316,9 +314,9 @@ wavinfo_t GetWavinfo (const char *name, byte *wav, int wavlength) if (!strncmp((char *)data_p + 28, "mark", 4)) { // this is not a proper parse, but it works with cooledit... data_p += 24; - i = GetLittleLong (); // samples in loop + i = GetLittleLong(); // samples in loop info.samples = info.loopstart + i; -// Con_Printf("looped length: %i\n", i); + // Con_Printf("looped length: %i\n", i); } } } @@ -334,7 +332,7 @@ wavinfo_t GetWavinfo (const char *name, byte *wav, int wavlength) } data_p += 4; - samples = GetLittleLong () / info.width; + samples = GetLittleLong() / info.width; if (info.samples) { diff --git a/Quake/snd_mix.c b/Quake/snd_mix.c index c92bb644..2bfbb070 100644 --- a/Quake/snd_mix.c +++ b/Quake/snd_mix.c @@ -31,9 +31,7 @@ short *snd_out; static int snd_vol; -void Snd_WriteLinearBlastStereo16 (void); - -void Snd_WriteLinearBlastStereo16 (void) +static void Snd_WriteLinearBlastStereo16 (void) { int i; int val; @@ -58,7 +56,7 @@ void Snd_WriteLinearBlastStereo16 (void) } } -void S_TransferStereo16 (int endtime) +static void S_TransferStereo16 (int endtime) { int lpos; int lpaintedtime; @@ -87,7 +85,7 @@ void S_TransferStereo16 (int endtime) } } -void S_TransferPaintBuffer(int endtime) +static void S_TransferPaintBuffer (int endtime) { int out_idx, out_mask; int count, step, val; @@ -146,8 +144,8 @@ CHANNEL MIXING =============================================================================== */ -void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int endtime); -void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime); +static void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int endtime); +static void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime); void S_PaintChannels (int endtime) { @@ -268,7 +266,7 @@ void SND_InitScaletable (void) } -void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count) +static void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count) { int data; int *lscale, *rscale; @@ -294,7 +292,7 @@ void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count) ch->pos += count; } -void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count) +static void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count) { int data; int left, right; diff --git a/Quake/snd_sdl.c b/Quake/snd_sdl.c index 80769024..2498ee41 100644 --- a/Quake/snd_sdl.c +++ b/Quake/snd_sdl.c @@ -71,7 +71,7 @@ static void paint_audio (void *unused, Uint8 *stream, int len) shm->samplepos = 0; } -qboolean SNDDMA_Init (void) +qboolean SNDDMA_Init (dma_t *dma) { SDL_AudioSpec desired, obtained; int tmp, val; @@ -120,8 +120,8 @@ qboolean SNDDMA_Init (void) return false; } - memset ((void *) &sn, 0, sizeof(dma_t)); - shm = &sn; + memset ((void *) dma, 0, sizeof(dma_t)); + shm = dma; /* Fill the audio DMA information block */ shm->samplebits = (obtained.format & 0xFF); /* first byte of format is bits */