Kaydet (Commit) 99953006 authored tarafından Victor Stinner's avatar Victor Stinner

Issue #23709, #23001: ossaudiodev now uses Py_ssize_t for sizes instead of int

The module is now also "SSIZE_T clean" (for PyArg_Parse...() functions) since
it switched to Py_buffer ("y*" argument format).
üst 716a74ea
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
* $Id$ * $Id$
*/ */
#define PY_SSIZE_T_CLEAN
#include "Python.h" #include "Python.h"
#include "structmember.h" #include "structmember.h"
...@@ -51,8 +52,8 @@ typedef struct { ...@@ -51,8 +52,8 @@ typedef struct {
char *devicename; /* name of the device file */ char *devicename; /* name of the device file */
int fd; /* file descriptor */ int fd; /* file descriptor */
int mode; /* file mode (O_RDONLY, etc.) */ int mode; /* file mode (O_RDONLY, etc.) */
int icount; /* input count */ Py_ssize_t icount; /* input count */
int ocount; /* output count */ Py_ssize_t ocount; /* output count */
uint32_t afmts; /* audio formats supported by hardware */ uint32_t afmts; /* audio formats supported by hardware */
} oss_audio_t; } oss_audio_t;
...@@ -399,13 +400,13 @@ oss_post(oss_audio_t *self, PyObject *args) ...@@ -399,13 +400,13 @@ oss_post(oss_audio_t *self, PyObject *args)
static PyObject * static PyObject *
oss_read(oss_audio_t *self, PyObject *args) oss_read(oss_audio_t *self, PyObject *args)
{ {
int size, count; Py_ssize_t size, count;
PyObject *rv; PyObject *rv;
if (!_is_fd_valid(self->fd)) if (!_is_fd_valid(self->fd))
return NULL; return NULL;
if (!PyArg_ParseTuple(args, "i:read", &size)) if (!PyArg_ParseTuple(args, "n:read", &size))
return NULL; return NULL;
rv = PyBytes_FromStringAndSize(NULL, size); rv = PyBytes_FromStringAndSize(NULL, size);
...@@ -427,7 +428,7 @@ static PyObject * ...@@ -427,7 +428,7 @@ static PyObject *
oss_write(oss_audio_t *self, PyObject *args) oss_write(oss_audio_t *self, PyObject *args)
{ {
Py_buffer data; Py_buffer data;
int rv; Py_ssize_t rv;
if (!_is_fd_valid(self->fd)) if (!_is_fd_valid(self->fd))
return NULL; return NULL;
...@@ -451,7 +452,7 @@ oss_writeall(oss_audio_t *self, PyObject *args) ...@@ -451,7 +452,7 @@ oss_writeall(oss_audio_t *self, PyObject *args)
Py_buffer data; Py_buffer data;
const char *cp; const char *cp;
Py_ssize_t size; Py_ssize_t size;
int rv; Py_ssize_t rv;
fd_set write_set_fds; fd_set write_set_fds;
int select_rv; int select_rv;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment