diff --git a/libs/audio/targets/snd_oss.c b/libs/audio/targets/snd_oss.c index ff401a20d..ff578aaa2 100644 --- a/libs/audio/targets/snd_oss.c +++ b/libs/audio/targets/snd_oss.c @@ -108,6 +108,7 @@ SNDDMA_Init (void) int caps; int retries = 3; int omode = O_WRONLY; + int mmmode = PROT_WRITE; snd_inited = 0; @@ -115,8 +116,10 @@ SNDDMA_Init (void) if (snd_device->string[0]) snd_dev = snd_device->string; - if (snd_oss_rw->int_val) + if (snd_oss_rw->int_val) { omode = O_RDWR; + mmmode |= PROT_READ; + } audio_fd = open (snd_dev, omode); if (audio_fd < 0) { // Failed open, retry up to 3 times @@ -124,7 +127,7 @@ SNDDMA_Init (void) while ((audio_fd < 0) && retries-- && ((errno == EAGAIN) || (errno == EBUSY))) { sleep (1); - audio_fd = open (snd_dev, O_RDWR); + audio_fd = open (snd_dev, omode); } if (audio_fd < 0) { perror (snd_dev); @@ -199,7 +202,7 @@ SNDDMA_Init (void) // memory map the dma buffer shm->buffer = (unsigned char *) mmap (NULL, info.fragstotal * info.fragsize, - PROT_READ | PROT_WRITE, + mmmode, MAP_FILE | MAP_SHARED, audio_fd, 0); if (shm->buffer == MAP_FAILED) {