diff --git a/libs/audio/targets/snd_alsa_0_9.c b/libs/audio/targets/snd_alsa_0_9.c index 1a7eb2c07..e64265e99 100644 --- a/libs/audio/targets/snd_alsa_0_9.c +++ b/libs/audio/targets/snd_alsa_0_9.c @@ -32,19 +32,17 @@ #endif #include - #include -#include "QF/cvar.h" -#include "QF/sound.h" -#include "QF/qargs.h" #include "QF/console.h" +#include "QF/cvar.h" #include "QF/plugin.h" +#include "QF/qargs.h" +#include "QF/sound.h" static int snd_inited; static snd_pcm_t *pcm; -//static const snd_pcm_channel_area_t *mmap_areas; static const char *pcmname = NULL; size_t buffer_size; @@ -102,10 +100,12 @@ SNDDMA_Init (void) if (snd_pcm_hw_params_set_rate_near (pcm, hw, 44100, 0) >= 0) { frag_size = 256; /* assuming stereo 8 bit */ rate = 44100; - } else if (snd_pcm_hw_params_set_rate_near (pcm, hw, 22050, 0) >= 0) { + } else if (snd_pcm_hw_params_set_rate_near (pcm, hw, 22050, 0) >= + 0) { frag_size = 128; /* assuming stereo 8 bit */ rate = 22050; - } else if (snd_pcm_hw_params_set_rate_near (pcm, hw, 11025, 0) >= 0) { + } else if (snd_pcm_hw_params_set_rate_near (pcm, hw, 11025, 0) >= + 0) { frag_size = 64; /* assuming stereo 8 bit */ rate = 11025; } else { @@ -128,10 +128,11 @@ SNDDMA_Init (void) switch (bps) { case -1: - if (snd_pcm_hw_params_set_format (pcm, hw, SND_PCM_FORMAT_S16_LE) >= - 0) { + if (snd_pcm_hw_params_set_format (pcm, hw, SND_PCM_FORMAT_S16_LE) + >= 0) { bps = 16; - } else if (snd_pcm_hw_params_set_format (pcm, hw, SND_PCM_FORMAT_U8) + } else if (snd_pcm_hw_params_set_format (pcm, hw, + SND_PCM_FORMAT_U8) >= 0) { bps = 8; } else { @@ -188,9 +189,7 @@ SNDDMA_Init (void) } snd_pcm_sw_params_current (pcm, sw); -// snd_pcm_sw_params_set_start_mode (pcm, sw, SND_PCM_START_EXPLICIT); snd_pcm_sw_params_set_start_threshold (pcm, sw, ~0U); -// snd_pcm_sw_params_set_xrun_mode (pcm, sw, SND_PCM_XRUN_NONE); snd_pcm_sw_params_set_stop_threshold (pcm, sw, ~0U); err = snd_pcm_sw_params (pcm, sw); @@ -199,8 +198,6 @@ SNDDMA_Init (void) goto error; } - //mmap_areas = snd_pcm_mmap_running_areas (pcm); - shm = &sn; memset ((dma_t *) shm, 0, sizeof (*shm)); shm->splitbuffer = 0; @@ -213,7 +210,6 @@ SNDDMA_Init (void) shm->samples = buffer_size * shm->channels; // mono samples in buffer shm->speed = rate; SNDDMA_GetDMAPos ();//XXX sets shm->buffer - //shm->buffer = (unsigned char *) mmap_areas->addr; Con_Printf ("%5d stereo\n", shm->channels - 1); Con_Printf ("%5d samples\n", shm->samples); Con_Printf ("%5d samplepos\n", shm->samplepos); @@ -225,12 +221,11 @@ SNDDMA_Init (void) snd_inited = 1; return 1; - error: +error: snd_pcm_close (pcm); return 0; } - int SNDDMA_GetDMAPos (void) { @@ -249,7 +244,6 @@ SNDDMA_GetDMAPos (void) return shm->samplepos; } - void SNDDMA_Shutdown (void) { @@ -259,7 +253,6 @@ SNDDMA_Shutdown (void) } } - /* SNDDMA_Submit @@ -296,7 +289,6 @@ SNDDMA_Submit (void) } } - plugin_t * PluginInfo (void) { diff --git a/libs/audio/targets/snd_disk.c b/libs/audio/targets/snd_disk.c index 839017314..1fec3ad3a 100644 --- a/libs/audio/targets/snd_disk.c +++ b/libs/audio/targets/snd_disk.c @@ -62,6 +62,7 @@ general_funcs_t plugin_info_general_funcs; sound_data_t plugin_info_sound_data; sound_funcs_t plugin_info_sound_funcs; + qboolean SNDDMA_Init (void) { @@ -133,7 +134,9 @@ PluginInfo (void) { plugin_info.plugin_version = "0.1"; plugin_info.description = "disk output"; plugin_info.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n" - "Copyright (C) 1999,2000,2001 contributors of the QuakeForge project\n" "Please see the file \"AUTHORS\" for a list of contributors"; + "Copyright (C) 1999,2000,2001 contributors of the QuakeForge " + "project\n" + "Please see the file \"AUTHORS\" for a list of contributors"; plugin_info.functions = &plugin_info_funcs; plugin_info.data = &plugin_info_data; diff --git a/libs/audio/targets/snd_dma.c b/libs/audio/targets/snd_dma.c index c1de9ca68..253559850 100644 --- a/libs/audio/targets/snd_dma.c +++ b/libs/audio/targets/snd_dma.c @@ -142,14 +142,12 @@ SND_AmbientOff (void) snd_ambient = false; } - void SND_AmbientOn (void) { snd_ambient = true; } - void SND_SoundInfo_f (void) { @@ -168,7 +166,6 @@ SND_SoundInfo_f (void) Con_Printf ("%5d total_channels\n", total_channels); } - void SND_Startup (void) { @@ -192,7 +189,6 @@ SND_Startup (void) sound_started = 1; } - void SND_Init (void) { @@ -224,7 +220,6 @@ SND_Init (void) // Con_Printf ("loading all sounds as 8bit\n"); // } - snd_initialized = true; SND_Startup (); @@ -265,7 +260,6 @@ SND_Init (void) SND_StopAllSounds (true); } - void SND_Init_Cvars (void) { @@ -308,7 +302,6 @@ SND_Init_Cvars (void) "max stereo volume separation. 1.0 is max"); } - // Shutdown sound engine ====================================================== void SND_Shutdown (void) @@ -329,7 +322,6 @@ SND_Shutdown (void) shm = 0; } - // Load a sound =============================================================== sfx_t * SND_FindName (const char *name) @@ -360,7 +352,6 @@ SND_FindName (const char *name) return sfx; } - void SND_TouchSound (const char *name) { @@ -373,7 +364,6 @@ SND_TouchSound (const char *name) Cache_Check (&sfx->cache); } - sfx_t * SND_PrecacheSound (const char *name) { @@ -391,10 +381,8 @@ SND_PrecacheSound (const char *name) return sfx; } - //============================================================================= - channel_t * SND_PickChannel (int entnum, int entchannel) { @@ -409,7 +397,8 @@ SND_PickChannel (int entnum, int entchannel) ch_idx++) { if (entchannel != 0 // channel 0 never overrides && channels[ch_idx].entnum == entnum - && (channels[ch_idx].entchannel == entchannel || entchannel == -1)) { + && (channels[ch_idx].entchannel == entchannel || + entchannel == -1)) { // always override sound from same entity first_to_die = ch_idx; break; @@ -435,7 +424,6 @@ SND_PickChannel (int entnum, int entchannel) return &channels[first_to_die]; } - void SND_Spatialize (channel_t *ch) { @@ -486,11 +474,10 @@ SND_Spatialize (channel_t *ch) ch->phase = phase; } - // Start a sound effect ======================================================= void -SND_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, - float attenuation) +SND_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, + float fvol, float attenuation) { channel_t *target_chan, *check; sfxcache_t *sc; @@ -556,7 +543,6 @@ SND_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvo } } - void SND_StopSound (int entnum, int entchannel) { @@ -572,7 +558,6 @@ SND_StopSound (int entnum, int entchannel) } } - void SND_StopAllSounds (qboolean clear) { @@ -593,14 +578,12 @@ SND_StopAllSounds (qboolean clear) SND_ClearBuffer (); } - void SND_StopAllSoundsC (void) { SND_StopAllSounds (true); } - void SND_ClearBuffer (void) { @@ -628,7 +611,6 @@ SND_ClearBuffer (void) } } - void SND_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation) { @@ -665,10 +647,8 @@ SND_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation) ss->oldphase = ss->phase; } - //============================================================================= - void SND_UpdateAmbientSounds (void) { @@ -692,7 +672,8 @@ SND_UpdateAmbientSounds (void) return; } - for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS; ambient_channel++) { + for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS; + ambient_channel++) { chan = &channels[ambient_channel]; chan->sfx = ambient_sfx[ambient_channel]; @@ -717,7 +698,6 @@ SND_UpdateAmbientSounds (void) } } - /* SND_Update @@ -767,7 +747,8 @@ SND_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) } // search for one combine = channels + MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; - for (j = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; j < i; j++, combine++) + for (j = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; j < i; j++, + combine++) if (combine->sfx == ch->sfx) break; @@ -782,8 +763,6 @@ SND_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) continue; } } - - } // debugging output @@ -804,7 +783,6 @@ SND_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) SND_Update_ (); } - void SND_GetSoundtime (void) { @@ -834,7 +812,6 @@ SND_GetSoundtime (void) soundtime = buffers * fullsamples + samplepos / shm->channels; } - void SND_ExtraUpdate (void) { @@ -843,7 +820,6 @@ SND_ExtraUpdate (void) SND_Update_ (); } - void SND_Update_ (void) { @@ -877,12 +853,10 @@ SND_Update_ (void) SNDDMA_Submit (); } - /* console functions */ - void SND_Play (void) { @@ -904,7 +878,6 @@ SND_Play (void) } } - void SND_PlayVol (void) { @@ -928,7 +901,6 @@ SND_PlayVol (void) } } - void SND_SoundList (void) { @@ -953,7 +925,6 @@ SND_SoundList (void) Con_Printf ("Total resident: %i\n", total); } - void SND_LocalSound (const char *sound) { @@ -969,22 +940,20 @@ SND_LocalSound (const char *sound) Con_Printf ("S_LocalSound: can't cache %s\n", sound); return; } - SND_StartSound (*plugin_info_sound_data.viewentity, -1, sfx, vec3_origin, 1, 1); + SND_StartSound (*plugin_info_sound_data.viewentity, -1, sfx, vec3_origin, + 1, 1); } - void SND_ClearPrecache (void) { } - void SND_BeginPrecaching (void) { } - void SND_EndPrecaching (void) { diff --git a/libs/audio/targets/snd_mem.c b/libs/audio/targets/snd_mem.c index 3c050ba3a..bdaa74ce4 100644 --- a/libs/audio/targets/snd_mem.c +++ b/libs/audio/targets/snd_mem.c @@ -48,9 +48,7 @@ int cache_full_cycle; byte *SND_Alloc (int size); wavinfo_t SND_GetWavinfo (char *name, byte * wav, int wavlength); -/* - SND_ResampleSfx -*/ + void SND_ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte * data) { @@ -72,9 +70,7 @@ SND_ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte * data) ib = data; ob = sc->data; - stepscale = (float) inrate / shm->speed; // this is usually 0.5, 1, or - // - // 2 + stepscale = (float) inrate / shm->speed; // usually 0.5, 1, or 2 outcount = sc->length / stepscale; @@ -164,9 +160,6 @@ SND_ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte * data) //============================================================================= -/* - SND_LoadSound -*/ sfxcache_t * SND_LoadSound (sfx_t *s) { @@ -178,18 +171,15 @@ SND_LoadSound (sfx_t *s) sfxcache_t *sc; byte stackbuf[1 * 1024]; // avoid dirtying the cache heap -// see if still in memory + // see if still in memory sc = Cache_Check (&s->cache); if (sc) return sc; -//Con_Printf ("S_LoadSound: %x\n", (int)stackbuf); -// load it in + // load it in strcpy (namebuffer, "sound/"); strncat (namebuffer, s->name, sizeof (namebuffer) - strlen (namebuffer)); -// Con_Printf ("loading %s\n",namebuffer); - data = COM_LoadStackFile (namebuffer, stackbuf, sizeof (stackbuf)); if (!data) { @@ -228,20 +218,16 @@ SND_LoadSound (sfx_t *s) return sc; } - - /* WAV loading */ - byte *data_p; byte *iff_end; byte *last_chunk; byte *iff_data; int iff_chunk_len; - short SND_GetLittleShort (void) { @@ -283,8 +269,7 @@ SND_FindNexctChunk (char *name) data_p = NULL; return; } -// if (iff_chunk_len > 1024*1024) -// Sys_Error ("SND_FindNexctChunk: %i length is past the 1 meg sanity limit", iff_chunk_len); + data_p -= 8; last_chunk = data_p + 8 + ((iff_chunk_len + 1) & ~1); if (!strncmp (data_p, name, 4)) @@ -299,7 +284,6 @@ SND_FindChunk (char *name) SND_FindNexctChunk (name); } - void SND_DumpChunks (void) { @@ -311,14 +295,12 @@ SND_DumpChunks (void) memcpy (str, data_p, 4); data_p += 4; iff_chunk_len = SND_GetLittleLong (); - Con_Printf ("0x%x : %s (%d)\n", (int) (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); } -/* - SND_GetWavinfo -*/ wavinfo_t SND_GetWavinfo (char *name, byte * wav, int wavlength) { @@ -335,15 +317,15 @@ SND_GetWavinfo (char *name, byte * wav, int wavlength) iff_data = wav; iff_end = wav + wavlength; -// find "RIFF" chunk + // find "RIFF" chunk SND_FindChunk ("RIFF"); if (!(data_p && !strncmp (data_p + 8, "WAVE", 4))) { Con_Printf ("Missing RIFF/WAVE chunks\n"); return info; } -// get "fmt " chunk + // get "fmt " chunk iff_data = data_p + 12; -// SND_DumpChunks (); +// SND_DumpChunks (); SND_FindChunk ("fmt "); if (!data_p) { @@ -362,30 +344,26 @@ SND_GetWavinfo (char *name, byte * wav, int wavlength) data_p += 4 + 2; info.width = SND_GetLittleShort () / 8; -// get cue chunk + // get cue chunk SND_FindChunk ("cue "); if (data_p) { data_p += 32; info.loopstart = SND_GetLittleLong (); -// Con_Printf("loopstart=%d\n", sfx->loopstart); // if the next chunk is a LIST chunk, look for a cue length marker SND_FindNexctChunk ("LIST"); if (data_p) { - if (!strncmp (data_p + 28, "mark", 4)) { // this is not a - // proper parse, but - // it works with - // cooledit... + if (!strncmp (data_p + 28, "mark", 4)) { + // this is not a proper parse, but it works with cooledit... data_p += 24; i = SND_GetLittleLong (); // samples in loop info.samples = info.loopstart + i; -// Con_Printf("looped length: %i\n", i); } } } else info.loopstart = -1; -// find data chunk + // find data chunk SND_FindChunk ("data"); if (!data_p) { Con_Printf ("Missing data chunk\n"); diff --git a/libs/audio/targets/snd_mix.c b/libs/audio/targets/snd_mix.c index fadb8ca5b..4a79556cf 100644 --- a/libs/audio/targets/snd_mix.c +++ b/libs/audio/targets/snd_mix.c @@ -36,11 +36,12 @@ # include #endif -#include "compat.h" #include "QF/console.h" #include "QF/cvar.h" #include "QF/sound.h" +#include "compat.h" + #ifdef _WIN32 # include "winquake.h" #else @@ -59,6 +60,7 @@ short *snd_out; void SND_WriteLinearBlastStereo16 (void); sfxcache_t *SND_LoadSound (sfx_t *s); + #ifndef USE_INTEL_ASM void SND_WriteLinearBlastStereo16 (void) @@ -206,13 +208,12 @@ SND_TransferPaintBuffer (int endtime) #endif } - /* CHANNEL MIXING */ -void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int endtime); -void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime); +void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int endtime); +void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime); void SND_PaintChannels (int endtime) @@ -297,9 +298,7 @@ SND_InitScaletable (void) snd_scaletable[i][j] = ((signed char) j) * i * 8; } - #ifndef USE_INTEL_ASM - void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count) { @@ -325,10 +324,8 @@ SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count) ch->pos += count; } - #endif // !USE_INTEL_ASM - void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count) { diff --git a/libs/audio/targets/snd_null.c b/libs/audio/targets/snd_null.c index 66765fff4..df55f1ed7 100644 --- a/libs/audio/targets/snd_null.c +++ b/libs/audio/targets/snd_null.c @@ -37,6 +37,7 @@ // Various variables also defined in snd_dma.c // FIXME - should be put in one place // ======================================================================= + extern channel_t channels[MAX_CHANNELS]; extern int total_channels; extern volatile dma_t *shm; @@ -58,6 +59,7 @@ sound_funcs_t plugin_info_sound_funcs; void SND_Init_Cvars (void); + void SND_Init (void) { @@ -176,7 +178,8 @@ PluginInfo (void) { plugin_info.plugin_version = "0.1"; plugin_info.description = "ALSA 0.5.x digital output"; plugin_info.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n" - "Copyright (C) 1999,2000,2001 contributors of the QuakeForge project\n" + "Copyright (C) 1999,2000,2001 contributors of the QuakeForge " + "project\n" "Please see the file \"AUTHORS\" for a list of contributors"; plugin_info.functions = &plugin_info_funcs; plugin_info.data = &plugin_info_data; diff --git a/libs/audio/targets/snd_oss.c b/libs/audio/targets/snd_oss.c index f9520af2d..cf2b96921 100644 --- a/libs/audio/targets/snd_oss.c +++ b/libs/audio/targets/snd_oss.c @@ -29,6 +29,19 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif +#ifdef HAVE_SYS_IOCTL_H +# include +#endif +#ifdef HAVE_SYS_MMAN_H +# include +#endif +#if defined HAVE_SYS_SOUNDCARD_H +# include +#elif defined HAVE_LINUX_SOUNDCARD_H +# include +#elif HAVE_MACHINE_SOUNDCARD_H +# include +#endif #include #include @@ -39,22 +52,6 @@ #include #include -#ifdef HAVE_SYS_IOCTL_H -# include -#endif - -#ifdef HAVE_SYS_MMAN_H -# include -#endif - -#if defined HAVE_SYS_SOUNDCARD_H -# include -#elif defined HAVE_LINUX_SOUNDCARD_H -# include -#elif HAVE_MACHINE_SOUNDCARD_H -# include -#endif - #include "QF/cmd.h" #include "QF/console.h" #include "QF/cvar.h" diff --git a/libs/audio/targets/snd_sdl.c b/libs/audio/targets/snd_sdl.c index ccdde883d..e663d2b7a 100644 --- a/libs/audio/targets/snd_sdl.c +++ b/libs/audio/targets/snd_sdl.c @@ -61,6 +61,7 @@ general_funcs_t plugin_info_general_funcs; sound_data_t plugin_info_sound_data; sound_funcs_t plugin_info_sound_funcs; + static void paint_audio (void *unused, Uint8 * stream, int len) { @@ -81,8 +82,10 @@ paint_audio (void *unused, Uint8 * stream, int len) if (shm->samplepos + streamsamples <= shm->samples) memcpy (stream, shm->buffer + sampleposbytes, len); else { - memcpy (stream, shm->buffer + sampleposbytes, samplesbytes - sampleposbytes); - memcpy (stream + samplesbytes - sampleposbytes, shm->buffer, len - (samplesbytes - sampleposbytes)); + memcpy (stream, shm->buffer + sampleposbytes, samplesbytes - + sampleposbytes); + memcpy (stream + samplesbytes - sampleposbytes, shm->buffer, len - + (samplesbytes - sampleposbytes)); } soundtime += streamsamples; } @@ -187,11 +190,9 @@ SNDDMA_Shutdown (void) } /* - SNDDMA_Submit Send sound to device if buffer isn't really the dma buffer - */ void SNDDMA_Submit (void) @@ -210,7 +211,9 @@ PluginInfo (void) { plugin_info.plugin_version = "0.1"; plugin_info.description = "SDL digital output"; plugin_info.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n" - "Copyright (C) 1999,2000,2001 contributors of the QuakeForge project\n" "Please see the file \"AUTHORS\" for a list of contributors"; + "Copyright (C) 1999,2000,2001 contributors of the QuakeForge " + "project\n" + "Please see the file \"AUTHORS\" for a list of contributors"; plugin_info.functions = &plugin_info_funcs; plugin_info.data = &plugin_info_data;