/* obufcount returns the number of samples that can be played without blocking */ static PyObject * lad_obuffree(lad_t *self, PyObject *unused) { audio_buf_info ai; int nchannels=0, ssize=0; if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) { PyErr_SetFromErrno(LinuxAudioError); return NULL; } if (ioctl(self->x_fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) { PyErr_SetFromErrno(LinuxAudioError); return NULL; } return PyInt_FromLong(ai.bytes / (ssize * nchannels)); }
/* obufcount returns the number of samples that can be played without blocking */ static PyObject * oss_obuffree(oss_audio_t *self, PyObject *unused) { audio_buf_info ai; int nchannels=0, ssize=0; if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) { PyErr_SetFromErrno(PyExc_IOError); return NULL; } if (ioctl(self->fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) { PyErr_SetFromErrno(PyExc_IOError); return NULL; } return PyLong_FromLong(ai.bytes / (ssize * nchannels)); }
/* bufsize returns the size of the hardware audio buffer in number of samples */ static PyObject * oss_bufsize(oss_audio_t *self, PyObject *unused) { audio_buf_info ai; int nchannels=0, ssize=0; if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) { PyErr_SetFromErrno(PyExc_IOError); return NULL; } if (ioctl(self->fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) { PyErr_SetFromErrno(PyExc_IOError); return NULL; } return PyInt_FromLong((ai.fragstotal * ai.fragsize) / (nchannels * ssize)); }
/* bufsize returns the size of the hardware audio buffer in number of samples */ static PyObject * oss_bufsize(oss_audio_t *self, PyObject *args) { audio_buf_info ai; int nchannels, ssize; if (!PyArg_ParseTuple(args, ":bufsize")) return NULL; if (_ssize(self, &nchannels, &ssize) < 0) { PyErr_SetFromErrno(PyExc_IOError); return NULL; } if (ioctl(self->fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) { PyErr_SetFromErrno(PyExc_IOError); return NULL; } return PyInt_FromLong((ai.fragstotal * ai.fragsize) / (nchannels * ssize)); }
/* obufcount returns the number of samples that can be played without blocking */ static PyObject * oss_obuffree(oss_audio_t *self, PyObject *args) { audio_buf_info ai; int nchannels, ssize; if (!PyArg_ParseTuple(args, ":obuffree")) return NULL; if (_ssize(self, &nchannels, &ssize) < 0) { PyErr_SetFromErrno(PyExc_IOError); return NULL; } if (ioctl(self->fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) { PyErr_SetFromErrno(PyExc_IOError); return NULL; } return PyInt_FromLong(ai.bytes / (ssize * nchannels)); }
/* obufcount returns the number of samples that are available in the hardware for playing */ static PyObject * oss_obufcount(oss_audio_t *self, PyObject *unused) { audio_buf_info ai; int nchannels=0, ssize=0; if (!_is_fd_valid(self->fd)) return NULL; if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) { PyErr_SetFromErrno(PyExc_IOError); return NULL; } if (ioctl(self->fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) { PyErr_SetFromErrno(PyExc_IOError); return NULL; } return PyLong_FromLong((ai.fragstotal * ai.fragsize - ai.bytes) / (ssize * nchannels)); }