mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +00:00
Whitespace normalization; break a long line.
This commit is contained in:
parent
f39dafb10a
commit
0741f801ba
1 changed files with 40 additions and 39 deletions
|
@ -9,7 +9,7 @@
|
||||||
* Renamed to ossaudiodev and rearranged/revised/hacked up
|
* Renamed to ossaudiodev and rearranged/revised/hacked up
|
||||||
* by Greg Ward <gward@python.net>, November 2002.
|
* by Greg Ward <gward@python.net>, November 2002.
|
||||||
* Mixer interface by Nicholas FitzRoy-Dale <wzdd@lardcave.net>, Dec 2002.
|
* Mixer interface by Nicholas FitzRoy-Dale <wzdd@lardcave.net>, Dec 2002.
|
||||||
*
|
*
|
||||||
* (c) 2000 Peter Bosch. All Rights Reserved.
|
* (c) 2000 Peter Bosch. All Rights Reserved.
|
||||||
* (c) 2002 Gregory P. Ward. All Rights Reserved.
|
* (c) 2002 Gregory P. Ward. All Rights Reserved.
|
||||||
* (c) 2002 Python Software Foundation. All Rights Reserved.
|
* (c) 2002 Python Software Foundation. All Rights Reserved.
|
||||||
|
@ -161,11 +161,11 @@ newossmixerobject(PyObject *arg)
|
||||||
char *basedev = NULL;
|
char *basedev = NULL;
|
||||||
int fd;
|
int fd;
|
||||||
oss_mixer_t *self;
|
oss_mixer_t *self;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(arg, "|s", &basedev)) {
|
if (!PyArg_ParseTuple(arg, "|s", &basedev)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (basedev == NULL) {
|
if (basedev == NULL) {
|
||||||
basedev = getenv("MIXERDEV");
|
basedev = getenv("MIXERDEV");
|
||||||
if (basedev == NULL) /* MIXERDEV not set */
|
if (basedev == NULL) /* MIXERDEV not set */
|
||||||
|
@ -181,9 +181,9 @@ newossmixerobject(PyObject *arg)
|
||||||
close(fd);
|
close(fd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->fd = fd;
|
self->fd = fd;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,13 +340,13 @@ oss_sync(oss_audio_t *self, PyObject *args)
|
||||||
{
|
{
|
||||||
return _do_ioctl_0(self->fd, args, "sync", SNDCTL_DSP_SYNC);
|
return _do_ioctl_0(self->fd, args, "sync", SNDCTL_DSP_SYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
oss_reset(oss_audio_t *self, PyObject *args)
|
oss_reset(oss_audio_t *self, PyObject *args)
|
||||||
{
|
{
|
||||||
return _do_ioctl_0(self->fd, args, "reset", SNDCTL_DSP_RESET);
|
return _do_ioctl_0(self->fd, args, "reset", SNDCTL_DSP_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
oss_post(oss_audio_t *self, PyObject *args)
|
oss_post(oss_audio_t *self, PyObject *args)
|
||||||
{
|
{
|
||||||
|
@ -363,7 +363,7 @@ oss_read(oss_audio_t *self, PyObject *args)
|
||||||
int size, count;
|
int size, count;
|
||||||
char *cp;
|
char *cp;
|
||||||
PyObject *rv;
|
PyObject *rv;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "i:read", &size))
|
if (!PyArg_ParseTuple(args, "i:read", &size))
|
||||||
return NULL;
|
return NULL;
|
||||||
rv = PyString_FromStringAndSize(NULL, size);
|
rv = PyString_FromStringAndSize(NULL, size);
|
||||||
|
@ -414,7 +414,7 @@ oss_writeall(oss_audio_t *self, PyObject *args)
|
||||||
int rv, size;
|
int rv, size;
|
||||||
fd_set write_set_fds;
|
fd_set write_set_fds;
|
||||||
int select_rv;
|
int select_rv;
|
||||||
|
|
||||||
/* NB. writeall() is only useful in non-blocking mode: according to
|
/* NB. writeall() is only useful in non-blocking mode: according to
|
||||||
Guenter Geiger <geiger@xdv.org> on the linux-audio-dev list
|
Guenter Geiger <geiger@xdv.org> on the linux-audio-dev list
|
||||||
(http://eca.cx/lad/2002/11/0380.html), OSS guarantees that
|
(http://eca.cx/lad/2002/11/0380.html), OSS guarantees that
|
||||||
|
@ -422,7 +422,7 @@ oss_writeall(oss_audio_t *self, PyObject *args)
|
||||||
mode, the behaviour of write() and writeall() from Python is
|
mode, the behaviour of write() and writeall() from Python is
|
||||||
indistinguishable. */
|
indistinguishable. */
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "s#:write", &cp, &size))
|
if (!PyArg_ParseTuple(args, "s#:write", &cp, &size))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* use select to wait for audio device to be available */
|
/* use select to wait for audio device to be available */
|
||||||
|
@ -475,7 +475,7 @@ oss_close(oss_audio_t *self, PyObject *args)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
oss_fileno(oss_audio_t *self, PyObject *args)
|
oss_fileno(oss_audio_t *self, PyObject *args)
|
||||||
{
|
{
|
||||||
if (!PyArg_ParseTuple(args, ":fileno"))
|
if (!PyArg_ParseTuple(args, ":fileno"))
|
||||||
return NULL;
|
return NULL;
|
||||||
return PyInt_FromLong(self->fd);
|
return PyInt_FromLong(self->fd);
|
||||||
}
|
}
|
||||||
|
@ -528,7 +528,7 @@ oss_setparameters(oss_audio_t *self, PyObject *args)
|
||||||
"unable to set requested rate (wanted %d, got %d)",
|
"unable to set requested rate (wanted %d, got %d)",
|
||||||
wanted_rate, rate);
|
wanted_rate, rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Construct the return value: a (fmt, channels, rate) tuple that
|
/* Construct the return value: a (fmt, channels, rate) tuple that
|
||||||
tells what the audio hardware was actually set to. */
|
tells what the audio hardware was actually set to. */
|
||||||
rv = PyTuple_New(3);
|
rv = PyTuple_New(3);
|
||||||
|
@ -546,7 +546,7 @@ _ssize(oss_audio_t *self, int *nchannels, int *ssize)
|
||||||
int fmt;
|
int fmt;
|
||||||
|
|
||||||
fmt = 0;
|
fmt = 0;
|
||||||
if (ioctl(self->fd, SNDCTL_DSP_SETFMT, &fmt) < 0)
|
if (ioctl(self->fd, SNDCTL_DSP_SETFMT, &fmt) < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
switch (fmt) {
|
switch (fmt) {
|
||||||
|
@ -574,7 +574,7 @@ _ssize(oss_audio_t *self, int *nchannels, int *ssize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* bufsize returns the size of the hardware audio buffer in number
|
/* bufsize returns the size of the hardware audio buffer in number
|
||||||
of samples */
|
of samples */
|
||||||
static PyObject *
|
static PyObject *
|
||||||
oss_bufsize(oss_audio_t *self, PyObject *args)
|
oss_bufsize(oss_audio_t *self, PyObject *args)
|
||||||
|
@ -595,7 +595,7 @@ oss_bufsize(oss_audio_t *self, PyObject *args)
|
||||||
return PyInt_FromLong((ai.fragstotal * ai.fragsize) / (nchannels * ssize));
|
return PyInt_FromLong((ai.fragstotal * ai.fragsize) / (nchannels * ssize));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* obufcount returns the number of samples that are available in the
|
/* obufcount returns the number of samples that are available in the
|
||||||
hardware for playing */
|
hardware for playing */
|
||||||
static PyObject *
|
static PyObject *
|
||||||
oss_obufcount(oss_audio_t *self, PyObject *args)
|
oss_obufcount(oss_audio_t *self, PyObject *args)
|
||||||
|
@ -614,7 +614,7 @@ oss_obufcount(oss_audio_t *self, PyObject *args)
|
||||||
PyErr_SetFromErrno(PyExc_IOError);
|
PyErr_SetFromErrno(PyExc_IOError);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return PyInt_FromLong((ai.fragstotal * ai.fragsize - ai.bytes) /
|
return PyInt_FromLong((ai.fragstotal * ai.fragsize - ai.bytes) /
|
||||||
(ssize * nchannels));
|
(ssize * nchannels));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,7 +648,7 @@ oss_getptr(oss_audio_t *self, PyObject *args)
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, ":getptr"))
|
if (!PyArg_ParseTuple(args, ":getptr"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (self->mode == O_RDONLY)
|
if (self->mode == O_RDONLY)
|
||||||
req = SNDCTL_DSP_GETIPTR;
|
req = SNDCTL_DSP_GETIPTR;
|
||||||
else
|
else
|
||||||
|
@ -682,7 +682,7 @@ oss_mixer_close(oss_mixer_t *self, PyObject *args)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
oss_mixer_fileno(oss_mixer_t *self, PyObject *args)
|
oss_mixer_fileno(oss_mixer_t *self, PyObject *args)
|
||||||
{
|
{
|
||||||
if (!PyArg_ParseTuple(args, ":fileno"))
|
if (!PyArg_ParseTuple(args, ":fileno"))
|
||||||
return NULL;
|
return NULL;
|
||||||
return PyInt_FromLong(self->fd);
|
return PyInt_FromLong(self->fd);
|
||||||
}
|
}
|
||||||
|
@ -714,19 +714,19 @@ static PyObject *
|
||||||
oss_mixer_get(oss_mixer_t *self, PyObject *args)
|
oss_mixer_get(oss_mixer_t *self, PyObject *args)
|
||||||
{
|
{
|
||||||
int channel, volume;
|
int channel, volume;
|
||||||
|
|
||||||
/* Can't use _do_ioctl_1 because of encoded arg thingy. */
|
/* Can't use _do_ioctl_1 because of encoded arg thingy. */
|
||||||
if (!PyArg_ParseTuple(args, "i:get", &channel))
|
if (!PyArg_ParseTuple(args, "i:get", &channel))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) {
|
if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) {
|
||||||
PyErr_SetString(OSSAudioError, "Invalid mixer channel specified.");
|
PyErr_SetString(OSSAudioError, "Invalid mixer channel specified.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(self->fd, MIXER_READ(channel), &volume) == -1)
|
if (ioctl(self->fd, MIXER_READ(channel), &volume) == -1)
|
||||||
return PyErr_SetFromErrno(PyExc_IOError);
|
return PyErr_SetFromErrno(PyExc_IOError);
|
||||||
|
|
||||||
return Py_BuildValue("(ii)", volume & 0xff, (volume & 0xff00) >> 8);
|
return Py_BuildValue("(ii)", volume & 0xff, (volume & 0xff00) >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,26 +734,26 @@ static PyObject *
|
||||||
oss_mixer_set(oss_mixer_t *self, PyObject *args)
|
oss_mixer_set(oss_mixer_t *self, PyObject *args)
|
||||||
{
|
{
|
||||||
int channel, volume, leftVol, rightVol;
|
int channel, volume, leftVol, rightVol;
|
||||||
|
|
||||||
/* Can't use _do_ioctl_1 because of encoded arg thingy. */
|
/* Can't use _do_ioctl_1 because of encoded arg thingy. */
|
||||||
if (!PyArg_ParseTuple(args, "i(ii):set", &channel, &leftVol, &rightVol))
|
if (!PyArg_ParseTuple(args, "i(ii):set", &channel, &leftVol, &rightVol))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) {
|
if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) {
|
||||||
PyErr_SetString(OSSAudioError, "Invalid mixer channel specified.");
|
PyErr_SetString(OSSAudioError, "Invalid mixer channel specified.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leftVol < 0 || rightVol < 0 || leftVol > 100 || rightVol > 100) {
|
if (leftVol < 0 || rightVol < 0 || leftVol > 100 || rightVol > 100) {
|
||||||
PyErr_SetString(OSSAudioError, "Volumes must be between 0 and 100.");
|
PyErr_SetString(OSSAudioError, "Volumes must be between 0 and 100.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
volume = (rightVol << 8) | leftVol;
|
volume = (rightVol << 8) | leftVol;
|
||||||
|
|
||||||
if (ioctl(self->fd, MIXER_WRITE(channel), &volume) == -1)
|
if (ioctl(self->fd, MIXER_WRITE(channel), &volume) == -1)
|
||||||
return PyErr_SetFromErrno(PyExc_IOError);
|
return PyErr_SetFromErrno(PyExc_IOError);
|
||||||
|
|
||||||
return Py_BuildValue("(ii)", volume & 0xff, (volume & 0xff00) >> 8);
|
return Py_BuildValue("(ii)", volume & 0xff, (volume & 0xff00) >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -809,18 +809,18 @@ static PyMethodDef oss_methods[] = {
|
||||||
|
|
||||||
static PyMethodDef oss_mixer_methods[] = {
|
static PyMethodDef oss_mixer_methods[] = {
|
||||||
/* Regular file method - OSS mixers are ioctl-only interface */
|
/* Regular file method - OSS mixers are ioctl-only interface */
|
||||||
{ "close", (PyCFunction)oss_mixer_close, METH_VARARGS },
|
{ "close", (PyCFunction)oss_mixer_close, METH_VARARGS },
|
||||||
{ "fileno", (PyCFunction)oss_mixer_fileno, METH_VARARGS },
|
{ "fileno", (PyCFunction)oss_mixer_fileno, METH_VARARGS },
|
||||||
|
|
||||||
/* Simple ioctl wrappers */
|
/* Simple ioctl wrappers */
|
||||||
{ "controls", (PyCFunction)oss_mixer_controls, METH_VARARGS },
|
{ "controls", (PyCFunction)oss_mixer_controls, METH_VARARGS },
|
||||||
{ "stereocontrols", (PyCFunction)oss_mixer_stereocontrols, METH_VARARGS},
|
{ "stereocontrols", (PyCFunction)oss_mixer_stereocontrols, METH_VARARGS},
|
||||||
{ "reccontrols", (PyCFunction)oss_mixer_reccontrols, METH_VARARGS},
|
{ "reccontrols", (PyCFunction)oss_mixer_reccontrols, METH_VARARGS},
|
||||||
{ "get", (PyCFunction)oss_mixer_get, METH_VARARGS },
|
{ "get", (PyCFunction)oss_mixer_get, METH_VARARGS },
|
||||||
{ "set", (PyCFunction)oss_mixer_set, METH_VARARGS },
|
{ "set", (PyCFunction)oss_mixer_set, METH_VARARGS },
|
||||||
{ "get_recsrc", (PyCFunction)oss_mixer_get_recsrc, METH_VARARGS },
|
{ "get_recsrc", (PyCFunction)oss_mixer_get_recsrc, METH_VARARGS },
|
||||||
{ "set_recsrc", (PyCFunction)oss_mixer_set_recsrc, METH_VARARGS },
|
{ "set_recsrc", (PyCFunction)oss_mixer_set_recsrc, METH_VARARGS },
|
||||||
|
|
||||||
{ NULL, NULL}
|
{ NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -913,7 +913,7 @@ build_namelists (PyObject *module)
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
PyList_SET_ITEM(labels, i, s);
|
PyList_SET_ITEM(labels, i, s);
|
||||||
|
|
||||||
s = PyString_FromString(control_names[i]);
|
s = PyString_FromString(control_names[i]);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -926,21 +926,22 @@ build_namelists (PyObject *module)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
initossaudiodev(void)
|
initossaudiodev(void)
|
||||||
{
|
{
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
|
|
||||||
m = Py_InitModule("ossaudiodev", ossaudiodev_methods);
|
m = Py_InitModule("ossaudiodev", ossaudiodev_methods);
|
||||||
|
|
||||||
OSSAudioError = PyErr_NewException("ossaudiodev.OSSAudioError", NULL, NULL);
|
OSSAudioError = PyErr_NewException("ossaudiodev.OSSAudioError",
|
||||||
|
NULL, NULL);
|
||||||
if (OSSAudioError) {
|
if (OSSAudioError) {
|
||||||
/* Each call to PyModule_AddObject decrefs it; compensate: */
|
/* Each call to PyModule_AddObject decrefs it; compensate: */
|
||||||
Py_INCREF(OSSAudioError);
|
Py_INCREF(OSSAudioError);
|
||||||
Py_INCREF(OSSAudioError);
|
Py_INCREF(OSSAudioError);
|
||||||
PyModule_AddObject(m, "error", OSSAudioError);
|
PyModule_AddObject(m, "error", OSSAudioError);
|
||||||
PyModule_AddObject(m, "OSSAudioError", OSSAudioError);
|
PyModule_AddObject(m, "OSSAudioError", OSSAudioError);
|
||||||
}
|
}
|
||||||
|
@ -968,7 +969,7 @@ initossaudiodev(void)
|
||||||
#ifdef AFMT_S16_NE
|
#ifdef AFMT_S16_NE
|
||||||
_EXPORT_INT(m, AFMT_S16_NE);
|
_EXPORT_INT(m, AFMT_S16_NE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Expose the sound mixer device numbers. */
|
/* Expose the sound mixer device numbers. */
|
||||||
_EXPORT_INT(m, SOUND_MIXER_NRDEVICES);
|
_EXPORT_INT(m, SOUND_MIXER_NRDEVICES);
|
||||||
_EXPORT_INT(m, SOUND_MIXER_VOLUME);
|
_EXPORT_INT(m, SOUND_MIXER_VOLUME);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue