[Python-checkins] python/dist/src/Modules ossaudiodev.c,1.13,1.14
gward@users.sourceforge.net
gward@users.sourceforge.net
Sun, 29 Dec 2002 19:02:25 -0800
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv8659
Modified Files:
ossaudiodev.c
Log Message:
Untabify.
Index: ossaudiodev.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/ossaudiodev.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** ossaudiodev.c 30 Dec 2002 03:01:48 -0000 1.13
--- ossaudiodev.c 30 Dec 2002 03:02:22 -0000 1.14
***************
*** 57,61 ****
typedef struct {
PyObject_HEAD;
! int fd; /* The open mixer device */
} oss_mixer_t;
--- 57,61 ----
typedef struct {
PyObject_HEAD;
! int fd; /* The open mixer device */
} oss_mixer_t;
***************
*** 65,81 ****
static struct {
! int a_bps;
! uint32_t a_fmt;
char *a_name;
} audio_types[] = {
! { 8, AFMT_MU_LAW, "logarithmic mu-law 8-bit audio" },
! { 8, AFMT_A_LAW, "logarithmic A-law 8-bit audio" },
! { 8, AFMT_U8, "linear unsigned 8-bit audio" },
! { 8, AFMT_S8, "linear signed 8-bit audio" },
! { 16, AFMT_U16_BE, "linear unsigned 16-bit big-endian audio" },
! { 16, AFMT_U16_LE, "linear unsigned 16-bit little-endian audio" },
! { 16, AFMT_S16_BE, "linear signed 16-bit big-endian audio" },
! { 16, AFMT_S16_LE, "linear signed 16-bit little-endian audio" },
! { 16, AFMT_S16_NE, "linear signed 16-bit native-endian audio" },
};
--- 65,81 ----
static struct {
! int a_bps;
! uint32_t a_fmt;
char *a_name;
} audio_types[] = {
! { 8, AFMT_MU_LAW, "logarithmic mu-law 8-bit audio" },
! { 8, AFMT_A_LAW, "logarithmic A-law 8-bit audio" },
! { 8, AFMT_U8, "linear unsigned 8-bit audio" },
! { 8, AFMT_S8, "linear signed 8-bit audio" },
! { 16, AFMT_U16_BE, "linear unsigned 16-bit big-endian audio" },
! { 16, AFMT_U16_LE, "linear unsigned 16-bit little-endian audio" },
! { 16, AFMT_S16_BE, "linear signed 16-bit big-endian audio" },
! { 16, AFMT_S16_LE, "linear signed 16-bit little-endian audio" },
! { 16, AFMT_S16_NE, "linear signed 16-bit native-endian audio" },
};
***************
*** 151,155 ****
/* if already closed, don't reclose it */
if (xp->fd != -1)
! close(xp->fd);
PyObject_Del(xp);
}
--- 151,155 ----
/* if already closed, don't reclose it */
if (xp->fd != -1)
! close(xp->fd);
PyObject_Del(xp);
}
***************
*** 163,173 ****
if (!PyArg_ParseTuple(arg, "|ss", &basedev, &mode)) {
! return NULL;
}
if (basedev == NULL) {
! basedev = getenv("MIXERDEV");
! if (basedev == NULL) /* MIXERDEV not set */
! basedev = "/dev/mixer";
}
--- 163,173 ----
if (!PyArg_ParseTuple(arg, "|ss", &basedev, &mode)) {
! return NULL;
}
if (basedev == NULL) {
! basedev = getenv("MIXERDEV");
! if (basedev == NULL) /* MIXERDEV not set */
! basedev = "/dev/mixer";
}
***************
*** 203,207 ****
/* if already closed, don't reclose it */
if (xp->fd != -1)
! close(xp->fd);
PyObject_Del(xp);
}
--- 203,207 ----
/* if already closed, don't reclose it */
if (xp->fd != -1)
! close(xp->fd);
PyObject_Del(xp);
}
***************
*** 234,238 ****
strcat(argfmt, fname);
if (!PyArg_ParseTuple(args, argfmt, &arg))
! return NULL;
if (ioctl(fd, cmd, &arg) == -1)
--- 234,238 ----
strcat(argfmt, fname);
if (!PyArg_ParseTuple(args, argfmt, &arg))
! return NULL;
if (ioctl(fd, cmd, &arg) == -1)
***************
*** 259,263 ****
strcat(argfmt, fname);
if (!PyArg_ParseTuple(args, argfmt, &arg))
! return NULL;
if (ioctl(fd, cmd, &arg) == -1)
--- 259,263 ----
strcat(argfmt, fname);
if (!PyArg_ParseTuple(args, argfmt, &arg))
! return NULL;
if (ioctl(fd, cmd, &arg) == -1)
***************
*** 278,282 ****
strcat(argfmt, fname);
if (!PyArg_ParseTuple(args, argfmt))
! return NULL;
if (ioctl(fd, cmd, 0) == -1)
--- 278,282 ----
strcat(argfmt, fname);
if (!PyArg_ParseTuple(args, argfmt))
! return NULL;
if (ioctl(fd, cmd, 0) == -1)
***************
*** 293,297 ****
mode once we're in non-blocking mode! */
if (!PyArg_ParseTuple(args, ":nonblock"))
! return NULL;
if (ioctl(self->fd, SNDCTL_DSP_NONBLOCK, NULL) == -1)
return PyErr_SetFromErrno(PyExc_IOError);
--- 293,297 ----
mode once we're in non-blocking mode! */
if (!PyArg_ParseTuple(args, ":nonblock"))
! return NULL;
if (ioctl(self->fd, SNDCTL_DSP_NONBLOCK, NULL) == -1)
return PyErr_SetFromErrno(PyExc_IOError);
***************
*** 311,315 ****
int mask;
if (!PyArg_ParseTuple(args, ":getfmts"))
! return NULL;
if (ioctl(self->fd, SNDCTL_DSP_GETFMTS, &mask) == -1)
return PyErr_SetFromErrno(PyExc_IOError);
--- 311,315 ----
int mask;
if (!PyArg_ParseTuple(args, ":getfmts"))
! return NULL;
if (ioctl(self->fd, SNDCTL_DSP_GETFMTS, &mask) == -1)
return PyErr_SetFromErrno(PyExc_IOError);
***************
*** 357,361 ****
char *cp;
PyObject *rv;
!
if (!PyArg_ParseTuple(args, "i:read", &size))
return NULL;
--- 357,361 ----
char *cp;
PyObject *rv;
!
if (!PyArg_ParseTuple(args, "i:read", &size))
return NULL;
***************
*** 381,385 ****
if (!PyArg_ParseTuple(args, "s#:write", &cp, &size)) {
! return NULL;
}
if ((rv = write(self->fd, cp, size)) == -1) {
--- 381,385 ----
if (!PyArg_ParseTuple(args, "s#:write", &cp, &size)) {
! return NULL;
}
if ((rv = write(self->fd, cp, size)) == -1) {
***************
*** 440,444 ****
{
if (!PyArg_ParseTuple(args, ":close"))
! return NULL;
if (self->fd >= 0) {
--- 440,444 ----
{
if (!PyArg_ParseTuple(args, ":close"))
! return NULL;
if (self->fd >= 0) {
***************
*** 454,458 ****
{
if (!PyArg_ParseTuple(args, ":fileno"))
! return NULL;
return PyInt_FromLong(self->fd);
}
--- 454,458 ----
{
if (!PyArg_ParseTuple(args, ":fileno"))
! return NULL;
return PyInt_FromLong(self->fd);
}
***************
*** 472,488 ****
if (rate < 0) {
! PyErr_Format(PyExc_ValueError, "expected rate >= 0, not %d",
! rate);
! return NULL;
}
if (ssize < 0) {
! PyErr_Format(PyExc_ValueError, "expected sample size >= 0, not %d",
! ssize);
! return NULL;
}
if (nchannels != 1 && nchannels != 2) {
! PyErr_Format(PyExc_ValueError, "nchannels must be 1 or 2, not %d",
! nchannels);
! return NULL;
}
--- 472,488 ----
if (rate < 0) {
! PyErr_Format(PyExc_ValueError, "expected rate >= 0, not %d",
! rate);
! return NULL;
}
if (ssize < 0) {
! PyErr_Format(PyExc_ValueError, "expected sample size >= 0, not %d",
! ssize);
! return NULL;
}
if (nchannels != 1 && nchannels != 2) {
! PyErr_Format(PyExc_ValueError, "nchannels must be 1 or 2, not %d",
! nchannels);
! return NULL;
}
***************
*** 491,514 ****
break;
if (n == n_audio_types) {
! PyErr_Format(PyExc_ValueError, "unknown audio encoding: %d", fmt);
! return NULL;
}
if (audio_types[n].a_bps != ssize) {
! PyErr_Format(PyExc_ValueError,
! "for %s, expected sample size %d, not %d",
! audio_types[n].a_name, audio_types[n].a_bps, ssize);
! return NULL;
}
if (emulate == 0) {
! if ((self->afmts & audio_types[n].a_fmt) == 0) {
! PyErr_Format(PyExc_ValueError,
! "%s format not supported by device",
! audio_types[n].a_name);
! return NULL;
! }
}
if (ioctl(self->fd, SNDCTL_DSP_SETFMT,
! &audio_types[n].a_fmt) == -1) {
PyErr_SetFromErrno(PyExc_IOError);
return NULL;
--- 491,514 ----
break;
if (n == n_audio_types) {
! PyErr_Format(PyExc_ValueError, "unknown audio encoding: %d", fmt);
! return NULL;
}
if (audio_types[n].a_bps != ssize) {
! PyErr_Format(PyExc_ValueError,
! "for %s, expected sample size %d, not %d",
! audio_types[n].a_name, audio_types[n].a_bps, ssize);
! return NULL;
}
if (emulate == 0) {
! if ((self->afmts & audio_types[n].a_fmt) == 0) {
! PyErr_Format(PyExc_ValueError,
! "%s format not supported by device",
! audio_types[n].a_name);
! return NULL;
! }
}
if (ioctl(self->fd, SNDCTL_DSP_SETFMT,
! &audio_types[n].a_fmt) == -1) {
PyErr_SetFromErrno(PyExc_IOError);
return NULL;
***************
*** 634,643 ****
if (!PyArg_ParseTuple(args, ":getptr"))
! return NULL;
if (self->mode == O_RDONLY)
! req = SNDCTL_DSP_GETIPTR;
else
! req = SNDCTL_DSP_GETOPTR;
if (ioctl(self->fd, req, &info) == -1) {
PyErr_SetFromErrno(PyExc_IOError);
--- 634,643 ----
if (!PyArg_ParseTuple(args, ":getptr"))
! return NULL;
if (self->mode == O_RDONLY)
! req = SNDCTL_DSP_GETIPTR;
else
! req = SNDCTL_DSP_GETOPTR;
if (ioctl(self->fd, req, &info) == -1) {
PyErr_SetFromErrno(PyExc_IOError);
***************
*** 652,656 ****
{
if (!PyArg_ParseTuple(args, ":close"))
! return NULL;
if (self->fd >= 0) {
--- 652,656 ----
{
if (!PyArg_ParseTuple(args, ":close"))
! return NULL;
if (self->fd >= 0) {
***************
*** 666,670 ****
{
if (!PyArg_ParseTuple(args, ":fileno"))
! return NULL;
return PyInt_FromLong(self->fd);
}
--- 666,670 ----
{
if (!PyArg_ParseTuple(args, ":fileno"))
! return NULL;
return PyInt_FromLong(self->fd);
}
***************
*** 700,712 ****
/* Can't use _do_ioctl_1 because of encoded arg thingy. */
if (!PyArg_ParseTuple(args, "i:get", &channel))
! return NULL;
if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) {
! PyErr_SetString(OSSAudioError, "Invalid mixer channel specified.");
! return NULL;
}
if (ioctl(self->fd, MIXER_READ(channel), &volume) == -1)
! return PyErr_SetFromErrno(PyExc_IOError);
return Py_BuildValue("(ii)", volume & 0xff, (volume & 0xff00) >> 8);
--- 700,712 ----
/* Can't use _do_ioctl_1 because of encoded arg thingy. */
if (!PyArg_ParseTuple(args, "i:get", &channel))
! return NULL;
if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) {
! PyErr_SetString(OSSAudioError, "Invalid mixer channel specified.");
! return NULL;
}
if (ioctl(self->fd, MIXER_READ(channel), &volume) == -1)
! return PyErr_SetFromErrno(PyExc_IOError);
return Py_BuildValue("(ii)", volume & 0xff, (volume & 0xff00) >> 8);
***************
*** 720,733 ****
/* Can't use _do_ioctl_1 because of encoded arg thingy. */
if (!PyArg_ParseTuple(args, "i(ii):set", &channel, &leftVol, &rightVol))
! return NULL;
!
if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) {
! PyErr_SetString(OSSAudioError, "Invalid mixer channel specified.");
! return NULL;
}
if (leftVol < 0 || rightVol < 0 || leftVol > 100 || rightVol > 100) {
! PyErr_SetString(OSSAudioError, "Volumes must be between 0 and 100.");
! return NULL;
}
--- 720,733 ----
/* Can't use _do_ioctl_1 because of encoded arg thingy. */
if (!PyArg_ParseTuple(args, "i(ii):set", &channel, &leftVol, &rightVol))
! return NULL;
!
if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) {
! PyErr_SetString(OSSAudioError, "Invalid mixer channel specified.");
! return NULL;
}
if (leftVol < 0 || rightVol < 0 || leftVol > 100 || rightVol > 100) {
! PyErr_SetString(OSSAudioError, "Volumes must be between 0 and 100.");
! return NULL;
}
***************
*** 735,739 ****
if (ioctl(self->fd, MIXER_WRITE(channel), &volume) == -1)
! return PyErr_SetFromErrno(PyExc_IOError);
return Py_BuildValue("(ii)", volume & 0xff, (volume & 0xff00) >> 8);
--- 735,739 ----
if (ioctl(self->fd, MIXER_WRITE(channel), &volume) == -1)
! return PyErr_SetFromErrno(PyExc_IOError);
return Py_BuildValue("(ii)", volume & 0xff, (volume & 0xff00) >> 8);
***************
*** 757,804 ****
static PyMethodDef oss_methods[] = {
/* Regular file methods */
! { "read", (PyCFunction)oss_read, METH_VARARGS },
! { "write", (PyCFunction)oss_write, METH_VARARGS },
! { "writeall", (PyCFunction)oss_writeall, METH_VARARGS },
! { "close", (PyCFunction)oss_close, METH_VARARGS },
! { "fileno", (PyCFunction)oss_fileno, METH_VARARGS },
/* Simple ioctl wrappers */
{ "nonblock", (PyCFunction)oss_nonblock, METH_VARARGS },
! { "setfmt", (PyCFunction)oss_setfmt, METH_VARARGS },
{ "getfmts", (PyCFunction)oss_getfmts, METH_VARARGS },
{ "channels", (PyCFunction)oss_channels, METH_VARARGS },
{ "speed", (PyCFunction)oss_speed, METH_VARARGS },
! { "sync", (PyCFunction)oss_sync, METH_VARARGS },
! { "reset", (PyCFunction)oss_reset, METH_VARARGS },
! { "post", (PyCFunction)oss_post, METH_VARARGS },
/* Convenience methods -- wrap a couple of ioctls together */
! { "setparameters", (PyCFunction)oss_setparameters, METH_VARARGS },
! { "bufsize", (PyCFunction)oss_bufsize, METH_VARARGS },
! { "obufcount", (PyCFunction)oss_obufcount, METH_VARARGS },
! { "obuffree", (PyCFunction)oss_obuffree, METH_VARARGS },
{ "getptr", (PyCFunction)oss_getptr, METH_VARARGS },
/* Aliases for backwards compatibility */
! { "flush", (PyCFunction)oss_sync, METH_VARARGS },
! { NULL, NULL} /* sentinel */
};
static PyMethodDef oss_mixer_methods[] = {
/* Regular file method - OSS mixers are ioctl-only interface */
! { "close", (PyCFunction)oss_mixer_close, METH_VARARGS },
! { "fileno", (PyCFunction)oss_mixer_fileno, METH_VARARGS },
/* Simple ioctl wrappers */
! { "devices", (PyCFunction)oss_mixer_devices, METH_VARARGS },
{ "stereodevices", (PyCFunction)oss_mixer_stereodevices, METH_VARARGS},
{ "recdevices", (PyCFunction)oss_mixer_recdevices, METH_VARARGS},
! { "get", (PyCFunction)oss_mixer_get, METH_VARARGS },
! { "set", (PyCFunction)oss_mixer_set, METH_VARARGS },
! { "getrecsrc", (PyCFunction)oss_mixer_getrecsrc, METH_VARARGS },
! { "setrecsrc", (PyCFunction)oss_mixer_setrecsrc, METH_VARARGS },
! { NULL, NULL}
};
--- 757,804 ----
static PyMethodDef oss_methods[] = {
/* Regular file methods */
! { "read", (PyCFunction)oss_read, METH_VARARGS },
! { "write", (PyCFunction)oss_write, METH_VARARGS },
! { "writeall", (PyCFunction)oss_writeall, METH_VARARGS },
! { "close", (PyCFunction)oss_close, METH_VARARGS },
! { "fileno", (PyCFunction)oss_fileno, METH_VARARGS },
/* Simple ioctl wrappers */
{ "nonblock", (PyCFunction)oss_nonblock, METH_VARARGS },
! { "setfmt", (PyCFunction)oss_setfmt, METH_VARARGS },
{ "getfmts", (PyCFunction)oss_getfmts, METH_VARARGS },
{ "channels", (PyCFunction)oss_channels, METH_VARARGS },
{ "speed", (PyCFunction)oss_speed, METH_VARARGS },
! { "sync", (PyCFunction)oss_sync, METH_VARARGS },
! { "reset", (PyCFunction)oss_reset, METH_VARARGS },
! { "post", (PyCFunction)oss_post, METH_VARARGS },
/* Convenience methods -- wrap a couple of ioctls together */
! { "setparameters", (PyCFunction)oss_setparameters, METH_VARARGS },
! { "bufsize", (PyCFunction)oss_bufsize, METH_VARARGS },
! { "obufcount", (PyCFunction)oss_obufcount, METH_VARARGS },
! { "obuffree", (PyCFunction)oss_obuffree, METH_VARARGS },
{ "getptr", (PyCFunction)oss_getptr, METH_VARARGS },
/* Aliases for backwards compatibility */
! { "flush", (PyCFunction)oss_sync, METH_VARARGS },
! { NULL, NULL} /* sentinel */
};
static PyMethodDef oss_mixer_methods[] = {
/* Regular file method - OSS mixers are ioctl-only interface */
! { "close", (PyCFunction)oss_mixer_close, METH_VARARGS },
! { "fileno", (PyCFunction)oss_mixer_fileno, METH_VARARGS },
/* Simple ioctl wrappers */
! { "devices", (PyCFunction)oss_mixer_devices, METH_VARARGS },
{ "stereodevices", (PyCFunction)oss_mixer_stereodevices, METH_VARARGS},
{ "recdevices", (PyCFunction)oss_mixer_recdevices, METH_VARARGS},
! { "get", (PyCFunction)oss_mixer_get, METH_VARARGS },
! { "set", (PyCFunction)oss_mixer_set, METH_VARARGS },
! { "getrecsrc", (PyCFunction)oss_mixer_getrecsrc, METH_VARARGS },
! { "setrecsrc", (PyCFunction)oss_mixer_setrecsrc, METH_VARARGS },
! { NULL, NULL}
};
***************
*** 817,846 ****
static PyTypeObject OSSType = {
PyObject_HEAD_INIT(&PyType_Type)
! 0, /*ob_size*/
"ossaudiodev.oss_audio_device", /*tp_name*/
! sizeof(oss_t), /*tp_size*/
! 0, /*tp_itemsize*/
/* methods */
! (destructor)oss_dealloc, /*tp_dealloc*/
! 0, /*tp_print*/
! (getattrfunc)oss_getattr, /*tp_getattr*/
! 0, /*tp_setattr*/
! 0, /*tp_compare*/
! 0, /*tp_repr*/
};
static PyTypeObject OSSMixerType = {
PyObject_HEAD_INIT(&PyType_Type)
! 0, /*ob_size*/
"ossaudiodev.oss_mixer_device", /*tp_name*/
! sizeof(oss_mixer_t), /*tp_size*/
! 0, /*tp_itemsize*/
/* methods */
(destructor)oss_mixer_dealloc, /*tp_dealloc*/
! 0, /*tp_print*/
(getattrfunc)oss_mixer_getattr, /*tp_getattr*/
! 0, /*tp_setattr*/
! 0, /*tp_compare*/
! 0, /*tp_repr*/
};
--- 817,846 ----
static PyTypeObject OSSType = {
PyObject_HEAD_INIT(&PyType_Type)
! 0, /*ob_size*/
"ossaudiodev.oss_audio_device", /*tp_name*/
! sizeof(oss_t), /*tp_size*/
! 0, /*tp_itemsize*/
/* methods */
! (destructor)oss_dealloc, /*tp_dealloc*/
! 0, /*tp_print*/
! (getattrfunc)oss_getattr, /*tp_getattr*/
! 0, /*tp_setattr*/
! 0, /*tp_compare*/
! 0, /*tp_repr*/
};
static PyTypeObject OSSMixerType = {
PyObject_HEAD_INIT(&PyType_Type)
! 0, /*ob_size*/
"ossaudiodev.oss_mixer_device", /*tp_name*/
! sizeof(oss_mixer_t), /*tp_size*/
! 0, /*tp_itemsize*/
/* methods */
(destructor)oss_mixer_dealloc, /*tp_dealloc*/
! 0, /*tp_print*/
(getattrfunc)oss_mixer_getattr, /*tp_getattr*/
! 0, /*tp_setattr*/
! 0, /*tp_compare*/
! 0, /*tp_repr*/
};
***************
*** 877,881 ****
OSSAudioError = PyErr_NewException("ossaudiodev.error", NULL, NULL);
if (OSSAudioError)
! PyModule_AddObject(m, "error", OSSAudioError);
/* Expose the audio format numbers -- essential! */
--- 877,881 ----
OSSAudioError = PyErr_NewException("ossaudiodev.error", NULL, NULL);
if (OSSAudioError)
! PyModule_AddObject(m, "error", OSSAudioError);
/* Expose the audio format numbers -- essential! */
***************
*** 893,897 ****
_EXPORT_INT(m, AFMT_AC3);
_EXPORT_INT(m, AFMT_S16_NE);
!
/* Expose the sound mixer device numbers. */
_EXPORT_INT(m, SOUND_MIXER_NRDEVICES);
--- 893,897 ----
_EXPORT_INT(m, AFMT_AC3);
_EXPORT_INT(m, AFMT_S16_NE);
!
/* Expose the sound mixer device numbers. */
_EXPORT_INT(m, SOUND_MIXER_NRDEVICES);