--- bsd/snd_bsd.c.orig Mon Jan 7 12:16:25 2002 +++ bsd/snd_bsd.c Wed Mar 14 15:25:14 2007 @@ -49,7 +49,7 @@ if (!audio_fd) { seteuid(saved_euid); - audio_fd = open(snddevice->string, O_RDWR); + audio_fd = open(snddevice->string, O_WRONLY); seteuid(getuid()); @@ -85,14 +85,6 @@ return 0; } - if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info)==-1) - { - perror("GETOSPACE"); - Com_Printf("Um, can't do GETOSPACE?\n"); - close(audio_fd); - return 0; - } - // set sample bits & speed dma.samplebits = (int)sndbits->value; @@ -114,6 +106,14 @@ if (dma.channels < 1 || dma.channels > 2) dma.channels = 2; + if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info)==-1) + { + perror("GETOSPACE"); + Com_Printf("Um, can't do GETOSPACE?\n"); + close(audio_fd); + return 0; + } + dma.samples = info.fragstotal * info.fragsize / (dma.samplebits/8); dma.submission_chunk = 1; @@ -121,7 +121,7 @@ if (!dma.buffer) dma.buffer = (unsigned char *) mmap(NULL, info.fragstotal - * info.fragsize, PROT_WRITE, MAP_FILE|MAP_SHARED, audio_fd, 0); + * info.fragsize, PROT_WRITE, MAP_SHARED, audio_fd, 0); if (!dma.buffer) { perror(snddevice->string); --- src/snd_oss.c.orig Mon Mar 15 10:25:43 2004 +++ src/snd_oss.c Wed Mar 14 15:22:38 2007 @@ -194,7 +194,7 @@ { /* seteuid(saved_euid);*/ - audio_fd = open(si->device->string, O_RDWR); + audio_fd = open(si->device->string, O_WRONLY); /* moved from below in snd_bsd.c -- jaq */ /*seteuid(getuid());*/ @@ -239,15 +239,6 @@ return 0; } - if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info)==-1) - { - perror("GETOSPACE"); - si->Com_Printf("SNDDMA_Init: GETOSPACE ioctl failed.\n"); - close(audio_fd); - audio_fd = -1; - return 0; - } - // set sample bits & speed si->dma->samplebits = (int)si->bits->value; @@ -347,6 +338,15 @@ /* RELNEV 0.9 insert the mmap stuff here */ + if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info)==-1) + { + perror("GETOSPACE"); + si->Com_Printf("SNDDMA_Init: GETOSPACE ioctl failed.\n"); + close(audio_fd); + audio_fd = -1; + return 0; + } + // toggle the trigger & start her up tmp = 0; @@ -358,12 +358,8 @@ if (!si->dma->buffer) { si->dma->buffer = (unsigned char *) mmap(NULL, info.fragstotal * info.fragsize, -#if defined(__FreeBSD__) && (__FreeBSD_version < 500000) - PROT_READ|PROT_WRITE, -#else PROT_WRITE, -#endif - MAP_FILE|MAP_SHARED, audio_fd, 0); + MAP_SHARED, audio_fd, 0); } if (!si->dma->buffer || si->dma->buffer == MAP_FAILED) { perror(si->device->string);