diff options
Diffstat (limited to 'Modules/sunaudiodev.c')
-rw-r--r-- | Modules/sunaudiodev.c | 65 |
1 files changed, 23 insertions, 42 deletions
diff --git a/Modules/sunaudiodev.c b/Modules/sunaudiodev.c index 514cab6..506ee33 100644 --- a/Modules/sunaudiodev.c +++ b/Modules/sunaudiodev.c @@ -58,7 +58,7 @@ newsadobject(PyObject *args) char* opendev; /* Check arg for r/w/rw */ - if (!PyArg_Parse(args, "s", &mode)) + if (!PyArg_ParseTuple(args, "s", &mode)) return NULL; if (strcmp(mode, "r") == 0) imode = 0; @@ -133,7 +133,7 @@ sad_read(sadobject *self, PyObject *args) char *cp; PyObject *rv; - if (!PyArg_Parse(args, "i", &size)) + if (!PyArg_ParseTuple(args, "i:read", &size)) return NULL; rv = PyString_FromStringAndSize(NULL, size); if (rv == NULL) @@ -169,7 +169,7 @@ sad_write(sadobject *self, PyObject *args) char *cp; int count, size; - if (!PyArg_Parse(args, "s#", &cp, &size)) + if (!PyArg_ParseTuple(args, "s#:write", &cp, &size)) return NULL; count = write(self->x_fd, cp, size); @@ -188,12 +188,10 @@ sad_write(sadobject *self, PyObject *args) } static PyObject * -sad_getinfo(sadobject *self, PyObject *args) +sad_getinfo(sadobject *self) { sadstatusobject *rv; - if (!PyArg_Parse(args, "")) - return NULL; if (!(rv = sads_alloc())) return NULL; @@ -222,12 +220,10 @@ sad_setinfo(sadobject *self, sadstatusobject *arg) } static PyObject * -sad_ibufcount(sadobject *self, PyObject *args) +sad_ibufcount(sadobject *self) { audio_info_t ai; - if (!PyArg_Parse(args, "")) - return NULL; if (ioctl(self->x_fd, AUDIO_GETINFO, &ai) < 0) { PyErr_SetFromErrno(SunAudioError); return NULL; @@ -236,12 +232,10 @@ sad_ibufcount(sadobject *self, PyObject *args) } static PyObject * -sad_obufcount(sadobject *self, PyObject *args) +sad_obufcount(sadobject *self) { audio_info_t ai; - if (!PyArg_Parse(args, "")) - return NULL; if (ioctl(self->x_fd, AUDIO_GETINFO, &ai) < 0) { PyErr_SetFromErrno(SunAudioError); return NULL; @@ -254,11 +248,8 @@ sad_obufcount(sadobject *self, PyObject *args) } static PyObject * -sad_drain(sadobject *self, PyObject *args) +sad_drain(sadobject *self) { - - if (!PyArg_Parse(args, "")) - return NULL; if (ioctl(self->x_fd, AUDIO_DRAIN, 0) < 0) { PyErr_SetFromErrno(SunAudioError); return NULL; @@ -269,12 +260,10 @@ sad_drain(sadobject *self, PyObject *args) #ifdef SOLARIS static PyObject * -sad_getdev(sadobject *self, PyObject *args) +sad_getdev(sadobject *self) { struct audio_device ad; - if (!PyArg_Parse(args, "")) - return NULL; if (ioctl(self->x_fd, AUDIO_GETDEV, &ad) < 0) { PyErr_SetFromErrno(SunAudioError); return NULL; @@ -284,11 +273,8 @@ sad_getdev(sadobject *self, PyObject *args) #endif static PyObject * -sad_flush(sadobject *self, PyObject *args) +sad_flush(sadobject *self) { - - if (!PyArg_Parse(args, "")) - return NULL; if (ioctl(self->x_fd, I_FLUSH, FLUSHW) < 0) { PyErr_SetFromErrno(SunAudioError); return NULL; @@ -298,11 +284,9 @@ sad_flush(sadobject *self, PyObject *args) } static PyObject * -sad_close(sadobject *self, PyObject *args) +sad_close(sadobject *self) { - if (!PyArg_Parse(args, "")) - return NULL; if (self->x_fd >= 0) { close(self->x_fd); self->x_fd = -1; @@ -312,30 +296,27 @@ sad_close(sadobject *self, PyObject *args) } static PyObject * -sad_fileno(sadobject *self, PyObject *args) +sad_fileno(sadobject *self) { - if (!PyArg_Parse(args, "")) - return NULL; - return PyInt_FromLong(self->x_fd); } static PyMethodDef sad_methods[] = { - { "read", (PyCFunction)sad_read, METH_OLDARGS }, - { "write", (PyCFunction)sad_write, METH_OLDARGS }, - { "ibufcount", (PyCFunction)sad_ibufcount, METH_OLDARGS }, - { "obufcount", (PyCFunction)sad_obufcount, METH_OLDARGS }, + { "read", (PyCFunction)sad_read, METH_VARARGS }, + { "write", (PyCFunction)sad_write, METH_VARARGS }, + { "ibufcount", (PyCFunction)sad_ibufcount, METH_NOARGS }, + { "obufcount", (PyCFunction)sad_obufcount, METH_NOARGS }, #define CTL_METHODS 4 - { "getinfo", (PyCFunction)sad_getinfo, METH_OLDARGS }, - { "setinfo", (PyCFunction)sad_setinfo, METH_OLDARGS }, - { "drain", (PyCFunction)sad_drain, METH_OLDARGS }, - { "flush", (PyCFunction)sad_flush, METH_OLDARGS }, + { "getinfo", (PyCFunction)sad_getinfo, METH_NOARGS }, + { "setinfo", (PyCFunction)sad_setinfo, METH_O}, + { "drain", (PyCFunction)sad_drain, METH_NOARGS }, + { "flush", (PyCFunction)sad_flush, METH_NOARGS }, #ifdef SOLARIS - { "getdev", (PyCFunction)sad_getdev, METH_OLDARGS }, + { "getdev", (PyCFunction)sad_getdev, METH_NOARGS }, #endif - { "close", (PyCFunction)sad_close, METH_OLDARGS }, - { "fileno", (PyCFunction)sad_fileno, METH_OLDARGS }, + { "close", (PyCFunction)sad_close, METH_NOARGS }, + { "fileno", (PyCFunction)sad_fileno, METH_NOARGS }, {NULL, NULL} /* sentinel */ }; @@ -465,7 +446,7 @@ sadopen(PyObject *self, PyObject *args) } static PyMethodDef sunaudiodev_methods[] = { - { "open", sadopen, METH_OLDARGS }, + { "open", sadopen, METH_VARARGS }, { 0, 0 }, }; |