diff -ru quakeforge-0.5.5.orig1/libs/audio/targets/snd_oss.c quakeforge-0.5.5/libs/audio/targets/snd_oss.c --- quakeforge-0.5.5.orig1/libs/audio/targets/snd_oss.c 2004-01-15 18:50:26.000000000 -0800 +++ quakeforge-0.5.5/libs/audio/targets/snd_oss.c 2008-06-04 15:47:01.000000000 -0700 @@ -83,7 +83,7 @@ static const char *snd_dev = "/dev/dsp"; static volatile dma_t sn; -static int tryrates[] = { 11025, 22050, 22051, 44100, 8000 }; +static int tryrates[] = { 44100, 48000, 11025, 22050, 22051, 44100, 8000 }; static cvar_t *snd_stereo; static cvar_t *snd_rate; @@ -171,12 +171,6 @@ return 0; } - if (ioctl (audio_fd, SNDCTL_DSP_GETOSPACE, &info) == -1) { - Sys_Printf ("Um, can't do GETOSPACE?: %s\n", strerror (errno)); - close (audio_fd); - return 0; - } - sn.splitbuffer = 0; // set sample bits & speed @@ -194,6 +188,40 @@ } } + if (sn.samplebits == 16) { + rc = AFMT_S16_LE; + rc = ioctl (audio_fd, SNDCTL_DSP_SETFMT, &rc); + if (rc < 0) { + Sys_Printf ("Could not support 16-bit data. Try 8-bit. %s\n", + strerror (errno)); + close (audio_fd); + return 0; + } + } else if (sn.samplebits == 8) { + rc = AFMT_U8; + rc = ioctl (audio_fd, SNDCTL_DSP_SETFMT, &rc); + if (rc < 0) { + Sys_Printf ("Could not support 8-bit data. %s\n", + strerror (errno)); + close (audio_fd); + return 0; + } + } else { + Sys_Printf ("%d-bit sound not supported. %s", sn.samplebits, + strerror (errno)); + close (audio_fd); + return 0; + } + + tmp = sn.channels; + rc = ioctl (audio_fd, SNDCTL_DSP_CHANNELS, &tmp); + if (rc < 0) { + Sys_Printf ("Could not set %s to stereo=%d: %s\n", snd_dev, + sn.channels, strerror (errno)); + close (audio_fd); + return 0; + } + if (snd_rate->int_val) { sn.speed = snd_rate->int_val; } else { @@ -209,25 +237,6 @@ sn.channels = 2; } - sn.samples = info.fragstotal * info.fragsize / (sn.samplebits / 8); - sn.submission_chunk = 1; - - tmp = 0; - if (sn.channels == 2) - tmp = 1; - rc = ioctl (audio_fd, SNDCTL_DSP_STEREO, &tmp); - if (rc < 0) { - Sys_Printf ("Could not set %s to stereo=%d: %s\n", snd_dev, - sn.channels, strerror (errno)); - close (audio_fd); - return 0; - } - - if (tmp) - sn.channels = 2; - else - sn.channels = 1; - rc = ioctl (audio_fd, SNDCTL_DSP_SPEED, &sn.speed); if (rc < 0) { Sys_Printf ("Could not set %s speed to %d: %s\n", snd_dev, sn.speed, @@ -236,31 +245,15 @@ return 0; } - if (sn.samplebits == 16) { - rc = AFMT_S16_LE; - rc = ioctl (audio_fd, SNDCTL_DSP_SETFMT, &rc); - if (rc < 0) { - Sys_Printf ("Could not support 16-bit data. Try 8-bit. %s\n", - strerror (errno)); - close (audio_fd); - return 0; - } - } else if (sn.samplebits == 8) { - rc = AFMT_U8; - rc = ioctl (audio_fd, SNDCTL_DSP_SETFMT, &rc); - if (rc < 0) { - Sys_Printf ("Could not support 8-bit data. %s\n", - strerror (errno)); - close (audio_fd); - return 0; - } - } else { - Sys_Printf ("%d-bit sound not supported. %s", sn.samplebits, - strerror (errno)); + if (ioctl (audio_fd, SNDCTL_DSP_GETOSPACE, &info) == -1) { + Sys_Printf ("Um, can't do GETOSPACE?: %s\n", strerror (errno)); close (audio_fd); return 0; } - + + sn.samples = info.fragstotal * info.fragsize / (sn.samplebits / 8); + sn.submission_chunk = 1; + if (mmaped_io) { // memory map the dma buffer unsigned long sz = sysconf (_SC_PAGESIZE); unsigned long len = info.fragstotal * info.fragsize;