static PyTypeObject Ladtype;
-static PyObject *LinuxAudioError;
+static PyObject *OSSAudioError;
static lad_t *
newladobject(PyObject *arg)
else if (strcmp(mode, "rw") == 0)
imode = O_RDWR;
else {
- PyErr_SetString(LinuxAudioError, "mode must be 'r', 'w', or 'rw'");
+ PyErr_SetString(OSSAudioError, "mode must be 'r', 'w', or 'rw'");
return NULL;
}
}
if ((fd = open(basedev, imode)) == -1) {
- PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev);
+ PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev);
return NULL;
}
if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) {
- PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev);
+ PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev);
return NULL;
}
/* Create and initialize the object */
return NULL;
if (ioctl(self->x_fd, cmd, &arg) == -1)
- return PyErr_SetFromErrno(LinuxAudioError);
+ return PyErr_SetFromErrno(PyExc_IOError);
return PyInt_FromLong(arg);
}
return NULL;
if (ioctl(self->x_fd, cmd, 0) == -1)
- return PyErr_SetFromErrno(LinuxAudioError);
+ return PyErr_SetFromErrno(PyExc_IOError);
Py_INCREF(Py_None);
return Py_None;
}
if (!PyArg_ParseTuple(args, ":nonblock"))
return NULL;
if (ioctl(self->x_fd, SNDCTL_DSP_NONBLOCK, NULL) == -1)
- return PyErr_SetFromErrno(LinuxAudioError);
+ return PyErr_SetFromErrno(PyExc_IOError);
Py_INCREF(Py_None);
return Py_None;
}
if (!PyArg_ParseTuple(args, ":getfmts"))
return NULL;
if (ioctl(self->x_fd, SNDCTL_DSP_GETFMTS, &mask) == -1)
- return PyErr_SetFromErrno(LinuxAudioError);
+ return PyErr_SetFromErrno(PyExc_IOError);
return PyInt_FromLong(mask);
}
return NULL;
cp = PyString_AS_STRING(rv);
if ((count = read(self->x_fd, cp, size)) < 0) {
- PyErr_SetFromErrno(LinuxAudioError);
+ PyErr_SetFromErrno(PyExc_IOError);
Py_DECREF(rv);
return NULL;
}
return NULL;
}
if ((rv = write(self->x_fd, cp, size)) == -1) {
- return PyErr_SetFromErrno(LinuxAudioError);
+ return PyErr_SetFromErrno(PyExc_IOError);
} else {
self->x_ocount += rv;
}
select_rv = select(self->x_fd+1, NULL, &write_set_fds, NULL, NULL);
assert(select_rv != 0); /* no timeout, can't expire */
if (select_rv == -1)
- return PyErr_SetFromErrno(LinuxAudioError);
+ return PyErr_SetFromErrno(PyExc_IOError);
rv = write(self->x_fd, cp, size);
if (rv == -1) {
errno = 0;
continue;
} else /* it's a real error */
- return PyErr_SetFromErrno(LinuxAudioError);
+ return PyErr_SetFromErrno(PyExc_IOError);
} else { /* wrote rv bytes */
self->x_ocount += rv;
size -= rv;
}
if (ioctl(self->x_fd, SNDCTL_DSP_SETFMT,
&audio_types[n].a_fmt) == -1) {
- PyErr_SetFromErrno(LinuxAudioError);
+ PyErr_SetFromErrno(PyExc_IOError);
return NULL;
}
if (ioctl(self->x_fd, SNDCTL_DSP_CHANNELS, &nchannels) == -1) {
- PyErr_SetFromErrno(LinuxAudioError);
+ PyErr_SetFromErrno(PyExc_IOError);
return NULL;
}
if (ioctl(self->x_fd, SNDCTL_DSP_SPEED, &rate) == -1) {
- PyErr_SetFromErrno(LinuxAudioError);
+ PyErr_SetFromErrno(PyExc_IOError);
return NULL;
}
if (!PyArg_ParseTuple(args, ":bufsize")) return NULL;
if (_ssize(self, &nchannels, &ssize) < 0) {
- PyErr_SetFromErrno(LinuxAudioError);
+ PyErr_SetFromErrno(PyExc_IOError);
return NULL;
}
if (ioctl(self->x_fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) {
- PyErr_SetFromErrno(LinuxAudioError);
+ PyErr_SetFromErrno(PyExc_IOError);
return NULL;
}
return PyInt_FromLong((ai.fragstotal * ai.fragsize) / (nchannels * ssize));
return NULL;
if (_ssize(self, &nchannels, &ssize) < 0) {
- PyErr_SetFromErrno(LinuxAudioError);
+ PyErr_SetFromErrno(PyExc_IOError);
return NULL;
}
if (ioctl(self->x_fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) {
- PyErr_SetFromErrno(LinuxAudioError);
+ PyErr_SetFromErrno(PyExc_IOError);
return NULL;
}
return PyInt_FromLong((ai.fragstotal * ai.fragsize - ai.bytes) /
return NULL;
if (_ssize(self, &nchannels, &ssize) < 0) {
- PyErr_SetFromErrno(LinuxAudioError);
+ PyErr_SetFromErrno(PyExc_IOError);
return NULL;
}
if (ioctl(self->x_fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) {
- PyErr_SetFromErrno(LinuxAudioError);
+ PyErr_SetFromErrno(PyExc_IOError);
return NULL;
}
return PyInt_FromLong(ai.bytes / (ssize * nchannels));
else
req = SNDCTL_DSP_GETOPTR;
if (ioctl(self->x_fd, req, &info) == -1) {
- PyErr_SetFromErrno(LinuxAudioError);
+ PyErr_SetFromErrno(PyExc_IOError);
return NULL;
}
return Py_BuildValue("iii", info.bytes, info.blocks, info.ptr);
m = Py_InitModule("linuxaudiodev", linuxaudiodev_methods);
- LinuxAudioError = PyErr_NewException("linuxaudiodev.error", NULL, NULL);
- if (LinuxAudioError)
- PyModule_AddObject(m, "error", LinuxAudioError);
+ OSSAudioError = PyErr_NewException("ossaudiodev.error", NULL, NULL);
+ if (OSSAudioError)
+ PyModule_AddObject(m, "error", OSSAudioError);
/* Expose the audio format numbers -- essential! */
_EXPORT_INT(m, AFMT_QUERY);