mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-10 06:42:26 +00:00
OSS sound now retries opening /dev/dsp up to 3 times if it fails the first
time, by checking whether the device is busy or temporarily unavailable (I haven't seen the latter happen, but the former may occur if your window manager is set to make noise when a window pops up). Between tries, the client sleep()'s for one second (should this be half a second or even faster?).
This commit is contained in:
parent
4173134bae
commit
40269b2bb5
1 changed files with 15 additions and 7 deletions
|
@ -36,6 +36,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/wait.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
|
@ -78,18 +79,25 @@ SNDDMA_Init(void)
|
|||
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);
|
||||
if (audio_fd < 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (audio_fd < 0) {
|
||||
perror ("/dev/dsp");
|
||||
Con_Printf ("Could not open /dev/dsp\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
rc = ioctl(audio_fd, SNDCTL_DSP_RESET, 0);
|
||||
if (rc < 0)
|
||||
|
|
Loading…
Reference in a new issue