mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-31 16:51:08 +00:00
all -snd* params and environment checking have been removed from the sound
subsystem in favor of Cvars*. These new cvars are: o snd_device defaults to "" which selects the default device of the system (eg, plug:0,0 for ALSA 0.9 or /dev/dsp for OSS) o snd_rate defaults to 0 which selects the system default rate. o snd_bits defaults to 0 which selects the system default bit depth. o snd_stereo defaults to 1 (0 is mono) * actually, not that thorough: alsa and oss only. The rest have just ws :/
This commit is contained in:
parent
95e5b5e4cf
commit
f6d047712d
10 changed files with 366 additions and 322 deletions
|
@ -172,6 +172,10 @@ extern cvar_t *loadas8bit;
|
|||
extern cvar_t *bgmvolume;
|
||||
extern cvar_t *volume;
|
||||
|
||||
extern cvar_t *snd_device;
|
||||
extern cvar_t *snd_rate;
|
||||
extern cvar_t *snd_bits;
|
||||
extern cvar_t *snd_stereo;
|
||||
extern cvar_t *snd_interp;
|
||||
extern cvar_t *snd_stereo_phase_separation;
|
||||
|
||||
|
|
|
@ -123,14 +123,11 @@ SNDDMA_Init (void)
|
|||
Con_Printf ("No sound cards detected\n");
|
||||
return 0;
|
||||
}
|
||||
if ((i = COM_CheckParm ("-sndcard")) != 0) {
|
||||
card = atoi (com_argv[i + 1]);
|
||||
if (snd_device->string[0]) {
|
||||
sscanf (snd_device->string, "%d,%d", &card, &dev);
|
||||
}
|
||||
if ((i = COM_CheckParm ("-snddev")) != 0) {
|
||||
dev = atoi (com_argv[i + 1]);
|
||||
}
|
||||
if ((i = COM_CheckParm ("-sndbits")) != 0) {
|
||||
i = atoi (com_argv[i + 1]);
|
||||
if (snd_bits->int_val) {
|
||||
i = snd_bits->int_val;
|
||||
if (i == 16) {
|
||||
format = SND_PCM_SFMT_S16_LE;
|
||||
} else if (i == 8) {
|
||||
|
@ -140,16 +137,14 @@ SNDDMA_Init (void)
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
if ((i = COM_CheckParm ("-sndspeed")) != 0) {
|
||||
rate = atoi (com_argv[i + 1]);
|
||||
if (snd_rate->int_val) {
|
||||
rate = snd_rate->int_val;
|
||||
if (rate != 44100 && rate != 22050 && rate != 11025) {
|
||||
Con_Printf ("Error: invalid sample rate: %d\n", rate);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ((i = COM_CheckParm ("-sndmono")) != 0) {
|
||||
stereo = 0;
|
||||
}
|
||||
stereo = snd_stereo->int_val;
|
||||
if (card == -1) {
|
||||
for (card = 0; card < SND_CARDS; card++) {
|
||||
if (!(mask & (1 << card)))
|
||||
|
@ -273,6 +268,7 @@ SNDDMA_Init (void)
|
|||
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
|
||||
|
|
|
@ -47,38 +47,34 @@ static const snd_pcm_channel_area_t *mmap_areas;
|
|||
static char *pcmname = NULL;
|
||||
size_t buffer_size;
|
||||
|
||||
qboolean SNDDMA_Init(void)
|
||||
qboolean
|
||||
SNDDMA_Init (void)
|
||||
{
|
||||
int err,i;
|
||||
int err;
|
||||
int rate = -1, bps = -1, stereo = -1, frag_size;
|
||||
snd_pcm_hw_params_t *hw;
|
||||
snd_pcm_sw_params_t *sw;
|
||||
|
||||
snd_pcm_hw_params_alloca (&hw);
|
||||
snd_pcm_sw_params_alloca (&sw);
|
||||
|
||||
if ((i=COM_CheckParm("-sndpcm"))!=0) {
|
||||
pcmname=com_argv[i+1];
|
||||
}
|
||||
if ((i=COM_CheckParm("-sndbits")) != 0) {
|
||||
bps = atoi(com_argv[i+1]);
|
||||
if (snd_device->string[0])
|
||||
pcmname = snd_device->string;
|
||||
if (snd_bits->int_val) {
|
||||
bps = snd_bits->int_val;
|
||||
if (bps != 16 && bps != 8) {
|
||||
Con_Printf("Error: invalid sample bits: %d\n", i);
|
||||
Con_Printf ("Error: invalid sample bits: %d\n", bps);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ((i=COM_CheckParm("-sndspeed")) != 0) {
|
||||
rate = atoi(com_argv[i+1]);
|
||||
if (snd_rate->int_val) {
|
||||
rate = snd_rate->int_val;
|
||||
if (rate != 44100 && rate != 22050 && rate != 11025) {
|
||||
Con_Printf ("Error: invalid sample rate: %d\n", rate);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ((i=COM_CheckParm("-sndmono")) != 0) {
|
||||
stereo=0;
|
||||
}
|
||||
if ((i=COM_CheckParm("-sndstereo")) != 0) {
|
||||
stereo=1;
|
||||
}
|
||||
stereo = snd_stereo->int_val;
|
||||
if (!pcmname)
|
||||
pcmname = "plug:0,0";
|
||||
if ((err = snd_pcm_open (&pcm, pcmname,
|
||||
|
@ -122,9 +118,11 @@ qboolean 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) >= 0) {
|
||||
} else if (snd_pcm_hw_params_set_format (pcm, hw, SND_PCM_FORMAT_U8)
|
||||
>= 0) {
|
||||
bps = 8;
|
||||
} else {
|
||||
Con_Printf ("ALSA: no useable formats\n");
|
||||
|
@ -195,7 +193,12 @@ qboolean SNDDMA_Init(void)
|
|||
memset ((dma_t *) shm, 0, sizeof (*shm));
|
||||
shm->splitbuffer = 0;
|
||||
shm->channels = stereo + 1;
|
||||
shm->submission_chunk=snd_pcm_hw_params_get_period_size(hw, 0); // don't mix less than this #
|
||||
shm->submission_chunk = snd_pcm_hw_params_get_period_size (hw, 0); // don't
|
||||
// mix
|
||||
// less
|
||||
// than
|
||||
// this
|
||||
// #
|
||||
shm->samplepos = 0; // in mono samples
|
||||
shm->samplebits = bps;
|
||||
buffer_size = snd_pcm_hw_params_get_buffer_size (hw);
|
||||
|
@ -235,11 +238,13 @@ get_hw_ptr()
|
|||
return hw_ptr;
|
||||
}
|
||||
|
||||
int SNDDMA_GetDMAPos(void)
|
||||
int
|
||||
SNDDMA_GetDMAPos (void)
|
||||
{
|
||||
int hw_ptr;
|
||||
|
||||
if (!snd_inited) return 0;
|
||||
if (!snd_inited)
|
||||
return 0;
|
||||
|
||||
hw_ptr = get_hw_ptr ();
|
||||
hw_ptr *= shm->channels;
|
||||
|
@ -247,10 +252,10 @@ int SNDDMA_GetDMAPos(void)
|
|||
return shm->samplepos;
|
||||
}
|
||||
|
||||
void SNDDMA_Shutdown(void)
|
||||
{
|
||||
if (snd_inited)
|
||||
void
|
||||
SNDDMA_Shutdown (void)
|
||||
{
|
||||
if (snd_inited) {
|
||||
snd_pcm_close (pcm);
|
||||
snd_inited = 0;
|
||||
}
|
||||
|
@ -263,7 +268,8 @@ SNDDMA_Submit
|
|||
Send sound to device if buffer isn't really the dma buffer
|
||||
===============
|
||||
*/
|
||||
void SNDDMA_Submit(void)
|
||||
void
|
||||
SNDDMA_Submit (void)
|
||||
{
|
||||
int count = paintedtime - soundtime;
|
||||
int avail;
|
||||
|
@ -305,4 +311,3 @@ void SNDDMA_Submit(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -101,6 +101,10 @@ int sound_started = 0;
|
|||
cvar_t *bgmvolume;
|
||||
cvar_t *volume;
|
||||
|
||||
cvar_t *snd_device;
|
||||
cvar_t *snd_rate;
|
||||
cvar_t *snd_bits;
|
||||
cvar_t *snd_stereo;
|
||||
cvar_t *nosound;
|
||||
cvar_t *precache;
|
||||
cvar_t *loadas8bit;
|
||||
|
@ -199,11 +203,16 @@ S_Init (void)
|
|||
|
||||
Con_Printf ("\nSound Initialization\n");
|
||||
|
||||
Cmd_AddCommand ("play", S_Play, "Play selected sound effect (play pathto/sound.wav)");
|
||||
Cmd_AddCommand ("playvol", S_PlayVol, "Play selected sound effect at selected volume (playvol pathto/sound.wav num");
|
||||
Cmd_AddCommand ("stopsound", S_StopAllSoundsC, "Stops all sounds currently being played");
|
||||
Cmd_AddCommand ("soundlist", S_SoundList, "Reports a list of sounds in the cache");
|
||||
Cmd_AddCommand ("soundinfo", S_SoundInfo_f, "Report information on the sound system");
|
||||
Cmd_AddCommand ("play", S_Play,
|
||||
"Play selected sound effect (play pathto/sound.wav)");
|
||||
Cmd_AddCommand ("playvol", S_PlayVol,
|
||||
"Play selected sound effect at selected volume (playvol pathto/sound.wav num");
|
||||
Cmd_AddCommand ("stopsound", S_StopAllSoundsC,
|
||||
"Stops all sounds currently being played");
|
||||
Cmd_AddCommand ("soundlist", S_SoundList,
|
||||
"Reports a list of sounds in the cache");
|
||||
Cmd_AddCommand ("soundinfo", S_SoundInfo_f,
|
||||
"Report information on the sound system");
|
||||
|
||||
if (COM_CheckParm ("-nosound"))
|
||||
return;
|
||||
|
@ -261,22 +270,47 @@ S_Init (void)
|
|||
void
|
||||
S_Init_Cvars (void)
|
||||
{
|
||||
snd_device = Cvar_Get ("snd_device", "", CVAR_ROM,
|
||||
"sound device. \"\" is system default");
|
||||
snd_rate = Cvar_Get ("snd_rate", "0", CVAR_ROM,
|
||||
"sound playback rate. 0 is system default");
|
||||
snd_bits = Cvar_Get ("snd_bits", "0", CVAR_ROM,
|
||||
"sound sample depth. 0 is system default");
|
||||
snd_stereo = Cvar_Get ("snd_stereo", "1", CVAR_ROM,
|
||||
"sound stereo output");
|
||||
nosound = Cvar_Get ("nosound", "0", CVAR_NONE, "Set to turn sound off");
|
||||
volume = Cvar_Get ("volume", "0.7", CVAR_ARCHIVE, "Set the volume for sound playback");
|
||||
precache = Cvar_Get ("precache", "1", CVAR_NONE, "Toggle the use of a precache");
|
||||
loadas8bit = Cvar_Get ("loadas8bit", "0", CVAR_NONE, "Toggles if sounds are loaded as 8-bit samples");
|
||||
volume =
|
||||
Cvar_Get ("volume", "0.7", CVAR_ARCHIVE,
|
||||
"Set the volume for sound playback");
|
||||
precache =
|
||||
Cvar_Get ("precache", "1", CVAR_NONE, "Toggle the use of a precache");
|
||||
loadas8bit =
|
||||
Cvar_Get ("loadas8bit", "0", CVAR_NONE,
|
||||
"Toggles if sounds are loaded as 8-bit samples");
|
||||
bgmvolume = Cvar_Get ("bgmvolume", "1", CVAR_ARCHIVE, "Volume of CD music");
|
||||
ambient_level = Cvar_Get ("ambient_level", "0.3", CVAR_NONE, "Ambient sounds' volume");
|
||||
ambient_fade = Cvar_Get ("ambient_fade", "100", CVAR_NONE, "How quickly ambient sounds fade in or out");
|
||||
snd_noextraupdate = Cvar_Get ("snd_noextraupdate", "0", CVAR_NONE,
|
||||
ambient_level =
|
||||
Cvar_Get ("ambient_level", "0.3", CVAR_NONE, "Ambient sounds' volume");
|
||||
ambient_fade =
|
||||
Cvar_Get ("ambient_fade", "100", CVAR_NONE,
|
||||
"How quickly ambient sounds fade in or out");
|
||||
snd_noextraupdate =
|
||||
Cvar_Get ("snd_noextraupdate", "0", CVAR_NONE,
|
||||
"Toggles the correct value display in host_speeds. Usually messes up sound playback when in effect");
|
||||
snd_show = Cvar_Get ("snd_show", "0", CVAR_NONE, "Toggles the display of sounds currently being played");
|
||||
snd_show =
|
||||
Cvar_Get ("snd_show", "0", CVAR_NONE,
|
||||
"Toggles the display of sounds currently being played");
|
||||
snd_interp =
|
||||
Cvar_Get ("snd_interp", "1", CVAR_ARCHIVE,
|
||||
"control sample interpolation");
|
||||
snd_phasesep = Cvar_Get ("snd_phasesep", "0.0", CVAR_ARCHIVE, "max stereo phase separation in ms. 0.6 is for 20cm head");
|
||||
snd_volumesep = Cvar_Get("snd_volumesep", "1.0", CVAR_ARCHIVE, "max stereo volume separation in ms. 1.0 is max");
|
||||
_snd_mixahead = Cvar_Get ("_snd_mixahead", "0.1", CVAR_ARCHIVE, "Delay time for sounds");
|
||||
snd_phasesep =
|
||||
Cvar_Get ("snd_phasesep", "0.0", CVAR_ARCHIVE,
|
||||
"max stereo phase separation in ms. 0.6 is for 20cm head");
|
||||
snd_volumesep =
|
||||
Cvar_Get ("snd_volumesep", "1.0", CVAR_ARCHIVE,
|
||||
"max stereo volume separation in ms. 1.0 is max");
|
||||
_snd_mixahead =
|
||||
Cvar_Get ("_snd_mixahead", "0.1", CVAR_ARCHIVE,
|
||||
"Delay time for sounds");
|
||||
}
|
||||
|
||||
|
||||
|
@ -605,7 +639,8 @@ S_ClearBuffer (void)
|
|||
clear = 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (pDSBuf) DSOUND_ClearBuffer(clear);
|
||||
if (pDSBuf)
|
||||
DSOUND_ClearBuffer (clear);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
|
@ -737,7 +772,8 @@ S_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
|
|||
for (i = NUM_AMBIENTS; i < total_channels; i++, ch++) {
|
||||
if (!ch->sfx)
|
||||
continue;
|
||||
ch->oldphase = ch->phase; // prepare to lerp from prev to next phase
|
||||
ch->oldphase = ch->phase; // prepare to lerp from prev to next
|
||||
// phase
|
||||
SND_Spatialize (ch); // respatialize channel
|
||||
if (!ch->leftvol && !ch->rightvol)
|
||||
continue;
|
||||
|
@ -861,7 +897,8 @@ S_Update_ (void)
|
|||
endtime = soundtime + samps;
|
||||
|
||||
#ifdef _WIN32
|
||||
if(pDSBuf) DSOUND_Restore();
|
||||
if (pDSBuf)
|
||||
DSOUND_Restore ();
|
||||
#endif
|
||||
|
||||
S_PaintChannels (endtime);
|
||||
|
|
|
@ -71,6 +71,7 @@ ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte * data)
|
|||
ob = sc->data;
|
||||
|
||||
stepscale = (float) inrate / shm->speed; // this is usually 0.5, 1, or
|
||||
//
|
||||
// 2
|
||||
|
||||
outcount = sc->length / stepscale;
|
||||
|
|
|
@ -47,7 +47,9 @@
|
|||
|
||||
#define PAINTBUFFER_SIZE 512
|
||||
portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE * 2];
|
||||
int max_overpaint; // number of extra samples painted due to phase shift
|
||||
int max_overpaint; // number of extra samples painted
|
||||
|
||||
// due to phase shift
|
||||
int snd_scaletable[32][256];
|
||||
int *snd_p, snd_linear_count, snd_vol;
|
||||
short *snd_out;
|
||||
|
@ -100,8 +102,7 @@ S_TransferStereo16 (int endtime)
|
|||
Con_Printf ("DSOUND_LockBuffer fails!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
pbuf = (DWORD *) shm->buffer;
|
||||
|
@ -127,7 +128,8 @@ S_TransferStereo16 (int endtime)
|
|||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (pDSBuf) DSOUND_LockBuffer(false);
|
||||
if (pDSBuf)
|
||||
DSOUND_LockBuffer (false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -162,8 +164,7 @@ S_TransferPaintBuffer (int endtime)
|
|||
Con_Printf ("DSOUND_LockBuffer fails!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
pbuf = (DWORD *) shm->buffer;
|
||||
|
@ -197,7 +198,8 @@ S_TransferPaintBuffer (int endtime)
|
|||
}
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if (pDSBuf) DSOUND_LockBuffer(false);
|
||||
if (pDSBuf)
|
||||
DSOUND_LockBuffer (false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,8 @@ void
|
|||
S_Init_Cvars (void)
|
||||
{
|
||||
volume = Cvar_Get ("volume", "0.7", CVAR_ARCHIVE, "Volume level of sounds");
|
||||
loadas8bit = Cvar_Get ("loadas8bit", "0", CVAR_NONE, "Load samples as 8-bit");
|
||||
loadas8bit =
|
||||
Cvar_Get ("loadas8bit", "0", CVAR_NONE, "Load samples as 8-bit");
|
||||
bgmvolume = Cvar_Get ("bgmvolume", "1", CVAR_ARCHIVE, "CD music volume");
|
||||
}
|
||||
|
||||
|
|
|
@ -64,8 +64,9 @@
|
|||
# define MAP_FAILED ((void *) -1)
|
||||
#endif
|
||||
|
||||
int audio_fd;
|
||||
int snd_inited;
|
||||
static int audio_fd;
|
||||
static int snd_inited;
|
||||
static char *snd_dev;
|
||||
|
||||
static int tryrates[] = { 11025, 22050, 22051, 44100, 8000 };
|
||||
|
||||
|
@ -76,38 +77,40 @@ SNDDMA_Init (void)
|
|||
int fmt;
|
||||
int tmp;
|
||||
int i;
|
||||
char *s;
|
||||
struct audio_buf_info info;
|
||||
int caps;
|
||||
int retries = 3;
|
||||
|
||||
snd_inited = 0;
|
||||
|
||||
// open /dev/dsp, confirm capability to mmap, and get size of dma buffer
|
||||
audio_fd = open ("/dev/dsp", O_RDWR);
|
||||
// open snd_dev, confirm capability to mmap, and get size of dma buffer
|
||||
if (snd_device->string[0])
|
||||
snd_dev = snd_device->string;
|
||||
|
||||
audio_fd = open (snd_dev, O_RDWR);
|
||||
if (audio_fd < 0) { // Failed open, retry up to 3 times
|
||||
// if it's busy
|
||||
while ((audio_fd < 0) && retries-- &&
|
||||
((errno == EAGAIN) || (errno == EBUSY))) {
|
||||
sleep (1);
|
||||
audio_fd = open ("/dev/dsp", O_RDWR);
|
||||
audio_fd = open (snd_dev, O_RDWR);
|
||||
}
|
||||
if (audio_fd < 0) {
|
||||
perror ("/dev/dsp");
|
||||
Con_Printf ("Could not open /dev/dsp\n");
|
||||
perror (snd_dev);
|
||||
Con_Printf ("Could not open %s\n", snd_dev);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((rc = ioctl (audio_fd, SNDCTL_DSP_RESET, 0)) < 0) {
|
||||
perror ("/dev/dsp");
|
||||
Con_Printf ("Could not reset /dev/dsp\n");
|
||||
perror (snd_dev);
|
||||
Con_Printf ("Could not reset %s\n", snd_dev);
|
||||
close (audio_fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ioctl (audio_fd, SNDCTL_DSP_GETCAPS, &caps) == -1) {
|
||||
perror ("/dev/dsp");
|
||||
perror (snd_dev);
|
||||
Con_Printf ("Sound driver too old\n");
|
||||
close (audio_fd);
|
||||
return 0;
|
||||
|
@ -130,13 +133,7 @@ SNDDMA_Init (void)
|
|||
shm->splitbuffer = 0;
|
||||
|
||||
// set sample bits & speed
|
||||
if ((i = COM_CheckParm ("-sndbits"))) {
|
||||
shm->samplebits = atoi (com_argv[i + 1]);
|
||||
} else {
|
||||
if ((s = getenv ("QF_SND_BITS"))) {
|
||||
shm->samplebits = atoi (s);
|
||||
}
|
||||
}
|
||||
shm->samplebits = snd_bits->int_val;
|
||||
|
||||
if (shm->samplebits != 16 && shm->samplebits != 8) {
|
||||
ioctl (audio_fd, SNDCTL_DSP_GETFMTS, &fmt);
|
||||
|
@ -150,10 +147,8 @@ SNDDMA_Init (void)
|
|||
}
|
||||
}
|
||||
|
||||
if ((i = COM_CheckParm ("-sndspeed"))) {
|
||||
shm->speed = atoi (com_argv[i + 1]);
|
||||
} else if ((s = getenv ("QF_SND_SPEED"))) {
|
||||
shm->speed = atoi (s);
|
||||
if (snd_rate->int_val) {
|
||||
shm->speed = snd_rate->int_val;
|
||||
} else {
|
||||
for (i = 0; i < (sizeof (tryrates) / 4); i++)
|
||||
if (!ioctl (audio_fd, SNDCTL_DSP_SPEED, &tryrates[i]))
|
||||
|
@ -161,12 +156,8 @@ SNDDMA_Init (void)
|
|||
shm->speed = tryrates[i];
|
||||
}
|
||||
|
||||
if ((i = COM_CheckParm ("-sndmono"))) {
|
||||
if (!snd_stereo->int_val) {
|
||||
shm->channels = 1;
|
||||
} else if ((i = COM_CheckParm ("-sndstereo"))) {
|
||||
shm->channels = 2;
|
||||
} else if ((s = getenv ("QF_SND_CHANNELS"))) {
|
||||
shm->channels = atoi (s);
|
||||
} else {
|
||||
shm->channels = 2;
|
||||
}
|
||||
|
@ -181,8 +172,8 @@ SNDDMA_Init (void)
|
|||
MAP_FILE | MAP_SHARED, audio_fd, 0);
|
||||
|
||||
if (shm->buffer == MAP_FAILED) {
|
||||
perror ("/dev/dsp");
|
||||
Con_Printf ("Could not mmap /dev/dsp\n");
|
||||
perror (snd_dev);
|
||||
Con_Printf ("Could not mmap %s\n", snd_dev);
|
||||
close (audio_fd);
|
||||
return 0;
|
||||
}
|
||||
|
@ -192,8 +183,8 @@ SNDDMA_Init (void)
|
|||
tmp = 1;
|
||||
rc = ioctl (audio_fd, SNDCTL_DSP_STEREO, &tmp);
|
||||
if (rc < 0) {
|
||||
perror ("/dev/dsp");
|
||||
Con_Printf ("Could not set /dev/dsp to stereo=%d", shm->channels);
|
||||
perror (snd_dev);
|
||||
Con_Printf ("Could not set %s to stereo=%d", snd_dev, shm->channels);
|
||||
close (audio_fd);
|
||||
return 0;
|
||||
}
|
||||
|
@ -205,8 +196,8 @@ SNDDMA_Init (void)
|
|||
|
||||
rc = ioctl (audio_fd, SNDCTL_DSP_SPEED, &shm->speed);
|
||||
if (rc < 0) {
|
||||
perror ("/dev/dsp");
|
||||
Con_Printf ("Could not set /dev/dsp speed to %d", shm->speed);
|
||||
perror (snd_dev);
|
||||
Con_Printf ("Could not set %s speed to %d", snd_dev, shm->speed);
|
||||
close (audio_fd);
|
||||
return 0;
|
||||
}
|
||||
|
@ -215,7 +206,7 @@ SNDDMA_Init (void)
|
|||
rc = AFMT_S16_LE;
|
||||
rc = ioctl (audio_fd, SNDCTL_DSP_SETFMT, &rc);
|
||||
if (rc < 0) {
|
||||
perror ("/dev/dsp");
|
||||
perror (snd_dev);
|
||||
Con_Printf ("Could not support 16-bit data. Try 8-bit.\n");
|
||||
close (audio_fd);
|
||||
return 0;
|
||||
|
@ -224,13 +215,13 @@ SNDDMA_Init (void)
|
|||
rc = AFMT_U8;
|
||||
rc = ioctl (audio_fd, SNDCTL_DSP_SETFMT, &rc);
|
||||
if (rc < 0) {
|
||||
perror ("/dev/dsp");
|
||||
perror (snd_dev);
|
||||
Con_Printf ("Could not support 8-bit data.\n");
|
||||
close (audio_fd);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
perror ("/dev/dsp");
|
||||
perror (snd_dev);
|
||||
Con_Printf ("%d-bit sound not supported.", shm->samplebits);
|
||||
close (audio_fd);
|
||||
return 0;
|
||||
|
@ -241,7 +232,7 @@ SNDDMA_Init (void)
|
|||
tmp = 0;
|
||||
rc = ioctl (audio_fd, SNDCTL_DSP_SETTRIGGER, &tmp);
|
||||
if (rc < 0) {
|
||||
perror ("/dev/dsp");
|
||||
perror (snd_dev);
|
||||
Con_Printf ("Could not toggle.\n");
|
||||
close (audio_fd);
|
||||
return 0;
|
||||
|
@ -249,7 +240,7 @@ SNDDMA_Init (void)
|
|||
tmp = PCM_ENABLE_OUTPUT;
|
||||
rc = ioctl (audio_fd, SNDCTL_DSP_SETTRIGGER, &tmp);
|
||||
if (rc < 0) {
|
||||
perror ("/dev/dsp");
|
||||
perror (snd_dev);
|
||||
Con_Printf ("Could not toggle.\n");
|
||||
close (audio_fd);
|
||||
return 0;
|
||||
|
@ -272,7 +263,7 @@ SNDDMA_GetDMAPos (void)
|
|||
return 0;
|
||||
|
||||
if (ioctl (audio_fd, SNDCTL_DSP_GETOPTR, &count) == -1) {
|
||||
perror ("/dev/dsp");
|
||||
perror (snd_dev);
|
||||
Con_Printf ("Uh, sound dead.\n");
|
||||
close (audio_fd);
|
||||
snd_inited = 0;
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
#define iDirectSoundCreate(a,b,c) pDirectSoundCreate(a,b,c)
|
||||
|
||||
HRESULT (WINAPI * pDirectSoundCreate) (GUID FAR * lpGUID,
|
||||
LPDIRECTSOUND FAR * lplpDS,IUnknown FAR * pUnkOuter);
|
||||
LPDIRECTSOUND FAR * lplpDS,
|
||||
IUnknown FAR * pUnkOuter);
|
||||
|
||||
// 64K is > 1 second at 16-bit, 22050 Hz
|
||||
#define WAV_BUFFERS 64
|
||||
|
@ -181,8 +182,7 @@ FreeSound (void)
|
|||
|
||||
Direct-Sound support
|
||||
*/
|
||||
sndinitstat
|
||||
SNDDMA_InitDirect (void)
|
||||
sndinitstat SNDDMA_InitDirect (void)
|
||||
{
|
||||
DSBUFFERDESC dsbuf;
|
||||
DSBCAPS dsbcaps;
|
||||
|
@ -271,7 +271,8 @@ SNDDMA_InitDirect (void)
|
|||
pformat = format;
|
||||
|
||||
if (DS_OK != IDirectSoundBuffer_SetFormat (pDSPBuf, &pformat)) {
|
||||
} else primary_format_set = true;
|
||||
} else
|
||||
primary_format_set = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,7 +329,8 @@ SNDDMA_InitDirect (void)
|
|||
reps = 0;
|
||||
|
||||
while ((hresult = IDirectSoundBuffer_Lock (pDSBuf, 0, gSndBufSize,
|
||||
(LPVOID *) & lpData, &dwSize, NULL,NULL, 0)) != DS_OK) {
|
||||
(LPVOID *) & lpData, &dwSize,
|
||||
NULL, NULL, 0)) != DS_OK) {
|
||||
if (hresult != DSERR_BUFFERLOST) {
|
||||
Con_Printf ("SNDDMA_InitDirect: DS::Lock Sound Buffer Failed\n");
|
||||
FreeSound ();
|
||||
|
@ -403,7 +405,8 @@ SNDDMA_InitWav (void)
|
|||
|
||||
/* Open a waveform device for output using window callback. */
|
||||
while ((hr = waveOutOpen ((LPHWAVEOUT) & hWaveOut, WAVE_MAPPER,
|
||||
&format,0, 0L, CALLBACK_NULL)) != MMSYSERR_NOERROR) {
|
||||
&format, 0, 0L,
|
||||
CALLBACK_NULL)) != MMSYSERR_NOERROR) {
|
||||
if (hr != MMSYSERR_ALLOCATED) {
|
||||
Con_Printf ("waveOutOpen failed\n");
|
||||
return false;
|
||||
|
@ -565,7 +568,8 @@ SNDDMA_GetDMAPos (void)
|
|||
|
||||
if (dsound_init) {
|
||||
mmtime.wType = TIME_SAMPLES;
|
||||
IDirectSoundBuffer_GetCurrentPosition (pDSBuf, &mmtime.u.sample, &dwWrite);
|
||||
IDirectSoundBuffer_GetCurrentPosition (pDSBuf, &mmtime.u.sample,
|
||||
&dwWrite);
|
||||
s = mmtime.u.sample - mmstarttime.u.sample;
|
||||
} else if (wav_init) {
|
||||
s = snd_sent * WAV_BUFFER_SIZE;
|
||||
|
@ -660,7 +664,8 @@ DSOUND_LockBuffer(qboolean lockit)
|
|||
reps = 0;
|
||||
while ((hresult = IDirectSoundBuffer_Lock (pDSBuf, 0, gSndBufSize,
|
||||
(LPVOID *) & pbuf1, &dwSize,
|
||||
(LPVOID *) & pbuf2, &dwSize2,0)) != DS_OK) {
|
||||
(LPVOID *) & pbuf2, &dwSize2,
|
||||
0)) != DS_OK) {
|
||||
if (hresult != DSERR_BUFFERLOST) {
|
||||
Con_Printf
|
||||
("S_TransferStereo16: DS::Lock Sound Buffer Failed\n");
|
||||
|
@ -687,7 +692,8 @@ DSOUND_LockBuffer(qboolean lockit)
|
|||
return (pbuf1);
|
||||
}
|
||||
|
||||
void DSOUND_ClearBuffer(int clear)
|
||||
void
|
||||
DSOUND_ClearBuffer (int clear)
|
||||
{
|
||||
DWORD *pData;
|
||||
|
||||
|
@ -697,12 +703,14 @@ void DSOUND_ClearBuffer(int clear)
|
|||
DSOUND_LockBuffer (false);
|
||||
}
|
||||
|
||||
void DSOUND_Restore(void)
|
||||
void
|
||||
DSOUND_Restore (void)
|
||||
{
|
||||
// if the buffer was lost or stopped, restore it and/or restart it
|
||||
DWORD dwStatus;
|
||||
|
||||
if (!pDSBuf) return;
|
||||
if (!pDSBuf)
|
||||
return;
|
||||
|
||||
if (IDirectSoundBuffer_GetStatus (pDSBuf, &dwStatus) != DD_OK)
|
||||
Con_Printf ("Couldn't get sound buffer status\n");
|
||||
|
@ -715,4 +723,3 @@ void DSOUND_Restore(void)
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue