From d16dc87dfadbde6955c82614699301bf84d03539 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 16 May 2001 18:59:31 +0000 Subject: [PATCH] fix oss' device openning mode. defaults to write only, but read/write can be selected by setting snd_oss_rw (need better name?) to non-zero --- include/QF/sound.h | 1 + libs/audio/targets/snd_dma.c | 4 ++++ libs/audio/targets/snd_oss.c | 6 +++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/QF/sound.h b/include/QF/sound.h index 99106e56e..71f4a0eb5 100644 --- a/include/QF/sound.h +++ b/include/QF/sound.h @@ -182,6 +182,7 @@ extern cvar_t *bgmvolume; extern cvar_t *volume; extern cvar_t *snd_device; +extern cvar_t *snd_oss_rw; extern cvar_t *snd_rate; extern cvar_t *snd_bits; extern cvar_t *snd_stereo; diff --git a/libs/audio/targets/snd_dma.c b/libs/audio/targets/snd_dma.c index 9eeee676f..cd77d167b 100644 --- a/libs/audio/targets/snd_dma.c +++ b/libs/audio/targets/snd_dma.c @@ -100,6 +100,7 @@ extern cvar_t *bgmvolume; extern cvar_t *volume; cvar_t *snd_device; +cvar_t *snd_oss_rw; cvar_t *snd_rate; cvar_t *snd_bits; cvar_t *snd_stereo; @@ -275,6 +276,9 @@ S_Init_Cvars (void) { snd_device = Cvar_Get ("snd_device", "", CVAR_ROM, NULL, "sound device. \"\" is system default"); + snd_oss_rw = Cvar_Get ("snd_oss_rw", "0", CVAR_ROM, NULL, + "open the oss device in r/w mode instead of w/o" + " (for braindead(?) drivers)"); snd_rate = Cvar_Get ("snd_rate", "0", CVAR_ROM, NULL, "sound playback rate. 0 is system default"); snd_bits = Cvar_Get ("snd_bits", "0", CVAR_ROM, NULL, diff --git a/libs/audio/targets/snd_oss.c b/libs/audio/targets/snd_oss.c index 2661fd6a1..09581c380 100644 --- a/libs/audio/targets/snd_oss.c +++ b/libs/audio/targets/snd_oss.c @@ -80,6 +80,7 @@ SNDDMA_Init (void) struct audio_buf_info info; int caps; int retries = 3; + int omode = O_WRONLY; snd_inited = 0; @@ -87,7 +88,10 @@ SNDDMA_Init (void) if (snd_device->string[0]) snd_dev = snd_device->string; - audio_fd = open (snd_dev, O_RDWR); + if (snd_oss_rw->int_val) + omode = O_RDWR; + + audio_fd = open (snd_dev, omode); if (audio_fd < 0) { // Failed open, retry up to 3 times // if it's busy while ((audio_fd < 0) && retries-- &&