diff -r ff2dac607b41 Modules/ossaudiodev.c
--- a/Modules/ossaudiodev.c Fri Mar 20 00:27:28 2015 +0100
+++ b/Modules/ossaudiodev.c Fri Mar 20 00:29:44 2015 +0100
@@ -48,12 +48,12 @@ typedef unsigned long uint32_t;
typedef struct {
PyObject_HEAD
- char *devicename; /* name of the device file */
- int fd; /* file descriptor */
- int mode; /* file mode (O_RDONLY, etc.) */
- int icount; /* input count */
- int ocount; /* output count */
- uint32_t afmts; /* audio formats supported by hardware */
+ char *devicename; /* name of the device file */
+ int fd; /* file descriptor */
+ int mode; /* file mode (O_RDONLY, etc.) */
+ Py_ssize_t icount; /* input count */
+ Py_ssize_t ocount; /* output count */
+ uint32_t afmts; /* audio formats supported by hardware */
} oss_audio_t;
typedef struct {
@@ -399,15 +399,14 @@ oss_post(oss_audio_t *self, PyObject *ar
static PyObject *
oss_read(oss_audio_t *self, PyObject *args)
{
- int size, count;
+ Py_ssize_t size, count;
PyObject *rv;
if (!_is_fd_valid(self->fd))
return NULL;
- if (!PyArg_ParseTuple(args, "i:read", &size))
+ if (!PyArg_ParseTuple(args, "n:read", &size))
return NULL;
-
rv = PyBytes_FromStringAndSize(NULL, size);
if (rv == NULL)
return NULL;
@@ -426,17 +425,17 @@ oss_read(oss_audio_t *self, PyObject *ar
static PyObject *
oss_write(oss_audio_t *self, PyObject *args)
{
- char *cp;
- int rv, size;
+ Py_buffer buf;
+ Py_ssize_t rv;
if (!_is_fd_valid(self->fd))
return NULL;
- if (!PyArg_ParseTuple(args, "y#:write", &cp, &size)) {
+ if (!PyArg_ParseTuple(args, "y*:write", &buf))
return NULL;
- }
- rv = _Py_write(self->fd, cp, size);
+ rv = _Py_write(self->fd, buf.buf, buf.len);
+ PyBuffer_Release(&buf);
if (rv == -1)
return NULL;
@@ -447,10 +446,12 @@ oss_write(oss_audio_t *self, PyObject *a
static PyObject *
oss_writeall(oss_audio_t *self, PyObject *args)
{
+ Py_buffer buf;
char *cp;
- int rv, size;
+ Py_ssize_t size, rv;
fd_set write_set_fds;
int select_rv;
+ PyObject *res = NULL;
/* NB. writeall() is only useful in non-blocking mode: according to
Guenter Geiger