Lots of whitespace, header cleanups, and a few tiny optimizations.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2001-09-09 21:41:35 +00:00
parent 8a959d157b
commit 7af79b96ec
23 changed files with 423 additions and 522 deletions

View file

@ -372,9 +372,7 @@ SND_PrecacheSound (const char *name)
channel_t *
SND_PickChannel (int entnum, int entchannel)
{
int ch_idx;
int first_to_die;
int life_left;
int ch_idx, first_to_die, life_left;
// Check for replacement sound, or find the best one to replace
first_to_die = -1;
@ -413,10 +411,8 @@ SND_PickChannel (int entnum, int entchannel)
void
SND_Spatialize (channel_t *ch)
{
vec_t dot;
vec_t dist;
int phase; // in samples
vec_t lscale, rscale, scale;
vec_t dist, dot, lscale, rscale, scale;
vec3_t source_vec;
// anything coming from the view entity will always be full volume
@ -463,11 +459,9 @@ void
SND_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin,
float fvol, float attenuation)
{
int ch_idx, skip, vol;
channel_t *target_chan, *check;
sfxcache_t *sc;
int vol;
int ch_idx;
int skip;
if (!sound_started)
return;
@ -524,7 +518,6 @@ SND_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin,
target_chan->end -= skip;
break;
}
}
}
@ -642,10 +635,10 @@ SND_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
void
SND_UpdateAmbientSounds (void)
{
mleaf_t *l;
float vol;
int ambient_channel;
channel_t *chan;
mleaf_t *l;
if (!snd_ambient)
return;
@ -697,10 +690,8 @@ SND_UpdateAmbientSounds (void)
void
SND_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
{
int i, j;
int total;
channel_t *ch;
channel_t *combine;
int total, i, j;
channel_t *ch, *combine;
if (!sound_started || (snd_blocked > 0))
return;
@ -777,10 +768,8 @@ SND_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
void
SND_GetSoundtime (void)
{
int samplepos;
static int buffers;
static int oldsamplepos;
int fullsamples;
int fullsamples, samplepos;
static int buffers, oldsamplepos;
fullsamples = shm->samples / shm->channels;
@ -814,8 +803,8 @@ SND_ExtraUpdate (void)
void
SND_Update_ (void)
{
unsigned int endtime;
int samps;
int samps;
unsigned int endtime;
if (!sound_started || (snd_blocked > 0))
return;
@ -848,9 +837,9 @@ SND_Update_ (void)
void
SND_Play (void)
{
static int hash = 345;
int i;
char name[256];
int i;
static int hash = 345;
sfx_t *sfx;
i = 1;
@ -869,10 +858,10 @@ SND_Play (void)
void
SND_PlayVol (void)
{
static int hash = 543;
int i;
float vol;
char name[256];
float vol;
int i;
static int hash = 543;
sfx_t *sfx;
i = 1;
@ -892,11 +881,9 @@ SND_PlayVol (void)
void
SND_SoundList (void)
{
int i;
int load, size, total, i;
sfx_t *sfx;
sfxcache_t *sc;
int size, total;
int load;
if (Cmd_Argc() >= 2 && Cmd_Argv (1)[0])
load = 1;
@ -977,7 +964,8 @@ SND_UnblockSound (void)
}
plugin_t *
snd_render_default_PluginInfo (void) {
snd_render_default_PluginInfo (void)
{
plugin_info.type = qfp_snd_render;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";

View file

@ -53,13 +53,10 @@ sfxcache_t *SND_LoadSound (sfx_t *sfx, cache_allocator_t allocator);
void
SND_ResampleSfx (sfxcache_t *sc, int inrate, int inwidth, byte * data)
{
int outcount;
int srcsample;
float stepscale;
int i;
int sample, samplefrac, fracstep;
short *is, *os;
unsigned char *ib, *ob;
int fracstep, outcount, sample, samplefrac, srcsample, i;
float stepscale;
short *is, *os;
is = (short *) data;
os = (short *) sc->data;
@ -99,8 +96,8 @@ SND_ResampleSfx (sfxcache_t *sc, int inrate, int inwidth, byte * data)
} else {
// general case
if (snd_interp->int_val && stepscale < 1) {
int points = 1 / stepscale;
int j;
int j;
int points = 1 / stepscale;
for (i = 0; i < sc->length; i++) {
int s1, s2;
@ -154,8 +151,6 @@ SND_ResampleSfx (sfxcache_t *sc, int inrate, int inwidth, byte * data)
sc->loopstart = sc->loopstart / stepscale;
}
//=============================================================================
sfxcache_t *
SND_LoadSound (sfx_t *sfx, cache_allocator_t allocator)
{
@ -217,16 +212,16 @@ SND_CallbackLoad (void *object, cache_allocator_t allocator)
/* WAV loading */
byte *data_p;
byte *iff_end;
byte *last_chunk;
byte *iff_data;
int iff_chunk_len;
byte *data_p;
byte *iff_end;
byte *last_chunk;
byte *iff_data;
int iff_chunk_len;
short
SND_GetLittleShort (void)
{
short val = 0;
short val = 0;
val = *data_p;
val = val + (*(data_p + 1) << 8);
@ -237,7 +232,7 @@ SND_GetLittleShort (void)
int
SND_GetLittleLong (void)
{
int val = 0;
int val = 0;
val = *data_p;
val = val + (*(data_p + 1) << 8);
@ -282,7 +277,7 @@ SND_FindChunk (char *name)
void
SND_DumpChunks (void)
{
char str[5];
char str[5];
str[4] = 0;
data_p = iff_data;
@ -299,10 +294,8 @@ SND_DumpChunks (void)
wavinfo_t
SND_GetWavinfo (const char *name, byte * wav, int wavlength)
{
wavinfo_t info;
int i;
int format;
int samples;
int format, samples, i;
wavinfo_t info;
memset (&info, 0, sizeof (info));

View file

@ -62,8 +62,7 @@ void SND_WriteLinearBlastStereo16 (void);
void
SND_WriteLinearBlastStereo16 (void)
{
int i;
int val;
int val, i;
for (i = 0; i < snd_linear_count; i += 2) {
val = (snd_p[i] * snd_vol) >> 8;
@ -88,9 +87,8 @@ SND_WriteLinearBlastStereo16 (void)
void
SND_TransferStereo16 (int endtime)
{
int lpos;
int lpaintedtime;
DWORD *pbuf;
int lpaintedtime, lpos;
DWORD *pbuf;
snd_vol = volume->value * 256;
@ -138,14 +136,9 @@ SND_TransferStereo16 (int endtime)
void
SND_TransferPaintBuffer (int endtime)
{
int out_idx;
int count;
int out_mask;
int *p;
int step;
int val;
int snd_vol;
DWORD *pbuf;
int count, out_idx, out_mask, snd_vol, step, val;
int *p;
DWORD *pbuf;
if (shm->samplebits == 16 && shm->channels == 2) {
SND_TransferStereo16 (endtime);
@ -213,11 +206,9 @@ void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime);
void
SND_PaintChannels (int endtime)
{
int i;
int end;
int end, ltime, count, i;
channel_t *ch;
sfxcache_t *sc;
int ltime, count;
while (paintedtime < endtime) {
// if paintbuffer is smaller than DMA buffer
@ -289,7 +280,7 @@ SND_PaintChannels (int endtime)
void
SND_InitScaletable (void)
{
int i, j;
int i, j;
for (i = 0; i < 32; i++)
for (j = 0; j < 256; j++)
@ -300,10 +291,9 @@ SND_InitScaletable (void)
void
SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count)
{
int data;
int *lscale, *rscale;
unsigned char *sfx;
int i;
unsigned char *sfx;
int data, i;
int *lscale, *rscale;
if (ch->leftvol > 255)
ch->leftvol = 255;
@ -327,12 +317,10 @@ SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count)
void
SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count)
{
int data;
int left, right;
int leftvol, rightvol;
signed short *sfx;
unsigned int i = 0;
unsigned int left_phase, right_phase; // Never allowed < 0 anyway
int data, left, right, leftvol, rightvol;
unsigned int left_phase, right_phase; // Never allowed < 0 anyway
unsigned int i = 0;
signed short *sfx;
leftvol = ch->leftvol;
rightvol = ch->rightvol;

View file

@ -30,25 +30,14 @@
*/
#include "QF/cvar.h"
#include "QF/sound.h"
#include "QF/plugin.h"
#include "QF/sound.h"
// =======================================================================
// 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;
extern cvar_t *snd_loadas8bit;
extern int paintedtime; // sample PAIRS
extern qboolean snd_initialized;
extern cvar_t *bgmvolume;
extern cvar_t *volume;
extern cvar_t *snd_interp;
plugin_t plugin_info;
plugin_data_t plugin_info_data;
plugin_funcs_t plugin_info_funcs;
@ -59,6 +48,17 @@ sound_funcs_t plugin_info_sound_funcs;
void SND_Init_Cvars (void);
extern int paintedtime; // sample PAIRS
extern int total_channels;
extern channel_t channels[MAX_CHANNELS];
extern volatile dma_t *shm;
extern qboolean snd_initialized;
extern cvar_t *bgmvolume;
extern cvar_t *volume;
extern cvar_t *snd_interp;
extern cvar_t *snd_loadas8bit;
void
SND_Init (void)

View file

@ -55,10 +55,9 @@ plugin_t *snd_render_module = NULL;
plugin_t *snd_output_module = NULL;
// FIXME: ewwwies
extern double host_frametime; // From host.h
extern struct model_s **snd_worldmodel;
extern int snd_viewentity;
extern double host_frametime; // From host.h
extern int snd_viewentity;
extern struct model_s **snd_worldmodel;
void

View file

@ -33,18 +33,13 @@
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_MMAN_H
# include <sys/mman.h>
#endif
#if defined HAVE_SYS_SOUNDCARD_H
#ifdef HAVE_SYS_SOUNDCARD_H
# include <sys/soundcard.h>
#elif defined HAVE_LINUX_SOUNDCARD_H
# include <linux/soundcard.h>
@ -52,7 +47,11 @@
# include <machine/soundcard.h>
#endif
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/asoundlib.h>
#include <sys/types.h>
#include "QF/console.h"
#include "QF/cvar.h"
@ -90,6 +89,7 @@ static general_funcs_t plugin_info_general_funcs;
static snd_output_data_t plugin_info_snd_output_data;
static snd_output_funcs_t plugin_info_snd_output_funcs;
static void
SNDDMA_Init_Cvars (void)
{
@ -106,9 +106,9 @@ SNDDMA_Init_Cvars (void)
static int
check_card (int card)
{
int rc;
snd_ctl_t *handle;
snd_ctl_hw_info_t info;
int rc;
if ((rc = snd_ctl_open (&handle, card)) < 0) {
Con_Printf ("Error: control open (%i): %s\n", card, snd_strerror (rc));
@ -144,9 +144,9 @@ check_card (int card)
static qboolean
SNDDMA_Init (void)
{
int rc = 0, i;
char *err_msg = "";
int rate = -1, format = -1, bps, stereo = -1, frag_size;
char *err_msg = "";
int bps, frag_size, i;
int format = -1, rate = -1, stereo = -1, rc = 0;
unsigned int mask;
mask = snd_cards_mask ();
@ -197,7 +197,8 @@ SNDDMA_Init (void)
if ((rc = snd_pcm_open (&pcm_handle, card, dev,
SND_PCM_OPEN_PLAYBACK
| SND_PCM_OPEN_NONBLOCK)) < 0) {
Con_Printf ("Error: audio open error: %s\n", snd_strerror (rc));
Con_Printf ("Error: audio open error: %s\n",
snd_strerror (rc));
return 0;
}
goto dev_openned;
@ -247,9 +248,9 @@ SNDDMA_Init (void)
frag_size /= 2;
}
// err_msg="audio flush";
// if ((rc=snd_pcm_channel_flush(pcm_handle, SND_PCM_CHANNEL_PLAYBACK))<0)
// goto error;
// err_msg="audio flush";
// if ((rc=snd_pcm_channel_flush(pcm_handle, SND_PCM_CHANNEL_PLAYBACK))<0)
// goto error;
err_msg = "audio munmap";
if ((rc = snd_pcm_munmap (pcm_handle, SND_PCM_CHANNEL_PLAYBACK)) < 0)
goto error;
@ -266,9 +267,9 @@ SNDDMA_Init (void)
params.buf.block.frag_size = frag_size;
params.buf.block.frags_min = 1;
params.buf.block.frags_max = -1;
// err_msg="audio flush";
// if ((rc=snd_pcm_channel_flush(pcm_handle, SND_PCM_CHANNEL_PLAYBACK))<0)
// goto error;
// err_msg="audio flush";
// if ((rc=snd_pcm_channel_flush(pcm_handle, SND_PCM_CHANNEL_PLAYBACK))<0)
// goto error;
err_msg = "audio params";
if ((rc = snd_pcm_channel_params (pcm_handle, &params)) < 0)
goto error;
@ -297,12 +298,8 @@ SNDDMA_Init (void)
shm->submission_chunk = 128; // don't mix less than this #
shm->samplepos = 0; // in mono samples
shm->samplebits = setup.format.format == SND_PCM_SFMT_S16_LE ? 16 : 8;
shm->samples =
setup.buf.block.frags * setup.buf.block.frag_size / (shm->samplebits / 8); // mono
//
// samples
// in
// buffer
shm->samples = setup.buf.block.frags * setup.buf.block.frag_size /
(shm->samplebits / 8); // mono samples in buffer
shm->speed = setup.format.rate;
shm->buffer = (unsigned char *) mmap_data;
Con_Printf ("%5d stereo\n", shm->channels - 1);
@ -328,9 +325,8 @@ SNDDMA_GetDMAPos (void)
{
if (!snd_inited)
return 0;
shm->samplepos =
(mmap_control->status.frag_io +
1) * setup.buf.block.frag_size / (shm->samplebits / 8);
shm->samplepos = (mmap_control->status.frag_io + 1) *
setup.buf.block.frag_size / (shm->samplebits / 8);
return shm->samplepos;
}
@ -351,10 +347,9 @@ SNDDMA_Shutdown (void)
static void
SNDDMA_Submit (void)
{
int count = *plugin_info_snd_output_data.paintedtime
- *plugin_info_snd_output_data.soundtime;
int i, s, e;
int rc;
int rc, e, i, s;
int count = (*plugin_info_snd_output_data.paintedtime -
*plugin_info_snd_output_data.soundtime);
if (snd_blocked)
return;
@ -366,18 +361,17 @@ SNDDMA_Submit (void)
mmap_control->fragments[i % setup.buf.block.frags].data = 1;
switch (mmap_control->status.status) {
case SND_PCM_STATUS_PREPARED:
if ((rc = snd_pcm_channel_go (pcm_handle, SND_PCM_CHANNEL_PLAYBACK))
< 0) {
Sys_Error ("unable to start playback. %s\n", snd_strerror (rc));
if ((rc = snd_pcm_channel_go (pcm_handle,
SND_PCM_CHANNEL_PLAYBACK)) < 0) {
Sys_Error ("unable to start playback. %s\n",
snd_strerror (rc));
}
break;
case SND_PCM_STATUS_RUNNING:
break;
case SND_PCM_STATUS_UNDERRUN:
if (
(rc =
snd_pcm_plugin_prepare (pcm_handle,
SND_PCM_CHANNEL_PLAYBACK)) < 0) {
if ((rc = snd_pcm_plugin_prepare (pcm_handle,
SND_PCM_CHANNEL_PLAYBACK)) < 0) {
Sys_Error ("underrun: playback channel prepare error. %s\n",
snd_strerror (rc));
}
@ -410,7 +404,9 @@ snd_output_alsa0_5_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" "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;
@ -426,10 +422,10 @@ snd_output_alsa0_5_PluginInfo (void) {
plugin_info_general_funcs.p_Shutdown = NULL;
plugin_info_snd_output_funcs.pS_O_Init = SNDDMA_Init;
plugin_info_snd_output_funcs.pS_O_Shutdown = SNDDMA_Shutdown;
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;
plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit;
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;
plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit;
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
return &plugin_info;
}

View file

@ -61,6 +61,7 @@ static general_funcs_t plugin_info_general_funcs;
static snd_output_data_t plugin_info_snd_output_data;
static snd_output_funcs_t plugin_info_snd_output_funcs;
void
static SNDDMA_Init_Cvars (void)
{
@ -79,10 +80,10 @@ static int SNDDMA_GetDMAPos (void);
static qboolean
SNDDMA_Init (void)
{
int err;
int rate = -1, bps = -1, stereo = -1, frag_size;
snd_pcm_hw_params_t *hw;
snd_pcm_sw_params_t *sw;
int err, frag_size;
int rate = -1, bps = -1, stereo = -1;
snd_pcm_hw_params_t *hw;
snd_pcm_sw_params_t *sw;
snd_pcm_hw_params_alloca (&hw);
snd_pcm_sw_params_alloca (&sw);
@ -115,7 +116,6 @@ SNDDMA_Init (void)
Con_Printf ("Using PCM %s.\n", pcmname);
snd_pcm_hw_params_any (pcm, hw);
switch (rate) {
case -1:
if (snd_pcm_hw_params_set_rate_near (pcm, hw, 44100, 0) >= 0) {
@ -250,9 +250,9 @@ error:
static int
SNDDMA_GetDMAPos (void)
{
const snd_pcm_channel_area_t *areas;
snd_pcm_uframes_t offset;
snd_pcm_uframes_t nframes = shm->samples/shm->channels;
const snd_pcm_channel_area_t *areas;
if (!snd_inited)
return 0;
@ -282,12 +282,12 @@ SNDDMA_Shutdown (void)
static void
SNDDMA_Submit (void)
{
snd_pcm_uframes_t offset;
snd_pcm_uframes_t nframes;
int state;
int count = (*plugin_info_snd_output_data.paintedtime -
*plugin_info_snd_output_data.soundtime);
const snd_pcm_channel_area_t *areas;
int state;
int count = *plugin_info_snd_output_data.paintedtime
- *plugin_info_snd_output_data.soundtime;
snd_pcm_uframes_t nframes;
snd_pcm_uframes_t offset;
if (snd_blocked)
return;
@ -330,33 +330,33 @@ SNDDMA_UnblockSound (void)
plugin_t *
snd_output_alsa0_9_PluginInfo (void)
{
plugin_info.type = qfp_snd_output;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "ALSA 0.9.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"
plugin_info.type = qfp_snd_output;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "ALSA 0.9.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"
"Please see the file \"AUTHORS\" for a list of contributors";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.snd_output = &plugin_info_snd_output_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.snd_output = &plugin_info_snd_output_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.snd_output = &plugin_info_snd_output_funcs;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.snd_output = &plugin_info_snd_output_funcs;
plugin_info_general_funcs.p_Init = SNDDMA_Init_Cvars;
plugin_info_general_funcs.p_Shutdown = NULL;
plugin_info_general_funcs.p_Init = SNDDMA_Init_Cvars;
plugin_info_general_funcs.p_Shutdown = NULL;
plugin_info_snd_output_funcs.pS_O_Init = SNDDMA_Init;
plugin_info_snd_output_funcs.pS_O_Shutdown = SNDDMA_Shutdown;
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;
plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit;
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;
plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit;
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
return &plugin_info;
return &plugin_info;
}

View file

@ -40,16 +40,16 @@
# include <strings.h>
#endif
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/sound.h"
#include "QF/qargs.h"
#include "QF/plugin.h"
#include "QF/qargs.h"
#include "QF/sound.h"
static int snd_inited;
static VFile *snd_file;
@ -64,6 +64,7 @@ static general_funcs_t plugin_info_general_funcs;
static snd_output_data_t plugin_info_snd_output_data;
static snd_output_funcs_t plugin_info_snd_output_funcs;
/* FIXME
static qboolean
SNDDMA_Init (void)
@ -122,8 +123,9 @@ SNDDMA_Shutdown (void)
static void
SNDDMA_Submit (void)
{
int count = (*plugin_info_snd_output_data.paintedtime
- *plugin_info_snd_output_data.soundtime) * shm->samplebits / 8;
int count = ((*plugin_info_snd_output_data.paintedtime -
*plugin_info_snd_output_data.soundtime) *
shm->samplebits / 8);
if (snd_blocked)
return;
@ -147,31 +149,31 @@ SNDDMA_UnblockSound (void)
plugin_t *
snd_output_disk_PluginInfo (void) {
plugin_info.type = qfp_snd_output;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "disk output";
plugin_info.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n"
plugin_info.type = qfp_snd_output;
plugin_info.api_version = QFPLUGIN_VERSION;
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";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.snd_output = &plugin_info_snd_output_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.snd_output = &plugin_info_snd_output_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.snd_output = &plugin_info_snd_output_funcs;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.snd_output = &plugin_info_snd_output_funcs;
// plugin_info_general_funcs.p_Init = SNDDMA_Init; // FIXME
plugin_info_general_funcs.p_Shutdown = SNDDMA_Shutdown;
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;
plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit;
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
// plugin_info_general_funcs.p_Init = SNDDMA_Init; // FIXME
plugin_info_general_funcs.p_Shutdown = SNDDMA_Shutdown;
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;
plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit;
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
return &plugin_info;
return &plugin_info;
}

View file

@ -51,7 +51,7 @@ static qboolean snd_firsttime = true, snd_iswave;
static int sample16;
static int snd_sent, snd_completed;
static int snd_blocked = 0;
static int snd_blocked = 0;
static HPSTR lpData;
static LPWAVEHDR lpWaveHdr;
@ -60,8 +60,7 @@ static DWORD gSndBufSize;
static volatile dma_t sn;
/* MME Callback function
*/
/* MME Callback function */
static void
mme_callback ( HANDLE h, UINT wMsg, DWORD instance, LPARAM p1, LPARAM p2 )
{
@ -70,12 +69,6 @@ mme_callback ( HANDLE h, UINT wMsg, DWORD instance, LPARAM p1, LPARAM p2 )
}
}
/*
==================
S_BlockSound
==================
*/
static void
S_BlockSound ( void )
{
@ -83,12 +76,6 @@ S_BlockSound ( void )
waveOutReset(hWaveOut);
}
/*
==================
S_UnblockSound
==================
*/
static void
S_UnblockSound ( void )
{
@ -97,12 +84,6 @@ S_UnblockSound ( void )
snd_blocked--;
}
/*
==================
FreeSound
==================
*/
static void
FreeSound ( void )
{
@ -130,17 +111,15 @@ FreeSound ( void )
/*
==================
SNDDM_InitWav
SNDDM_InitWav
Crappy windows multimedia base
==================
Crappy windows multimedia base
*/
static qboolean
SNDDMA_InitWav ( void )
{
int hr, i;
LPPCMWAVEFORMAT format;
int i, hr;
if ((format = (LPPCMWAVEFORMAT)
mmeAllocMem(sizeof(*format))) == NULL) {
@ -185,10 +164,9 @@ SNDDMA_InitWav ( void )
mmeFreeMem(format);
/*
* Allocate and lock memory for the waveform data. The memory
* for waveform data must be globally allocated with
* GMEM_MOVEABLE and GMEM_SHARE flags.
Allocate and lock memory for the waveform data. The memory
for waveform data must be globally allocated with
GMEM_MOVEABLE and GMEM_SHARE flags.
*/
gSndBufSize = WAV_BUFFERS*WAV_BUFFER_SIZE;
lpData = mmeAllocBuffer(gSndBufSize);
@ -200,10 +178,10 @@ SNDDMA_InitWav ( void )
memset (lpData, 0, gSndBufSize);
/*
* Allocate and lock memory for the header. This memory must
* also be globally allocated with GMEM_MOVEABLE and
* GMEM_SHARE flags.
*/
Allocate and lock memory for the header. This memory must
also be globally allocated with GMEM_MOVEABLE and
GMEM_SHARE flags.
*/
lpWaveHdr = mmeAllocMem(sizeof(WAVEHDR) * WAV_BUFFERS);
if (lpWaveHdr == NULL)
@ -235,14 +213,11 @@ SNDDMA_InitWav ( void )
}
/*
==================
SNDDMA_Init
SNDDMA_Init
Try to find a sound device to mix for.
Returns false if nothing is found.
==================
Try to find a sound device to mix for.
Returns false if nothing is found.
*/
static qboolean
SNDDMA_Init ( void )
{
@ -273,13 +248,11 @@ SNDDMA_Init ( void )
}
/*
==============
SNDDMA_GetDMAPos
SNDDMA_GetDMAPos
return the current sample position (in mono samples read)
inside the recirculating dma buffer, so the mixing code will know
how many sample are required to fill it up.
===============
return the current sample position (in mono samples read)
inside the recirculating dma buffer, so the mixing code will know
how many sample are required to fill it up.
*/
static int
SNDDMA_GetDMAPos ( void )
@ -298,17 +271,15 @@ SNDDMA_GetDMAPos ( void )
}
/*
==============
SNDDMA_Submit
SNDDMA_Submit
Send sound to device if buffer isn't really the dma buffer
===============
Send sound to device if buffer isn't really the dma buffer
*/
static void
SNDDMA_Submit ( void )
{
LPWAVEHDR h;
int wResult;
LPWAVEHDR h;
if (!wav_init) return;
@ -318,9 +289,7 @@ SNDDMA_Submit ( void )
Con_DPrintf ("Sound overrun\n");
}
//
// submit two new sound blocks
//
while (((snd_sent - snd_completed) >> sample16) < 4)
{
int i = (snd_sent&WAV_MASK);
@ -332,10 +301,10 @@ SNDDMA_Submit ( void )
snd_sent++;
/*
* Now the data block can be sent to the output device. The
* waveOutWrite function returns immediately and waveform
* data is sent to the output device in the background.
*/
Now the data block can be sent to the output device. The
waveOutWrite function returns immediately and waveform
data is sent to the output device in the background.
*/
wResult = waveOutWrite(hWaveOut, h, sizeof(WAVEHDR));
if (wResult != MMSYSERR_NOERROR)
@ -348,11 +317,9 @@ SNDDMA_Submit ( void )
}
/*
==============
SNDDMA_Shutdown
SNDDMA_Shutdown
Reset the sound device for exiting
===============
Reset the sound device for exiting
*/
static void
SNDDMA_Shutdown ( void )

View file

@ -30,8 +30,8 @@
*/
#include "QF/cvar.h"
#include "QF/sound.h"
#include "QF/plugin.h"
#include "QF/sound.h"
// =======================================================================
// Various variables also defined in snd_dma.c
@ -40,8 +40,8 @@
static cvar_t *bgmvolume;
static cvar_t *volume;
static cvar_t *snd_loadas8bit;
static cvar_t *snd_interp;
static cvar_t *snd_loadas8bit;
static plugin_t plugin_info;
static plugin_data_t plugin_info_data;
@ -104,8 +104,8 @@ SND_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
}
static 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)
{
}
@ -167,45 +167,45 @@ SND_UnblockSound (void)
plugin_t *
snd_output_null_PluginInfo (void) {
plugin_info.type = qfp_sound;
plugin_info.api_version = QFPLUGIN_VERSION;
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"
plugin_info.type = qfp_sound;
plugin_info.api_version = QFPLUGIN_VERSION;
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"
"Please see the file \"AUTHORS\" for a list of contributors";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = &plugin_info_sound_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = &plugin_info_sound_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_general_funcs.p_Init = SND_Init;
plugin_info_general_funcs.p_Shutdown = SND_Shutdown;
plugin_info_general_funcs.p_Init = SND_Init;
plugin_info_general_funcs.p_Shutdown = SND_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = SND_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = SND_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = SND_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = SND_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = SND_StaticSound;
plugin_info_sound_funcs.pS_StartSound = SND_StartSound;
plugin_info_sound_funcs.pS_StopSound = SND_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = SND_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = SND_ClearPrecache;
plugin_info_sound_funcs.pS_Update = SND_Update;
plugin_info_sound_funcs.pS_StopAllSounds = SND_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = SND_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = SND_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = SND_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = SND_LocalSound;
plugin_info_sound_funcs.pS_AmbientOff = SND_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = SND_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = SND_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = SND_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = SND_StaticSound;
plugin_info_sound_funcs.pS_StartSound = SND_StartSound;
plugin_info_sound_funcs.pS_StopSound = SND_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = SND_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = SND_ClearPrecache;
plugin_info_sound_funcs.pS_Update = SND_Update;
plugin_info_sound_funcs.pS_StopAllSounds = SND_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = SND_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = SND_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = SND_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = SND_LocalSound;
plugin_info_sound_funcs.pS_BlockSound = SND_BlockSound;
plugin_info_sound_funcs.pS_UnblockSound = SND_UnblockSound;
return &plugin_info;
return &plugin_info;
}

View file

@ -29,14 +29,13 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <sys/types.h>
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_MMAN_H
# include <sys/mman.h>
#endif
#if defined HAVE_SYS_SOUNDCARD_H
#ifdef HAVE_SYS_SOUNDCARD_H
# include <sys/soundcard.h>
#elif defined HAVE_LINUX_SOUNDCARD_H
# include <linux/soundcard.h>
@ -44,21 +43,21 @@
# include <machine/soundcard.h>
#endif
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/shm.h>
#include <sys/wait.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "QF/cmd.h"
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/plugin.h"
#include "QF/qargs.h"
#include "QF/sound.h"
#include "QF/plugin.h"
#ifndef MAP_FAILED
# define MAP_FAILED ((void *) -1)
@ -85,6 +84,7 @@ static general_funcs_t plugin_info_general_funcs;
static snd_output_data_t plugin_info_snd_output_data;
static snd_output_funcs_t plugin_info_snd_output_funcs;
static void
SNDDMA_Init_Cvars (void)
{
@ -103,13 +103,9 @@ SNDDMA_Init_Cvars (void)
static qboolean
SNDDMA_Init (void)
{
int rc;
int fmt;
int tmp;
int i;
int caps, fmt, rc, tmp, i;
int retries = 3;
struct audio_buf_info info;
int caps;
int retries = 3;
snd_inited = 0;
mmaped_io = snd_oss_mmaped->int_val;
@ -198,10 +194,9 @@ SNDDMA_Init (void)
if (mmaped_io) {
// memory map the dma buffer
shm->buffer = (unsigned char *) mmap (NULL, info.fragstotal
* info.fragsize,
PROT_WRITE, // was also | PROT_READ
MAP_FILE | MAP_SHARED, audio_fd, 0);
shm->buffer = (unsigned char *) mmap
(NULL, info.fragstotal * info.fragsize, PROT_WRITE,
MAP_FILE | MAP_SHARED, audio_fd, 0);
if (shm->buffer == MAP_FAILED) {
perror (snd_dev);
@ -267,8 +262,7 @@ SNDDMA_Init (void)
return 0;
}
// toggle the trigger & start her up
// toggle the trigger & start her up
tmp = 0;
rc = ioctl (audio_fd, SNDCTL_DSP_SETTRIGGER, &tmp);
if (rc < 0) {
@ -290,13 +284,11 @@ SNDDMA_Init (void)
snd_inited = 1;
return 1;
}
static int
SNDDMA_GetDMAPos (void)
{
struct count_info count;
if (!snd_inited)
@ -344,8 +336,10 @@ SNDDMA_Submit (void)
if (shm->samplepos + BYTES <= shm->samples)
write (audio_fd, shm->buffer + BYTES, samples);
else {
write (audio_fd, shm->buffer + BYTES, shm->samples - shm->samplepos);
write (audio_fd, shm->buffer, BYTES - (shm->samples - shm->samplepos));
write (audio_fd, shm->buffer + BYTES, shm->samples -
shm->samplepos);
write (audio_fd, shm->buffer, BYTES - (shm->samples -
shm->samplepos));
}
*plugin_info_snd_output_data.soundtime += samples;
}
@ -363,12 +357,14 @@ SNDDMA_UnblockSound (void)
plugin_t *
snd_output_oss_PluginInfo (void) {
plugin_info.type = qfp_snd_output;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "OSS 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";
plugin_info.type = qfp_snd_output;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "OSS 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";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
@ -389,5 +385,5 @@ snd_output_oss_PluginInfo (void) {
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
return &plugin_info;
return &plugin_info;
}

View file

@ -43,10 +43,10 @@
#include "QF/cmd.h"
#include "QF/console.h"
#include "QF/plugin.h"
#include "QF/qargs.h"
#include "QF/sound.h"
#include "QF/sys.h"
#include "QF/plugin.h"
static dma_t the_shm;
static int snd_inited;
@ -67,9 +67,7 @@ static snd_output_funcs_t plugin_info_snd_output_funcs;
static void
paint_audio (void *unused, Uint8 * stream, int len)
{
int streamsamples;
int sampleposbytes;
int samplesbytes;
int sampleposbytes, samplesbytes, streamsamples;
if (shm) {
streamsamples = len / (shm->samplebits / 8);
@ -231,34 +229,35 @@ SNDDMA_UnblockSound (void)
}
plugin_t *
snd_output_sdl_PluginInfo (void) {
plugin_info.type = qfp_snd_output;
plugin_info.api_version = QFPLUGIN_VERSION;
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 "
snd_output_sdl_PluginInfo (void)
{
plugin_info.type = qfp_snd_output;
plugin_info.api_version = QFPLUGIN_VERSION;
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";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.snd_output = &plugin_info_snd_output_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.snd_output = &plugin_info_snd_output_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.snd_output = &plugin_info_snd_output_funcs;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.snd_output = &plugin_info_snd_output_funcs;
plugin_info_general_funcs.p_Init = SNDDMA_Init_Cvars;
plugin_info_general_funcs.p_Shutdown = NULL;
plugin_info_general_funcs.p_Init = SNDDMA_Init_Cvars;
plugin_info_general_funcs.p_Shutdown = NULL;
plugin_info_snd_output_funcs.pS_O_Init = SNDDMA_Init;
plugin_info_snd_output_funcs.pS_O_Shutdown = SNDDMA_Shutdown;
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;
plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit;
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;
plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit;
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
return &plugin_info;
return &plugin_info;
}

View file

@ -34,10 +34,10 @@
#include <dmedia/audio.h>
#include "QF/console.h"
#include "QF/qtypes.h"
#include "QF/qargs.h"
#include "QF/sound.h"
#include "QF/plugin.h"
#include "QF/qargs.h"
#include "QF/qtypes.h"
#include "QF/sound.h"
static int snd_inited = 0;
static ALconfig alc;
@ -63,9 +63,9 @@ static sound_funcs_t plugin_info_sound_funcs;
static qboolean
SNDDMA_Init (void)
{
ALpv alpv;
int i;
char *s;
char *s;
int i;
ALpv alpv;
alc = alNewConfig ();
@ -159,8 +159,8 @@ SNDDMA_Init (void)
/* channels */
while (shm->channels > 0) {
if (alSetChannels (alc, shm->channels) < 0) {
Con_Printf ("Unable to set number of channels to %d, trying half\n",
shm->channels);
Con_Printf ("Unable to set number of channels to %d, "
"trying half\n", shm->channels);
shm->channels /= 2;
} else
break;
@ -184,9 +184,10 @@ SNDDMA_Init (void)
return 0;
}
/* set sizes of buffers relative to sizes of those for ** the 'standard'
frequency of 11025 ** ** use *huge* buffers since at least my indigo2
has enough ** to do to get sound on the way anyway */
/* set sizes of buffers relative to sizes of those for the 'standard'
frequency of 11025 use *huge* buffers since at least my indigo2
has enough to do to get sound on the way anyway
*/
bufsize = 32768 * (int) ((double) shm->speed / 11025.0);
dma_buffer = malloc (bufsize);
@ -201,8 +202,8 @@ SNDDMA_Init (void)
write_buffer = malloc (bufsize);
if (write_buffer == NULL) {
Con_Printf ("Could not get %d bytes of memory for audio write buffer\n",
bufsize);
Con_Printf ("Could not get %d bytes of memory for audio write "
"buffer\n", bufsize);
free (dma_buffer);
alFreeConfig (alc);
return 0;
@ -255,7 +256,6 @@ SNDDMA_Init (void)
return 1;
}
static int
SNDDMA_GetDMAPos (void)
{
@ -266,7 +266,6 @@ SNDDMA_GetDMAPos (void)
return shm->samplepos;
}
static void
SNDDMA_Shutdown (void)
{
@ -279,7 +278,6 @@ SNDDMA_Shutdown (void)
}
}
/*
SNDDMA_Submit
@ -288,11 +286,9 @@ SNDDMA_Shutdown (void)
static void
SNDDMA_Submit (void)
{
int bsize;
int bytes, b;
unsigned char *p;
int idx;
int stop = *plugin_info_snd_output_data.paintedtime;
unsigned char *p;
int bsize, bytes, idx, b;
int stop = *plugin_info_snd_output_data.paintedtime;
if (snd_blocked)
return;
@ -325,15 +321,26 @@ SNDDMA_Submit (void)
framecount += bytes / bsize;
}
static void
SNDDMA_BlockSound (void)
{
}
static void
SNDDMA_UnblockSound (void)
{
}
plugin_t *
snd_output_sgi_PluginInfo (void) {
plugin_info.type = qfp_sound;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "SGI 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";
plugin_info.type = qfp_sound;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "SGI 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";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
@ -368,13 +375,3 @@ snd_output_sgi_PluginInfo (void) {
return &plugin_info;
}
static void
SNDDMA_BlockSound (void)
{
}
static void
SNDDMA_UnblockSound (void)
{
}

View file

@ -35,26 +35,26 @@
# include <unistd.h>
#endif
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/audioio.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <sys/audioio.h>
#include <errno.h>
#include "QF/console.h"
#include "QF/qtypes.h"
#include "QF/qargs.h"
#include "QF/sound.h"
#include "QF/plugin.h"
#include "QF/qargs.h"
#include "QF/qtypes.h"
#include "QF/sound.h"
static int audio_fd;
static int snd_inited;
static int snd_blocked = 0;
static int audio_fd;
static int snd_inited;
static int snd_blocked = 0;
static int wbufp;
static audio_info_t info;
@ -74,6 +74,7 @@ static general_funcs_t plugin_info_general_funcs;
static sound_data_t plugin_info_sound_data;
static sound_funcs_t plugin_info_sound_funcs;
static qboolean
SNDDMA_Init (void)
{
@ -102,9 +103,7 @@ SNDDMA_Init (void)
close (audio_fd);
return 0;
}
//
// set to nonblock
//
if (fcntl (audio_fd, F_SETFL, O_NONBLOCK) < 0) {
perror ("/dev/audio");
close (audio_fd);
@ -202,12 +201,10 @@ SNDDMA_Shutdown (void)
static void
SNDDMA_Submit (void)
{
int bsize;
int bytes, b;
static unsigned char writebuf[1024];
unsigned char *p;
int idx;
int stop = *plugin_info_snd_output_data.paintedtime;
static unsigned char writebuf[1024];
int bsize, bytes, idx, b;
int stop = *plugin_info_snd_output_data.paintedtime;
if (snd_blocked)
return;
@ -257,43 +254,45 @@ SNDDMA_UnblockSound (void)
plugin_t *
snd_output_sun_PluginInfo (void) {
plugin_info.type = qfp_sound;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "SUN 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";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info.type = qfp_sound;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "SUN 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";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = &plugin_info_sound_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = &plugin_info_sound_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_general_funcs.p_Init = SND_Init;
plugin_info_general_funcs.p_Shutdown = SND_Shutdown;
plugin_info_general_funcs.p_Init = SND_Init;
plugin_info_general_funcs.p_Shutdown = SND_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = SND_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = SND_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = SND_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = SND_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = SND_StaticSound;
plugin_info_sound_funcs.pS_StartSound = SND_StartSound;
plugin_info_sound_funcs.pS_StopSound = SND_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = SND_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = SND_ClearPrecache;
plugin_info_sound_funcs.pS_Update = SND_Update;
plugin_info_sound_funcs.pS_StopAllSounds = SND_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = SND_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = SND_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = SND_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = SND_LocalSound;
plugin_info_sound_funcs.pS_AmbientOff = SND_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = SND_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = SND_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = SND_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = SND_StaticSound;
plugin_info_sound_funcs.pS_StartSound = SND_StartSound;
plugin_info_sound_funcs.pS_StopSound = SND_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = SND_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = SND_ClearPrecache;
plugin_info_sound_funcs.pS_Update = SND_Update;
plugin_info_sound_funcs.pS_StopAllSounds = SND_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = SND_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = SND_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = SND_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = SND_LocalSound;
plugin_info_sound_funcs.pS_BlockSound = SND_BlockSound;
plugin_info_sound_funcs.pS_UnblockSound = SND_UnblockSound;
return &plugin_info;
return &plugin_info;
}

View file

@ -62,10 +62,10 @@ static int snd_sent, snd_completed;
static int snd_blocked = 0;
static volatile dma_t sn;
/*
* Global variables. Must be visible to window-procedure function
* so it can unlock and free the data block after it has been played.
*/
/*
Global variables. Must be visible to window-procedure function
so it can unlock and free the data block after it has been played.
*/
static HANDLE hData;
static HPSTR lpData;//, lpData2;
@ -90,9 +90,6 @@ static sndinitstat SNDDMA_InitDirect (void);
static qboolean SNDDMA_InitWav (void);
/*
S_BlockSound
*/
void
S_BlockSound (void)
{
@ -102,10 +99,6 @@ S_BlockSound (void)
waveOutReset (hWaveOut);
}
/*
S_UnblockSound
*/
void
S_UnblockSound (void)
{
@ -115,10 +108,6 @@ S_UnblockSound (void)
--snd_blocked;
}
/*
FreeSound
*/
static void
FreeSound (void)
{
@ -173,7 +162,6 @@ FreeSound (void)
wav_init = false;
}
/*
SNDDMA_InitDirect
@ -181,13 +169,13 @@ FreeSound (void)
*/
static sndinitstat SNDDMA_InitDirect (void)
{
DSBUFFERDESC dsbuf;
DSBCAPS dsbcaps;
DWORD dwSize, dwWrite;
DSCAPS dscaps;
WAVEFORMATEX format, pformat;
HRESULT hresult;
int reps;
int reps;
DSBUFFERDESC dsbuf;
DSBCAPS dsbcaps;
DSCAPS dscaps;
DWORD dwSize, dwWrite;
HRESULT hresult;
WAVEFORMATEX format, pformat;
memset ((void *) &sn, 0, sizeof (sn));
@ -250,8 +238,8 @@ static sndinitstat SNDDMA_InitDirect (void)
FreeSound ();
return SIS_FAILURE;
}
// get access to the primary buffer, if possible, so we can set the
// sound hardware format
// get access to the primary buffer, if possible, so we can set the
// sound hardware format
memset (&dsbuf, 0, sizeof (dsbuf));
dsbuf.dwSize = sizeof (DSBUFFERDESC);
dsbuf.dwFlags = DSBCAPS_PRIMARYBUFFER;
@ -322,7 +310,7 @@ static sndinitstat SNDDMA_InitDirect (void)
gSndBufSize = dsbcaps.dwBufferBytes;
// initialize the buffer
// initialize the buffer
reps = 0;
while ((hresult = IDirectSoundBuffer_Lock (pDSBuf, 0, gSndBufSize,
@ -343,7 +331,7 @@ static sndinitstat SNDDMA_InitDirect (void)
}
memset (lpData, 0, dwSize);
// lpData[4] = lpData[5] = 0x7f; // force a pop for debugging
// lpData[4] = lpData[5] = 0x7f; // force a pop for debugging
IDirectSoundBuffer_Unlock (pDSBuf, lpData, dwSize, NULL, 0);
@ -369,7 +357,6 @@ static sndinitstat SNDDMA_InitDirect (void)
return SIS_SUCCESS;
}
/*
SNDDM_InitWav
@ -378,9 +365,9 @@ static sndinitstat SNDDMA_InitDirect (void)
static qboolean
SNDDMA_InitWav (void)
{
int i;
HRESULT hr;
WAVEFORMATEX format;
int i;
HRESULT hr;
snd_sent = 0;
snd_completed = 0;
@ -413,11 +400,10 @@ SNDDMA_InitWav (void)
}
/*
* Allocate and lock memory for the waveform data. The memory
* for waveform data must be globally allocated with
* GMEM_MOVEABLE and GMEM_SHARE flags.
*/
Allocate and lock memory for the waveform data. The memory
for waveform data must be globally allocated with
GMEM_MOVEABLE and GMEM_SHARE flags.
*/
gSndBufSize = WAV_BUFFERS * WAV_BUFFER_SIZE;
hData = GlobalAlloc (GMEM_MOVEABLE | GMEM_SHARE, gSndBufSize);
if (!hData) {
@ -489,7 +475,6 @@ SNDDMA_InitWav (void)
Try to find a sound device to mix for.
Returns false if nothing is found.
*/
qboolean
SNDDMA_Init (void)
{
@ -559,9 +544,9 @@ SNDDMA_Init (void)
static int
SNDDMA_GetDMAPos (void)
{
MMTIME mmtime;
int s = 0;
DWORD dwWrite;
int s = 0;
DWORD dwWrite;
MMTIME mmtime;
if (dsound_init) {
mmtime.wType = TIME_SAMPLES;
@ -588,15 +573,13 @@ SNDDMA_GetDMAPos (void)
static void
SNDDMA_Submit (void)
{
LPWAVEHDR h;
int wResult;
int wResult;
LPWAVEHDR h;
if (!wav_init)
return;
//
// find which sound blocks have completed
//
while (1) {
if (snd_completed == snd_sent) {
Con_DPrintf ("Sound overrun\n");
@ -610,18 +593,16 @@ SNDDMA_Submit (void)
snd_completed++; // this buffer has been played
}
//
// submit two new sound blocks
//
while (((snd_sent - snd_completed) >> sample16) < 4) {
h = lpWaveHdr + (snd_sent & WAV_MASK);
snd_sent++;
/*
* Now the data block can be sent to the output device. The
* waveOutWrite function returns immediately and waveform
* data is sent to the output device in the background.
*/
Now the data block can be sent to the output device. The
waveOutWrite function returns immediately and waveform
data is sent to the output device in the background.
*/
wResult = waveOutWrite (hWaveOut, h, sizeof (WAVEHDR));
if (wResult != MMSYSERR_NOERROR) {
@ -646,7 +627,7 @@ SNDDMA_Shutdown (void)
DWORD *
DSOUND_LockBuffer (qboolean lockit)
{
int reps;
int reps;
static DWORD dwSize;
static DWORD dwSize2;
@ -659,10 +640,9 @@ DSOUND_LockBuffer (qboolean lockit)
if (lockit) {
reps = 0;
while ((hresult = IDirectSoundBuffer_Lock (pDSBuf, 0, gSndBufSize,
(LPVOID *) & pbuf1, &dwSize,
(LPVOID *) & pbuf2, &dwSize2,
0)) != DS_OK) {
while ((hresult = IDirectSoundBuffer_Lock
(pDSBuf, 0, gSndBufSize, (LPVOID *) & pbuf1, &dwSize,
(LPVOID *) & pbuf2, &dwSize2, 0)) != DS_OK) {
if (hresult != DSERR_BUFFERLOST) {
Con_Printf
("S_TransferStereo16: DS::Lock Sound Buffer Failed\n");

View file

@ -124,9 +124,9 @@ static byte chktbl[1024 + 4] = {
byte
COM_BlockSequenceCRCByte (const byte * base, int length, int sequence)
{
unsigned short crc;
byte *p;
byte chkb[60 + 4];
byte *p;
unsigned short crc;
p = chktbl + (sequence % (sizeof (chktbl) - 8));
@ -151,8 +151,8 @@ COM_BlockSequenceCRCByte (const byte * base, int length, int sequence)
unsigned int
Com_BlockChecksum (const void *buffer, int length)
{
int digest[4];
unsigned int val;
int digest[4];
unsigned int val;
mdfour ((unsigned char *) digest, (unsigned char *) buffer, length);

View file

@ -73,10 +73,9 @@ fgetLittleLong (VFile *f)
byte *
LoadTGA (VFile *fin)
{
int columns, rows, numPixels;
byte *pixbuf;
int row, column;
unsigned char red = 0, green = 0, blue = 0, alphabyte = 0;
byte *pixbuf;
unsigned char red = 0, green = 0, blue = 0, alphabyte = 0;
int column, row, columns, rows, numPixels;
TargaHeader targa_header;
byte *targa_rgba;

View file

@ -183,7 +183,7 @@ SCR_DrawCenterString (void)
int remaining, j, l, x, y;
// the finale prints the characters one at a time
if (r_force_fullscreen /*FIXME better test*/)
if (r_force_fullscreen /* FIXME: better test */)
remaining = scr_printspeed->value * (r_realtime -
scr_centertime_start);
else
@ -245,11 +245,11 @@ CalcFov (float fov_x, float width, float height)
if (fov_x < 1 || fov_x > 179)
Sys_Error ("Bad fov: %f", fov_x);
x = width / tan (fov_x / 360 * M_PI);
x = width / tan (fov_x * (M_PI / 360));
a = (x == 0) ? 90 : atan (height / x); // 0 shouldn't happen
a = a * 360 / M_PI;
a = a * (360 / M_PI);
return a;
}
@ -293,7 +293,7 @@ SCR_CalcRefdef (void)
size = scr_viewsize->int_val;
}
// intermission is always full screen
if (r_force_fullscreen /*FIXME better test*/) {
if (r_force_fullscreen /* FIXME: better test */) {
full = true;
size = 100.0;
sb_lines = 0;
@ -536,9 +536,7 @@ SCR_DrawConsole (int swap)
}
}
/*
SCREEN SHOTS
*/
/* SCREEN SHOTS */
tex_t *
SCR_ScreenShot (int width, int height)
@ -578,7 +576,7 @@ SCR_ScreenShot (int width, int height)
dey++; // at least one
count = 0;
for ( /* */ ; dy < dey; dy++) {
for (; dy < dey; dy++) {
src = tex->data + (vid.width * 3 * dy) + dx * 3;
for (nx = dx; nx < dex; nx++) {
r += *src++;
@ -647,9 +645,11 @@ MipColor (int r, int g, int b)
bestdist = 256 * 256 * 3;
for (i = 0; i < 256; i++) {
r1 = vid_basepal[i * 3] - r;
g1 = vid_basepal[i * 3 + 1] - g;
b1 = vid_basepal[i * 3 + 2] - b;
static int j;
j = i * 3;
r1 = vid_basepal[j] - r;
g1 = vid_basepal[j + 1] - g;
b1 = vid_basepal[j + 2] - b;
dist = r1 * r1 + g1 * g1 + b1 * b1;
if (dist < bestdist) {
bestdist = dist;

View file

@ -51,17 +51,17 @@
static byte translate[256];
static unsigned int translate32[256];
void
Skin_Set_Translate (int top, int bottom, void *_dest)
{
int i;
top = bound (0, top, 13) * 16;
bottom = bound (0, bottom, 13) * 16;
top = bound (0, top, 13) << 4;
bottom = bound (0, bottom, 13) << 4;
for (i = 0; i < 16; i++) {
if (top < 128) // the artists made some backwards
// ranges. sigh.
if (top < 128) // the artists made some backwards ranges. sigh.
translate[TOP_RANGE + i] = top + i;
else
translate[TOP_RANGE + i] = top + 15 - i;

View file

@ -197,11 +197,11 @@ R_DrawSkyLayer (float s)
qfglBegin (GL_TRIANGLE_STRIP);
qfglTexCoord2f (0.5 + s * (1.0 / 128.0), 0.5 + s * (1.0 / 128.0));
qfglVertex3f (r_refdef.vieworg[0],
r_refdef.vieworg[1], r_refdef.vieworg[2] + domescale[2]);
qfglVertex3f (r_refdef.vieworg[0], r_refdef.vieworg[1],
r_refdef.vieworg[2] + domescale[2]);
for (b = 1; b < 8; b++) {
x = bubble_costable[b * 2 + 16];
y = -bubble_sintable[b * 2 + 16];
x = bubble_costable[(b << 1) + 16];
y = -bubble_sintable[(b << 1) + 16];
v[0] = a1x * x;
v[1] = a1y * x;

View file

@ -675,7 +675,7 @@ EmitSkyPolys (float speedscale, msurface_t *fa)
dir[2] *= 3; // flatten the sphere
length = DotProduct (dir, dir);
length = 6 * 63 / sqrt (length);
length = (6 * 63) / sqrt (length);
dir[0] *= length;
dir[1] *= length;

View file

@ -201,11 +201,11 @@ EmitWaterPolys (msurface_t *fa)
s = os + turbsin[(int) ((ot * 0.125 + r_realtime) * TURBSCALE) &
255];
s *= (1.0 / 64);
s *= (1.0 / 64.0);
t = ot + turbsin[(int) ((os * 0.125 + r_realtime) * TURBSCALE) &
255];
t *= (1.0 / 64);
t *= (1.0 / 64.0);
qfglTexCoord2f (s, t);

View file

@ -41,9 +41,7 @@ efrag_t *r_free_efrags;
// FIXME: put this on hunk?
efrag_t r_efrags[MAX_EFRAGS];
/*
ENTITY FRAGMENT FUNCTIONS
*/
/* ENTITY FRAGMENT FUNCTIONS */
efrag_t **lastlink;