diff options
author | Guido van Rossum <guido@python.org> | 2001-04-02 17:59:02 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-04-02 17:59:02 (GMT) |
commit | f5bd6843377a4f4433700282f5c4bddb3d6333ae (patch) | |
tree | b2aaa62669baf3f659e8605ca61bdd173f4fcba8 /Modules/linuxaudiodev.c | |
parent | cb67ea1d6e2dfb2680bba29144ef33fd2cc9a21a (diff) | |
download | cpython-f5bd6843377a4f4433700282f5c4bddb3d6333ae.zip cpython-f5bd6843377a4f4433700282f5c4bddb3d6333ae.tar.gz cpython-f5bd6843377a4f4433700282f5c4bddb3d6333ae.tar.bz2 |
Applying SF patch #412553 by Christopher Lee: fix linuxaudiodev
handling of EAGAIN.
This may or may not fix the problem for me (Mandrake 7.2 on a Dell
Optiplex GX110 desktop): I can't hear the output, but it does pass the
test now. It doesn't fix the problem for Fred (Mandrake 7.2 on a Dell
Inspiron 7500 which has the Maestro sound drivers). Fred suspects
that it's the kernel version in combination with the driver.
Diffstat (limited to 'Modules/linuxaudiodev.c')
-rw-r--r-- | Modules/linuxaudiodev.c | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/Modules/linuxaudiodev.c b/Modules/linuxaudiodev.c index a0661c5..37ad5ff 100644 --- a/Modules/linuxaudiodev.c +++ b/Modules/linuxaudiodev.c @@ -4,8 +4,6 @@ * * Author : Peter Bosch * Created On : Thu Mar 2 21:10:33 2000 - * Last Modified By: Peter Bosch - * Last Modified On: Fri Mar 24 11:27:00 2000 * Status : Unknown, Use with caution! * * Unless other notices are present in any part of this file @@ -174,18 +172,40 @@ lad_write(lad_t *self, PyObject *args) { char *cp; int rv, size; - + fd_set write_set_fds; + struct timeval tv; + int select_retval; + if (!PyArg_ParseTuple(args, "s#:write", &cp, &size)) return NULL; + /* use select to wait for audio device to be available */ + FD_ZERO(&write_set_fds); + FD_SET(self->x_fd, &write_set_fds); + tv.tv_sec = 4; /* timeout values */ + tv.tv_usec = 0; + while (size > 0) { + select_retval = select(self->x_fd+1, NULL, &write_set_fds, NULL, &tv); + tv.tv_sec = 1; tv.tv_usec = 0; /* willing to wait this long next time*/ + if (select_retval) { if ((rv = write(self->x_fd, cp, size)) == -1) { - PyErr_SetFromErrno(LinuxAudioError); - return NULL; - } - self->x_ocount += rv; - size -= rv; - cp += rv; + if (errno != EAGAIN) { + PyErr_SetFromErrno(LinuxAudioError); + return NULL; + } else { + errno = 0; /* EAGAIN: buffer is full, try again */ + } + } else { + self->x_ocount += rv; + size -= rv; + cp += rv; + } + } else { + /* printf("Not able to write to linux audio device within %ld seconds\n", tv.tv_sec); */ + PyErr_SetFromErrno(LinuxAudioError); + return NULL; + } } Py_INCREF(Py_None); return Py_None; |