2002-11-30 18:47:45 -04:00
|
|
|
/*
|
|
|
|
* ossaudiodev -- Python interface to the OSS (Open Sound System) API.
|
|
|
|
* This is the standard audio API for Linux and some
|
|
|
|
* flavours of BSD [XXX which ones?]; it is also available
|
|
|
|
* for a wide range of commercial Unices.
|
|
|
|
*
|
|
|
|
* Originally written by Peter Bosch, March 2000, as linuxaudiodev.
|
|
|
|
*
|
|
|
|
* Renamed to ossaudiodev and rearranged/revised/hacked up
|
|
|
|
* by Greg Ward <gward@python.net>, November 2002.
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
* Mixer interface by Nicholas FitzRoy-Dale <wzdd@lardcave.net>, Dec 2002.
|
2003-06-02 11:15:34 -03:00
|
|
|
*
|
2002-11-30 18:47:45 -04:00
|
|
|
* (c) 2000 Peter Bosch. All Rights Reserved.
|
|
|
|
* (c) 2002 Gregory P. Ward. All Rights Reserved.
|
|
|
|
* (c) 2002 Python Software Foundation. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* XXX need a license statement
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Python.h"
|
|
|
|
#include "structmember.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_FCNTL_H
|
|
|
|
#include <fcntl.h>
|
|
|
|
#else
|
|
|
|
#define O_RDONLY 00
|
|
|
|
#define O_WRONLY 01
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/ioctl.h>
|
2003-03-09 23:17:06 -04:00
|
|
|
#include <sys/soundcard.h>
|
|
|
|
|
2002-11-30 18:47:45 -04:00
|
|
|
#if defined(linux)
|
|
|
|
|
2006-10-04 07:23:57 -03:00
|
|
|
#ifndef HAVE_STDINT_H
|
2002-11-30 18:47:45 -04:00
|
|
|
typedef unsigned long uint32_t;
|
2006-10-04 07:23:57 -03:00
|
|
|
#endif
|
2002-11-30 18:47:45 -04:00
|
|
|
|
|
|
|
#elif defined(__FreeBSD__)
|
|
|
|
|
2003-03-09 23:17:06 -04:00
|
|
|
# ifndef SNDCTL_DSP_CHANNELS
|
|
|
|
# define SNDCTL_DSP_CHANNELS SOUND_PCM_WRITE_CHANNELS
|
|
|
|
# endif
|
2002-11-30 18:47:45 -04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct {
|
2006-01-07 17:19:49 -04:00
|
|
|
PyObject_HEAD
|
2005-03-06 21:41:11 -04:00
|
|
|
char *devicename; /* name of the device file */
|
|
|
|
int fd; /* file descriptor */
|
|
|
|
int mode; /* file mode (O_RDONLY, etc.) */
|
|
|
|
int icount; /* input count */
|
|
|
|
int ocount; /* output count */
|
|
|
|
uint32_t afmts; /* audio formats supported by hardware */
|
2002-12-30 23:04:52 -04:00
|
|
|
} oss_audio_t;
|
2002-11-30 18:47:45 -04:00
|
|
|
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
typedef struct {
|
2006-01-07 17:19:49 -04:00
|
|
|
PyObject_HEAD
|
2002-12-29 23:02:22 -04:00
|
|
|
int fd; /* The open mixer device */
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
} oss_mixer_t;
|
|
|
|
|
2002-11-30 18:47:45 -04:00
|
|
|
|
2002-12-30 23:04:52 -04:00
|
|
|
static PyTypeObject OSSAudioType;
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
static PyTypeObject OSSMixerType;
|
2002-11-30 18:47:45 -04:00
|
|
|
|
2002-11-30 19:17:10 -04:00
|
|
|
static PyObject *OSSAudioError;
|
2002-11-30 18:47:45 -04:00
|
|
|
|
2002-12-30 23:02:23 -04:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
* DSP object initialization/deallocation
|
|
|
|
*/
|
|
|
|
|
2002-12-30 23:04:52 -04:00
|
|
|
static oss_audio_t *
|
2002-12-11 10:43:13 -04:00
|
|
|
newossobject(PyObject *arg)
|
2002-11-30 18:47:45 -04:00
|
|
|
{
|
2002-12-30 23:07:21 -04:00
|
|
|
oss_audio_t *self;
|
2002-11-30 18:47:45 -04:00
|
|
|
int fd, afmts, imode;
|
2005-03-06 21:41:11 -04:00
|
|
|
char *devicename = NULL;
|
2002-11-30 18:47:45 -04:00
|
|
|
char *mode = NULL;
|
|
|
|
|
2002-11-30 19:20:09 -04:00
|
|
|
/* Two ways to call open():
|
2002-11-30 18:47:45 -04:00
|
|
|
open(device, mode) (for consistency with builtin open())
|
|
|
|
open(mode) (for backwards compatibility)
|
|
|
|
because the *first* argument is optional, parsing args is
|
|
|
|
a wee bit tricky. */
|
2005-03-06 21:41:11 -04:00
|
|
|
if (!PyArg_ParseTuple(arg, "s|s:open", &devicename, &mode))
|
2002-11-30 18:47:45 -04:00
|
|
|
return NULL;
|
|
|
|
if (mode == NULL) { /* only one arg supplied */
|
2005-03-06 21:41:11 -04:00
|
|
|
mode = devicename;
|
|
|
|
devicename = NULL;
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(mode, "r") == 0)
|
|
|
|
imode = O_RDONLY;
|
|
|
|
else if (strcmp(mode, "w") == 0)
|
|
|
|
imode = O_WRONLY;
|
2002-11-30 19:05:26 -04:00
|
|
|
else if (strcmp(mode, "rw") == 0)
|
|
|
|
imode = O_RDWR;
|
2002-11-30 18:47:45 -04:00
|
|
|
else {
|
2002-11-30 19:17:10 -04:00
|
|
|
PyErr_SetString(OSSAudioError, "mode must be 'r', 'w', or 'rw'");
|
2002-11-30 18:47:45 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2002-12-29 22:58:04 -04:00
|
|
|
/* Open the correct device: either the 'device' argument,
|
|
|
|
or the AUDIODEV environment variable, or "/dev/dsp". */
|
2005-03-06 21:41:11 -04:00
|
|
|
if (devicename == NULL) { /* called with one arg */
|
|
|
|
devicename = getenv("AUDIODEV");
|
|
|
|
if (devicename == NULL) /* $AUDIODEV not set */
|
|
|
|
devicename = "/dev/dsp";
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
|
|
|
|
2003-03-11 12:53:13 -04:00
|
|
|
/* Open with O_NONBLOCK to avoid hanging on devices that only allow
|
|
|
|
one open at a time. This does *not* affect later I/O; OSS
|
|
|
|
provides a special ioctl() for non-blocking read/write, which is
|
|
|
|
exposed via oss_nonblock() below. */
|
2005-03-06 21:41:11 -04:00
|
|
|
if ((fd = open(devicename, imode|O_NONBLOCK)) == -1) {
|
|
|
|
PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename);
|
2002-11-30 18:47:45 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-04-03 21:47:42 -04:00
|
|
|
|
|
|
|
/* And (try to) put it back in blocking mode so we get the
|
|
|
|
expected write() semantics. */
|
|
|
|
if (fcntl(fd, F_SETFL, 0) == -1) {
|
|
|
|
close(fd);
|
2005-03-06 21:41:11 -04:00
|
|
|
PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename);
|
2003-04-03 21:47:42 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2002-11-30 18:47:45 -04:00
|
|
|
if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) {
|
2011-09-29 14:43:01 -03:00
|
|
|
close(fd);
|
2005-03-06 21:41:11 -04:00
|
|
|
PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename);
|
2002-11-30 18:47:45 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/* Create and initialize the object */
|
2002-12-30 23:07:21 -04:00
|
|
|
if ((self = PyObject_New(oss_audio_t, &OSSAudioType)) == NULL) {
|
2002-11-30 18:47:45 -04:00
|
|
|
close(fd);
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-03-06 21:41:11 -04:00
|
|
|
self->devicename = devicename;
|
2002-12-30 23:07:21 -04:00
|
|
|
self->fd = fd;
|
|
|
|
self->mode = imode;
|
|
|
|
self->icount = self->ocount = 0;
|
|
|
|
self->afmts = afmts;
|
|
|
|
return self;
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-12-30 23:07:21 -04:00
|
|
|
oss_dealloc(oss_audio_t *self)
|
2002-11-30 18:47:45 -04:00
|
|
|
{
|
|
|
|
/* if already closed, don't reclose it */
|
2002-12-30 23:07:21 -04:00
|
|
|
if (self->fd != -1)
|
|
|
|
close(self->fd);
|
|
|
|
PyObject_Del(self);
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
|
|
|
|
2002-12-30 23:02:23 -04:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
* Mixer object initialization/deallocation
|
|
|
|
*/
|
|
|
|
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
static oss_mixer_t *
|
|
|
|
newossmixerobject(PyObject *arg)
|
|
|
|
{
|
2005-03-06 21:41:11 -04:00
|
|
|
char *devicename = NULL;
|
2003-03-09 23:17:06 -04:00
|
|
|
int fd;
|
2002-12-30 23:07:21 -04:00
|
|
|
oss_mixer_t *self;
|
2003-06-02 11:15:34 -03:00
|
|
|
|
2005-03-06 21:41:11 -04:00
|
|
|
if (!PyArg_ParseTuple(arg, "|s", &devicename)) {
|
2002-12-29 23:02:22 -04:00
|
|
|
return NULL;
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
}
|
2003-06-02 11:15:34 -03:00
|
|
|
|
2005-03-06 21:41:11 -04:00
|
|
|
if (devicename == NULL) {
|
|
|
|
devicename = getenv("MIXERDEV");
|
|
|
|
if (devicename == NULL) /* MIXERDEV not set */
|
|
|
|
devicename = "/dev/mixer";
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
}
|
|
|
|
|
2005-03-06 21:41:11 -04:00
|
|
|
if ((fd = open(devicename, O_RDWR)) == -1) {
|
|
|
|
PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename);
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-03-09 23:17:06 -04:00
|
|
|
|
2002-12-30 23:07:21 -04:00
|
|
|
if ((self = PyObject_New(oss_mixer_t, &OSSMixerType)) == NULL) {
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
close(fd);
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-06-02 11:15:34 -03:00
|
|
|
|
2002-12-30 23:07:21 -04:00
|
|
|
self->fd = fd;
|
2003-06-02 11:15:34 -03:00
|
|
|
|
2002-12-30 23:07:21 -04:00
|
|
|
return self;
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-12-30 23:07:21 -04:00
|
|
|
oss_mixer_dealloc(oss_mixer_t *self)
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
{
|
|
|
|
/* if already closed, don't reclose it */
|
2002-12-30 23:07:21 -04:00
|
|
|
if (self->fd != -1)
|
|
|
|
close(self->fd);
|
|
|
|
PyObject_Del(self);
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
}
|
|
|
|
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
|
|
|
|
/* Methods to wrap the OSS ioctls. The calling convention is pretty
|
|
|
|
simple:
|
|
|
|
nonblock() -> ioctl(fd, SNDCTL_DSP_NONBLOCK)
|
|
|
|
fmt = setfmt(fmt) -> ioctl(fd, SNDCTL_DSP_SETFMT, &fmt)
|
|
|
|
etc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-05-29 18:53:06 -03:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
* Helper functions
|
|
|
|
*/
|
|
|
|
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
/* _do_ioctl_1() is a private helper function used for the OSS ioctls --
|
2013-03-11 18:41:44 -03:00
|
|
|
SNDCTL_DSP_{SETFMT,CHANNELS,SPEED} -- that are called from C
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
like this:
|
|
|
|
ioctl(fd, SNDCTL_DSP_cmd, &arg)
|
|
|
|
|
|
|
|
where arg is the value to set, and on return the driver sets arg to
|
|
|
|
the value that was actually set. Mapping this to Python is obvious:
|
|
|
|
arg = dsp.xxx(arg)
|
|
|
|
*/
|
|
|
|
static PyObject *
|
2002-12-11 10:49:59 -04:00
|
|
|
_do_ioctl_1(int fd, PyObject *args, char *fname, int cmd)
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
{
|
2002-12-11 10:49:59 -04:00
|
|
|
char argfmt[33] = "i:";
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
int arg;
|
|
|
|
|
2002-12-11 10:49:59 -04:00
|
|
|
assert(strlen(fname) <= 30);
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
strcat(argfmt, fname);
|
|
|
|
if (!PyArg_ParseTuple(args, argfmt, &arg))
|
2002-12-29 23:02:22 -04:00
|
|
|
return NULL;
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
|
2002-12-11 10:49:59 -04:00
|
|
|
if (ioctl(fd, cmd, &arg) == -1)
|
2002-11-30 19:17:10 -04:00
|
|
|
return PyErr_SetFromErrno(PyExc_IOError);
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
return PyInt_FromLong(arg);
|
|
|
|
}
|
|
|
|
|
2002-12-30 23:02:23 -04:00
|
|
|
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
/* _do_ioctl_1_internal() is a wrapper for ioctls that take no inputs
|
|
|
|
but return an output -- ie. we need to pass a pointer to a local C
|
|
|
|
variable so the driver can write its output there, but from Python
|
|
|
|
all we see is the return value. For example,
|
|
|
|
SOUND_MIXER_READ_DEVMASK returns a bitmask of available mixer
|
|
|
|
devices, but does not use the value of the parameter passed-in in any
|
|
|
|
way.
|
|
|
|
*/
|
|
|
|
static PyObject *
|
|
|
|
_do_ioctl_1_internal(int fd, PyObject *args, char *fname, int cmd)
|
|
|
|
{
|
|
|
|
char argfmt[32] = ":";
|
|
|
|
int arg = 0;
|
|
|
|
|
|
|
|
assert(strlen(fname) <= 30);
|
|
|
|
strcat(argfmt, fname);
|
|
|
|
if (!PyArg_ParseTuple(args, argfmt, &arg))
|
2002-12-29 23:02:22 -04:00
|
|
|
return NULL;
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
|
|
|
|
if (ioctl(fd, cmd, &arg) == -1)
|
|
|
|
return PyErr_SetFromErrno(PyExc_IOError);
|
|
|
|
return PyInt_FromLong(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
/* _do_ioctl_0() is a private helper for the no-argument ioctls:
|
|
|
|
SNDCTL_DSP_{SYNC,RESET,POST}. */
|
|
|
|
static PyObject *
|
2002-12-11 10:49:59 -04:00
|
|
|
_do_ioctl_0(int fd, PyObject *args, char *fname, int cmd)
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
{
|
2002-12-11 10:49:59 -04:00
|
|
|
char argfmt[32] = ":";
|
2003-05-26 22:57:21 -03:00
|
|
|
int rv;
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
|
2002-12-11 10:49:59 -04:00
|
|
|
assert(strlen(fname) <= 30);
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
strcat(argfmt, fname);
|
|
|
|
if (!PyArg_ParseTuple(args, argfmt))
|
2002-12-29 23:02:22 -04:00
|
|
|
return NULL;
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
|
2003-05-26 22:57:21 -03:00
|
|
|
/* According to hannu@opensound.com, all three of the ioctls that
|
|
|
|
use this function can block, so release the GIL. This is
|
|
|
|
especially important for SYNC, which can block for several
|
|
|
|
seconds. */
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
rv = ioctl(fd, cmd, 0);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
|
|
|
|
if (rv == -1)
|
2002-11-30 19:17:10 -04:00
|
|
|
return PyErr_SetFromErrno(PyExc_IOError);
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-30 23:02:23 -04:00
|
|
|
/* ----------------------------------------------------------------------
|
2002-12-30 23:04:52 -04:00
|
|
|
* Methods of DSP objects (OSSAudioType)
|
2002-12-30 23:02:23 -04:00
|
|
|
*/
|
|
|
|
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
static PyObject *
|
2006-05-29 18:04:52 -03:00
|
|
|
oss_nonblock(oss_audio_t *self, PyObject *unused)
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
{
|
|
|
|
/* Hmmm: it doesn't appear to be possible to return to blocking
|
|
|
|
mode once we're in non-blocking mode! */
|
2002-12-29 22:29:28 -04:00
|
|
|
if (ioctl(self->fd, SNDCTL_DSP_NONBLOCK, NULL) == -1)
|
2002-11-30 19:17:10 -04:00
|
|
|
return PyErr_SetFromErrno(PyExc_IOError);
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2002-12-30 23:04:52 -04:00
|
|
|
oss_setfmt(oss_audio_t *self, PyObject *args)
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
{
|
2002-12-29 22:29:28 -04:00
|
|
|
return _do_ioctl_1(self->fd, args, "setfmt", SNDCTL_DSP_SETFMT);
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2006-05-29 18:04:52 -03:00
|
|
|
oss_getfmts(oss_audio_t *self, PyObject *unused)
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
{
|
|
|
|
int mask;
|
2002-12-29 22:29:28 -04:00
|
|
|
if (ioctl(self->fd, SNDCTL_DSP_GETFMTS, &mask) == -1)
|
2002-11-30 19:17:10 -04:00
|
|
|
return PyErr_SetFromErrno(PyExc_IOError);
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
return PyInt_FromLong(mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2002-12-30 23:04:52 -04:00
|
|
|
oss_channels(oss_audio_t *self, PyObject *args)
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
{
|
2002-12-29 22:29:28 -04:00
|
|
|
return _do_ioctl_1(self->fd, args, "channels", SNDCTL_DSP_CHANNELS);
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2002-12-30 23:04:52 -04:00
|
|
|
oss_speed(oss_audio_t *self, PyObject *args)
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
{
|
2002-12-29 22:29:28 -04:00
|
|
|
return _do_ioctl_1(self->fd, args, "speed", SNDCTL_DSP_SPEED);
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2002-12-30 23:04:52 -04:00
|
|
|
oss_sync(oss_audio_t *self, PyObject *args)
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
{
|
2003-05-26 22:57:21 -03:00
|
|
|
return _do_ioctl_0(self->fd, args, "sync", SNDCTL_DSP_SYNC);
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
}
|
2003-06-02 11:15:34 -03:00
|
|
|
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
static PyObject *
|
2002-12-30 23:04:52 -04:00
|
|
|
oss_reset(oss_audio_t *self, PyObject *args)
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
{
|
2002-12-29 22:29:28 -04:00
|
|
|
return _do_ioctl_0(self->fd, args, "reset", SNDCTL_DSP_RESET);
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
}
|
2003-06-02 11:15:34 -03:00
|
|
|
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
static PyObject *
|
2002-12-30 23:04:52 -04:00
|
|
|
oss_post(oss_audio_t *self, PyObject *args)
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
{
|
2002-12-29 22:29:28 -04:00
|
|
|
return _do_ioctl_0(self->fd, args, "post", SNDCTL_DSP_POST);
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Regular file methods: read(), write(), close(), etc. as well
|
|
|
|
as one convenience method, writeall(). */
|
|
|
|
|
2002-11-30 18:47:45 -04:00
|
|
|
static PyObject *
|
2002-12-30 23:04:52 -04:00
|
|
|
oss_read(oss_audio_t *self, PyObject *args)
|
2002-11-30 18:47:45 -04:00
|
|
|
{
|
|
|
|
int size, count;
|
|
|
|
char *cp;
|
|
|
|
PyObject *rv;
|
2003-06-02 11:15:34 -03:00
|
|
|
|
2002-11-30 18:47:45 -04:00
|
|
|
if (!PyArg_ParseTuple(args, "i:read", &size))
|
|
|
|
return NULL;
|
2008-06-09 01:58:54 -03:00
|
|
|
rv = PyString_FromStringAndSize(NULL, size);
|
2002-11-30 18:47:45 -04:00
|
|
|
if (rv == NULL)
|
|
|
|
return NULL;
|
2008-06-09 01:58:54 -03:00
|
|
|
cp = PyString_AS_STRING(rv);
|
2003-05-22 22:50:37 -03:00
|
|
|
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
count = read(self->fd, cp, size);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
|
|
|
|
if (count < 0) {
|
2002-11-30 19:17:10 -04:00
|
|
|
PyErr_SetFromErrno(PyExc_IOError);
|
2002-11-30 18:47:45 -04:00
|
|
|
Py_DECREF(rv);
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-12-29 22:29:28 -04:00
|
|
|
self->icount += count;
|
2008-06-09 01:58:54 -03:00
|
|
|
_PyString_Resize(&rv, count);
|
2002-11-30 18:47:45 -04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2002-12-30 23:04:52 -04:00
|
|
|
oss_write(oss_audio_t *self, PyObject *args)
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
{
|
|
|
|
char *cp;
|
|
|
|
int rv, size;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "s#:write", &cp, &size)) {
|
2002-12-29 23:02:22 -04:00
|
|
|
return NULL;
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
}
|
2003-05-22 22:50:37 -03:00
|
|
|
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
rv = write(self->fd, cp, size);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
|
|
|
|
if (rv == -1) {
|
2002-11-30 19:17:10 -04:00
|
|
|
return PyErr_SetFromErrno(PyExc_IOError);
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
} else {
|
2002-12-29 22:29:28 -04:00
|
|
|
self->ocount += rv;
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
}
|
|
|
|
return PyInt_FromLong(rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2002-12-30 23:04:52 -04:00
|
|
|
oss_writeall(oss_audio_t *self, PyObject *args)
|
2002-11-30 18:47:45 -04:00
|
|
|
{
|
|
|
|
char *cp;
|
|
|
|
int rv, size;
|
|
|
|
fd_set write_set_fds;
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
int select_rv;
|
2003-06-02 11:15:34 -03:00
|
|
|
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
/* NB. writeall() is only useful in non-blocking mode: according to
|
|
|
|
Guenter Geiger <geiger@xdv.org> on the linux-audio-dev list
|
|
|
|
(http://eca.cx/lad/2002/11/0380.html), OSS guarantees that
|
|
|
|
write() in blocking mode consumes the whole buffer. In blocking
|
|
|
|
mode, the behaviour of write() and writeall() from Python is
|
|
|
|
indistinguishable. */
|
|
|
|
|
2003-06-02 11:15:34 -03:00
|
|
|
if (!PyArg_ParseTuple(args, "s#:write", &cp, &size))
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
return NULL;
|
2002-11-30 18:47:45 -04:00
|
|
|
|
2011-08-28 11:22:33 -03:00
|
|
|
if (!_PyIsSelectable_fd(self->fd)) {
|
|
|
|
PyErr_SetString(PyExc_ValueError,
|
|
|
|
"file descriptor out of range for select");
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-11-30 18:47:45 -04:00
|
|
|
/* use select to wait for audio device to be available */
|
|
|
|
FD_ZERO(&write_set_fds);
|
2002-12-29 22:29:28 -04:00
|
|
|
FD_SET(self->fd, &write_set_fds);
|
2002-11-30 18:47:45 -04:00
|
|
|
|
|
|
|
while (size > 0) {
|
2003-05-22 22:50:37 -03:00
|
|
|
Py_BEGIN_ALLOW_THREADS
|
2002-12-29 22:29:28 -04:00
|
|
|
select_rv = select(self->fd+1, NULL, &write_set_fds, NULL, NULL);
|
2003-05-22 22:50:37 -03:00
|
|
|
Py_END_ALLOW_THREADS
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
assert(select_rv != 0); /* no timeout, can't expire */
|
|
|
|
if (select_rv == -1)
|
2002-11-30 19:17:10 -04:00
|
|
|
return PyErr_SetFromErrno(PyExc_IOError);
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
|
2003-05-22 22:50:37 -03:00
|
|
|
Py_BEGIN_ALLOW_THREADS
|
2002-12-29 22:29:28 -04:00
|
|
|
rv = write(self->fd, cp, size);
|
2003-05-22 22:50:37 -03:00
|
|
|
Py_END_ALLOW_THREADS
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
if (rv == -1) {
|
|
|
|
if (errno == EAGAIN) { /* buffer is full, try again */
|
|
|
|
errno = 0;
|
|
|
|
continue;
|
|
|
|
} else /* it's a real error */
|
2002-11-30 19:17:10 -04:00
|
|
|
return PyErr_SetFromErrno(PyExc_IOError);
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
} else { /* wrote rv bytes */
|
2002-12-29 22:29:28 -04:00
|
|
|
self->ocount += rv;
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
size -= rv;
|
|
|
|
cp += rv;
|
|
|
|
}
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2006-05-29 18:04:52 -03:00
|
|
|
oss_close(oss_audio_t *self, PyObject *unused)
|
2002-11-30 18:47:45 -04:00
|
|
|
{
|
2002-12-29 22:29:28 -04:00
|
|
|
if (self->fd >= 0) {
|
2003-05-26 19:47:30 -03:00
|
|
|
Py_BEGIN_ALLOW_THREADS
|
2002-12-29 22:29:28 -04:00
|
|
|
close(self->fd);
|
2003-05-26 19:47:30 -03:00
|
|
|
Py_END_ALLOW_THREADS
|
2002-12-29 22:29:28 -04:00
|
|
|
self->fd = -1;
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2006-05-29 18:04:52 -03:00
|
|
|
oss_fileno(oss_audio_t *self, PyObject *unused)
|
2002-11-30 18:47:45 -04:00
|
|
|
{
|
2002-12-29 22:29:28 -04:00
|
|
|
return PyInt_FromLong(self->fd);
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
|
|
|
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
|
|
|
|
/* Convenience methods: these generally wrap a couple of ioctls into one
|
|
|
|
common task. */
|
|
|
|
|
2002-11-30 18:47:45 -04:00
|
|
|
static PyObject *
|
2002-12-30 23:04:52 -04:00
|
|
|
oss_setparameters(oss_audio_t *self, PyObject *args)
|
2002-11-30 18:47:45 -04:00
|
|
|
{
|
2003-05-29 18:53:06 -03:00
|
|
|
int wanted_fmt, wanted_channels, wanted_rate, strict=0;
|
|
|
|
int fmt, channels, rate;
|
2002-11-30 18:47:45 -04:00
|
|
|
|
2003-05-29 18:53:06 -03:00
|
|
|
if (!PyArg_ParseTuple(args, "iii|i:setparameters",
|
|
|
|
&wanted_fmt, &wanted_channels, &wanted_rate,
|
|
|
|
&strict))
|
2002-12-29 23:02:22 -04:00
|
|
|
return NULL;
|
2003-05-29 18:53:06 -03:00
|
|
|
|
|
|
|
fmt = wanted_fmt;
|
|
|
|
if (ioctl(self->fd, SNDCTL_DSP_SETFMT, &fmt) == -1) {
|
|
|
|
return PyErr_SetFromErrno(PyExc_IOError);
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
2003-05-29 18:53:06 -03:00
|
|
|
if (strict && fmt != wanted_fmt) {
|
|
|
|
return PyErr_Format
|
|
|
|
(OSSAudioError,
|
|
|
|
"unable to set requested format (wanted %d, got %d)",
|
|
|
|
wanted_fmt, fmt);
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
|
|
|
|
2003-05-29 18:53:06 -03:00
|
|
|
channels = wanted_channels;
|
|
|
|
if (ioctl(self->fd, SNDCTL_DSP_CHANNELS, &channels) == -1) {
|
|
|
|
return PyErr_SetFromErrno(PyExc_IOError);
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
2003-05-29 18:53:06 -03:00
|
|
|
if (strict && channels != wanted_channels) {
|
|
|
|
return PyErr_Format
|
|
|
|
(OSSAudioError,
|
|
|
|
"unable to set requested channels (wanted %d, got %d)",
|
|
|
|
wanted_channels, channels);
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
|
|
|
|
2003-05-29 18:53:06 -03:00
|
|
|
rate = wanted_rate;
|
|
|
|
if (ioctl(self->fd, SNDCTL_DSP_SPEED, &rate) == -1) {
|
|
|
|
return PyErr_SetFromErrno(PyExc_IOError);
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
2003-05-29 18:53:06 -03:00
|
|
|
if (strict && rate != wanted_rate) {
|
|
|
|
return PyErr_Format
|
|
|
|
(OSSAudioError,
|
|
|
|
"unable to set requested rate (wanted %d, got %d)",
|
|
|
|
wanted_rate, rate);
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
2003-06-02 11:15:34 -03:00
|
|
|
|
2003-05-29 18:53:06 -03:00
|
|
|
/* Construct the return value: a (fmt, channels, rate) tuple that
|
|
|
|
tells what the audio hardware was actually set to. */
|
2013-12-17 09:09:45 -04:00
|
|
|
return Py_BuildValue("(iii)", fmt, channels, rate);
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-12-30 23:04:52 -04:00
|
|
|
_ssize(oss_audio_t *self, int *nchannels, int *ssize)
|
2002-11-30 18:47:45 -04:00
|
|
|
{
|
|
|
|
int fmt;
|
|
|
|
|
|
|
|
fmt = 0;
|
2003-06-02 11:15:34 -03:00
|
|
|
if (ioctl(self->fd, SNDCTL_DSP_SETFMT, &fmt) < 0)
|
2002-11-30 18:47:45 -04:00
|
|
|
return -errno;
|
|
|
|
|
|
|
|
switch (fmt) {
|
|
|
|
case AFMT_MU_LAW:
|
|
|
|
case AFMT_A_LAW:
|
|
|
|
case AFMT_U8:
|
|
|
|
case AFMT_S8:
|
2003-05-29 18:55:41 -03:00
|
|
|
*ssize = 1; /* 8 bit formats: 1 byte */
|
2002-11-30 18:47:45 -04:00
|
|
|
break;
|
|
|
|
case AFMT_S16_LE:
|
|
|
|
case AFMT_S16_BE:
|
|
|
|
case AFMT_U16_LE:
|
|
|
|
case AFMT_U16_BE:
|
2003-05-29 20:44:44 -03:00
|
|
|
*ssize = 2; /* 16 bit formats: 2 byte */
|
2002-11-30 18:47:45 -04:00
|
|
|
break;
|
|
|
|
case AFMT_MPEG:
|
|
|
|
case AFMT_IMA_ADPCM:
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2002-12-29 22:29:28 -04:00
|
|
|
if (ioctl(self->fd, SNDCTL_DSP_CHANNELS, nchannels) < 0)
|
2002-11-30 18:47:45 -04:00
|
|
|
return -errno;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-02 11:15:34 -03:00
|
|
|
/* bufsize returns the size of the hardware audio buffer in number
|
2002-11-30 18:47:45 -04:00
|
|
|
of samples */
|
|
|
|
static PyObject *
|
2006-05-29 18:04:52 -03:00
|
|
|
oss_bufsize(oss_audio_t *self, PyObject *unused)
|
2002-11-30 18:47:45 -04:00
|
|
|
{
|
|
|
|
audio_buf_info ai;
|
2006-03-01 18:45:36 -04:00
|
|
|
int nchannels=0, ssize=0;
|
2002-11-30 18:47:45 -04:00
|
|
|
|
2006-03-01 18:45:36 -04:00
|
|
|
if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) {
|
2002-11-30 19:17:10 -04:00
|
|
|
PyErr_SetFromErrno(PyExc_IOError);
|
2002-11-30 18:47:45 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
2002-12-29 22:29:28 -04:00
|
|
|
if (ioctl(self->fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) {
|
2002-11-30 19:17:10 -04:00
|
|
|
PyErr_SetFromErrno(PyExc_IOError);
|
2002-11-30 18:47:45 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return PyInt_FromLong((ai.fragstotal * ai.fragsize) / (nchannels * ssize));
|
|
|
|
}
|
|
|
|
|
2003-06-02 11:15:34 -03:00
|
|
|
/* obufcount returns the number of samples that are available in the
|
2002-11-30 18:47:45 -04:00
|
|
|
hardware for playing */
|
|
|
|
static PyObject *
|
2006-05-29 18:04:52 -03:00
|
|
|
oss_obufcount(oss_audio_t *self, PyObject *unused)
|
2002-11-30 18:47:45 -04:00
|
|
|
{
|
|
|
|
audio_buf_info ai;
|
2006-03-01 18:45:36 -04:00
|
|
|
int nchannels=0, ssize=0;
|
2002-11-30 18:47:45 -04:00
|
|
|
|
2006-03-01 18:45:36 -04:00
|
|
|
if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) {
|
2002-11-30 19:17:10 -04:00
|
|
|
PyErr_SetFromErrno(PyExc_IOError);
|
2002-11-30 18:47:45 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
2002-12-29 22:29:28 -04:00
|
|
|
if (ioctl(self->fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) {
|
2002-11-30 19:17:10 -04:00
|
|
|
PyErr_SetFromErrno(PyExc_IOError);
|
2002-11-30 18:47:45 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-06-02 11:15:34 -03:00
|
|
|
return PyInt_FromLong((ai.fragstotal * ai.fragsize - ai.bytes) /
|
2002-11-30 18:47:45 -04:00
|
|
|
(ssize * nchannels));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* obufcount returns the number of samples that can be played without
|
|
|
|
blocking */
|
|
|
|
static PyObject *
|
2006-05-29 18:04:52 -03:00
|
|
|
oss_obuffree(oss_audio_t *self, PyObject *unused)
|
2002-11-30 18:47:45 -04:00
|
|
|
{
|
|
|
|
audio_buf_info ai;
|
2006-03-01 18:45:36 -04:00
|
|
|
int nchannels=0, ssize=0;
|
2002-11-30 18:47:45 -04:00
|
|
|
|
2006-03-01 18:45:36 -04:00
|
|
|
if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) {
|
2002-11-30 19:17:10 -04:00
|
|
|
PyErr_SetFromErrno(PyExc_IOError);
|
2002-11-30 18:47:45 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
2002-12-29 22:29:28 -04:00
|
|
|
if (ioctl(self->fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) {
|
2002-11-30 19:17:10 -04:00
|
|
|
PyErr_SetFromErrno(PyExc_IOError);
|
2002-11-30 18:47:45 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return PyInt_FromLong(ai.bytes / (ssize * nchannels));
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2006-05-29 18:04:52 -03:00
|
|
|
oss_getptr(oss_audio_t *self, PyObject *unused)
|
2002-11-30 18:47:45 -04:00
|
|
|
{
|
|
|
|
count_info info;
|
|
|
|
int req;
|
|
|
|
|
2002-12-29 22:29:28 -04:00
|
|
|
if (self->mode == O_RDONLY)
|
2002-12-29 23:02:22 -04:00
|
|
|
req = SNDCTL_DSP_GETIPTR;
|
2002-11-30 18:47:45 -04:00
|
|
|
else
|
2002-12-29 23:02:22 -04:00
|
|
|
req = SNDCTL_DSP_GETOPTR;
|
2002-12-29 22:29:28 -04:00
|
|
|
if (ioctl(self->fd, req, &info) == -1) {
|
2002-11-30 19:17:10 -04:00
|
|
|
PyErr_SetFromErrno(PyExc_IOError);
|
2002-11-30 18:47:45 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return Py_BuildValue("iii", info.bytes, info.blocks, info.ptr);
|
|
|
|
}
|
|
|
|
|
2002-12-30 23:02:23 -04:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
* Methods of mixer objects (OSSMixerType)
|
|
|
|
*/
|
|
|
|
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
static PyObject *
|
2006-05-29 18:04:52 -03:00
|
|
|
oss_mixer_close(oss_mixer_t *self, PyObject *unused)
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
{
|
2002-12-29 22:29:28 -04:00
|
|
|
if (self->fd >= 0) {
|
|
|
|
close(self->fd);
|
|
|
|
self->fd = -1;
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
}
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2006-05-29 18:04:52 -03:00
|
|
|
oss_mixer_fileno(oss_mixer_t *self, PyObject *unused)
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
{
|
2002-12-29 22:29:28 -04:00
|
|
|
return PyInt_FromLong(self->fd);
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Simple mixer interface methods */
|
|
|
|
|
|
|
|
static PyObject *
|
2002-12-30 22:54:43 -04:00
|
|
|
oss_mixer_controls(oss_mixer_t *self, PyObject *args)
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
{
|
2002-12-30 22:54:43 -04:00
|
|
|
return _do_ioctl_1_internal(self->fd, args, "controls",
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
SOUND_MIXER_READ_DEVMASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2002-12-30 22:54:43 -04:00
|
|
|
oss_mixer_stereocontrols(oss_mixer_t *self, PyObject *args)
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
{
|
2002-12-30 22:54:43 -04:00
|
|
|
return _do_ioctl_1_internal(self->fd, args, "stereocontrols",
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
SOUND_MIXER_READ_STEREODEVS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2002-12-30 22:54:43 -04:00
|
|
|
oss_mixer_reccontrols(oss_mixer_t *self, PyObject *args)
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
{
|
2002-12-30 22:54:43 -04:00
|
|
|
return _do_ioctl_1_internal(self->fd, args, "reccontrols",
|
2002-12-12 13:35:45 -04:00
|
|
|
SOUND_MIXER_READ_RECMASK);
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2002-12-29 23:01:48 -04:00
|
|
|
oss_mixer_get(oss_mixer_t *self, PyObject *args)
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
{
|
|
|
|
int channel, volume;
|
2003-06-02 11:15:34 -03:00
|
|
|
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
/* Can't use _do_ioctl_1 because of encoded arg thingy. */
|
2002-12-29 23:01:48 -04:00
|
|
|
if (!PyArg_ParseTuple(args, "i:get", &channel))
|
2002-12-29 23:02:22 -04:00
|
|
|
return NULL;
|
2003-06-02 11:15:34 -03:00
|
|
|
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) {
|
2002-12-29 23:02:22 -04:00
|
|
|
PyErr_SetString(OSSAudioError, "Invalid mixer channel specified.");
|
|
|
|
return NULL;
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
}
|
2003-06-02 11:15:34 -03:00
|
|
|
|
2002-12-29 23:01:48 -04:00
|
|
|
if (ioctl(self->fd, MIXER_READ(channel), &volume) == -1)
|
2002-12-29 23:02:22 -04:00
|
|
|
return PyErr_SetFromErrno(PyExc_IOError);
|
2003-06-02 11:15:34 -03:00
|
|
|
|
2002-12-29 23:01:48 -04:00
|
|
|
return Py_BuildValue("(ii)", volume & 0xff, (volume & 0xff00) >> 8);
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2002-12-29 23:01:48 -04:00
|
|
|
oss_mixer_set(oss_mixer_t *self, PyObject *args)
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
{
|
|
|
|
int channel, volume, leftVol, rightVol;
|
2003-06-02 11:15:34 -03:00
|
|
|
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
/* Can't use _do_ioctl_1 because of encoded arg thingy. */
|
2002-12-29 23:01:48 -04:00
|
|
|
if (!PyArg_ParseTuple(args, "i(ii):set", &channel, &leftVol, &rightVol))
|
2002-12-29 23:02:22 -04:00
|
|
|
return NULL;
|
2003-06-02 11:15:34 -03:00
|
|
|
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) {
|
2002-12-29 23:02:22 -04:00
|
|
|
PyErr_SetString(OSSAudioError, "Invalid mixer channel specified.");
|
|
|
|
return NULL;
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
}
|
2003-06-02 11:15:34 -03:00
|
|
|
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
if (leftVol < 0 || rightVol < 0 || leftVol > 100 || rightVol > 100) {
|
2002-12-29 23:02:22 -04:00
|
|
|
PyErr_SetString(OSSAudioError, "Volumes must be between 0 and 100.");
|
|
|
|
return NULL;
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
volume = (rightVol << 8) | leftVol;
|
2003-06-02 11:15:34 -03:00
|
|
|
|
2002-12-29 23:01:48 -04:00
|
|
|
if (ioctl(self->fd, MIXER_WRITE(channel), &volume) == -1)
|
2002-12-29 23:02:22 -04:00
|
|
|
return PyErr_SetFromErrno(PyExc_IOError);
|
2003-06-02 11:15:34 -03:00
|
|
|
|
2002-12-29 23:01:48 -04:00
|
|
|
return Py_BuildValue("(ii)", volume & 0xff, (volume & 0xff00) >> 8);
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2002-12-30 19:19:32 -04:00
|
|
|
oss_mixer_get_recsrc(oss_mixer_t *self, PyObject *args)
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
{
|
2002-12-30 19:19:32 -04:00
|
|
|
return _do_ioctl_1_internal(self->fd, args, "get_recsrc",
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
SOUND_MIXER_READ_RECSRC);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2002-12-30 19:19:32 -04:00
|
|
|
oss_mixer_set_recsrc(oss_mixer_t *self, PyObject *args)
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
{
|
2002-12-30 19:19:32 -04:00
|
|
|
return _do_ioctl_1(self->fd, args, "set_recsrc",
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
SOUND_MIXER_WRITE_RECSRC);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-30 23:02:23 -04:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
* Method tables and other bureaucracy
|
|
|
|
*/
|
|
|
|
|
2002-12-11 10:43:13 -04:00
|
|
|
static PyMethodDef oss_methods[] = {
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
/* Regular file methods */
|
2002-12-29 23:02:22 -04:00
|
|
|
{ "read", (PyCFunction)oss_read, METH_VARARGS },
|
|
|
|
{ "write", (PyCFunction)oss_write, METH_VARARGS },
|
|
|
|
{ "writeall", (PyCFunction)oss_writeall, METH_VARARGS },
|
2006-05-29 18:04:52 -03:00
|
|
|
{ "close", (PyCFunction)oss_close, METH_NOARGS },
|
|
|
|
{ "fileno", (PyCFunction)oss_fileno, METH_NOARGS },
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
|
|
|
|
/* Simple ioctl wrappers */
|
2006-05-29 18:04:52 -03:00
|
|
|
{ "nonblock", (PyCFunction)oss_nonblock, METH_NOARGS },
|
2002-12-29 23:02:22 -04:00
|
|
|
{ "setfmt", (PyCFunction)oss_setfmt, METH_VARARGS },
|
2006-05-29 18:04:52 -03:00
|
|
|
{ "getfmts", (PyCFunction)oss_getfmts, METH_NOARGS },
|
2002-12-11 10:43:13 -04:00
|
|
|
{ "channels", (PyCFunction)oss_channels, METH_VARARGS },
|
|
|
|
{ "speed", (PyCFunction)oss_speed, METH_VARARGS },
|
2002-12-29 23:02:22 -04:00
|
|
|
{ "sync", (PyCFunction)oss_sync, METH_VARARGS },
|
|
|
|
{ "reset", (PyCFunction)oss_reset, METH_VARARGS },
|
|
|
|
{ "post", (PyCFunction)oss_post, METH_VARARGS },
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
|
|
|
|
/* Convenience methods -- wrap a couple of ioctls together */
|
2002-12-29 23:02:22 -04:00
|
|
|
{ "setparameters", (PyCFunction)oss_setparameters, METH_VARARGS },
|
2006-05-29 18:04:52 -03:00
|
|
|
{ "bufsize", (PyCFunction)oss_bufsize, METH_NOARGS },
|
|
|
|
{ "obufcount", (PyCFunction)oss_obufcount, METH_NOARGS },
|
|
|
|
{ "obuffree", (PyCFunction)oss_obuffree, METH_NOARGS },
|
|
|
|
{ "getptr", (PyCFunction)oss_getptr, METH_NOARGS },
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
|
|
|
|
/* Aliases for backwards compatibility */
|
2002-12-29 23:02:22 -04:00
|
|
|
{ "flush", (PyCFunction)oss_sync, METH_VARARGS },
|
* Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!
* Rename write() to writeall(), and add a write() method that just
does one write().
* Rearrange/simplify writeall(): in particular, don't supply a timeout
to select(). Let it block forever if it has to.
* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
getfmts(), channels(), speed(), sync(), reset(), post(). These
wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
SNDCTL_DSP_GETFMTS, etc.
* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
an alias for sync().
* Rearrange the lad_methods list to reflect the order in which the
methods are defined, and add some grouping comments.
2002-11-30 18:56:44 -04:00
|
|
|
|
2002-12-29 23:02:22 -04:00
|
|
|
{ NULL, NULL} /* sentinel */
|
2002-11-30 18:47:45 -04:00
|
|
|
};
|
|
|
|
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
static PyMethodDef oss_mixer_methods[] = {
|
|
|
|
/* Regular file method - OSS mixers are ioctl-only interface */
|
2006-05-29 18:04:52 -03:00
|
|
|
{ "close", (PyCFunction)oss_mixer_close, METH_NOARGS },
|
|
|
|
{ "fileno", (PyCFunction)oss_mixer_fileno, METH_NOARGS },
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
|
|
|
|
/* Simple ioctl wrappers */
|
2003-06-02 11:15:34 -03:00
|
|
|
{ "controls", (PyCFunction)oss_mixer_controls, METH_VARARGS },
|
2002-12-30 22:54:43 -04:00
|
|
|
{ "stereocontrols", (PyCFunction)oss_mixer_stereocontrols, METH_VARARGS},
|
2003-06-02 11:15:34 -03:00
|
|
|
{ "reccontrols", (PyCFunction)oss_mixer_reccontrols, METH_VARARGS},
|
2002-12-29 23:02:22 -04:00
|
|
|
{ "get", (PyCFunction)oss_mixer_get, METH_VARARGS },
|
|
|
|
{ "set", (PyCFunction)oss_mixer_set, METH_VARARGS },
|
2002-12-30 19:19:32 -04:00
|
|
|
{ "get_recsrc", (PyCFunction)oss_mixer_get_recsrc, METH_VARARGS },
|
|
|
|
{ "set_recsrc", (PyCFunction)oss_mixer_set_recsrc, METH_VARARGS },
|
2003-06-02 11:15:34 -03:00
|
|
|
|
2002-12-29 23:02:22 -04:00
|
|
|
{ NULL, NULL}
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
};
|
|
|
|
|
2002-11-30 18:47:45 -04:00
|
|
|
static PyObject *
|
2002-12-30 23:07:21 -04:00
|
|
|
oss_getattr(oss_audio_t *self, char *name)
|
2002-11-30 18:47:45 -04:00
|
|
|
{
|
2005-03-06 21:41:11 -04:00
|
|
|
PyObject * rval = NULL;
|
|
|
|
if (strcmp(name, "closed") == 0) {
|
|
|
|
rval = (self->fd == -1) ? Py_True : Py_False;
|
|
|
|
Py_INCREF(rval);
|
|
|
|
}
|
|
|
|
else if (strcmp(name, "name") == 0) {
|
2008-06-09 01:58:54 -03:00
|
|
|
rval = PyString_FromString(self->devicename);
|
2005-03-06 21:41:11 -04:00
|
|
|
}
|
|
|
|
else if (strcmp(name, "mode") == 0) {
|
|
|
|
/* No need for a "default" in this switch: from newossobject(),
|
|
|
|
self->mode can only be one of these three values. */
|
|
|
|
switch(self->mode) {
|
|
|
|
case O_RDONLY:
|
2008-06-09 01:58:54 -03:00
|
|
|
rval = PyString_FromString("r");
|
2005-03-06 21:41:11 -04:00
|
|
|
break;
|
|
|
|
case O_RDWR:
|
2008-06-09 01:58:54 -03:00
|
|
|
rval = PyString_FromString("rw");
|
2005-03-06 21:41:11 -04:00
|
|
|
break;
|
|
|
|
case O_WRONLY:
|
2008-06-09 01:58:54 -03:00
|
|
|
rval = PyString_FromString("w");
|
2005-03-06 21:41:11 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rval = Py_FindMethod(oss_methods, (PyObject *)self, name);
|
|
|
|
}
|
|
|
|
return rval;
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
|
|
|
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
static PyObject *
|
2002-12-30 23:07:21 -04:00
|
|
|
oss_mixer_getattr(oss_mixer_t *self, char *name)
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
{
|
2002-12-30 23:07:21 -04:00
|
|
|
return Py_FindMethod(oss_mixer_methods, (PyObject *)self, name);
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
}
|
|
|
|
|
2002-12-30 23:04:52 -04:00
|
|
|
static PyTypeObject OSSAudioType = {
|
2007-07-21 03:55:02 -03:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
2002-11-30 19:20:09 -04:00
|
|
|
"ossaudiodev.oss_audio_device", /*tp_name*/
|
2002-12-30 23:04:52 -04:00
|
|
|
sizeof(oss_audio_t), /*tp_size*/
|
2002-12-29 23:02:22 -04:00
|
|
|
0, /*tp_itemsize*/
|
2002-11-30 18:47:45 -04:00
|
|
|
/* methods */
|
2002-12-29 23:02:22 -04:00
|
|
|
(destructor)oss_dealloc, /*tp_dealloc*/
|
|
|
|
0, /*tp_print*/
|
|
|
|
(getattrfunc)oss_getattr, /*tp_getattr*/
|
|
|
|
0, /*tp_setattr*/
|
|
|
|
0, /*tp_compare*/
|
|
|
|
0, /*tp_repr*/
|
2002-11-30 18:47:45 -04:00
|
|
|
};
|
|
|
|
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
static PyTypeObject OSSMixerType = {
|
2007-07-21 03:55:02 -03:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
"ossaudiodev.oss_mixer_device", /*tp_name*/
|
2002-12-29 23:02:22 -04:00
|
|
|
sizeof(oss_mixer_t), /*tp_size*/
|
|
|
|
0, /*tp_itemsize*/
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
/* methods */
|
|
|
|
(destructor)oss_mixer_dealloc, /*tp_dealloc*/
|
2002-12-29 23:02:22 -04:00
|
|
|
0, /*tp_print*/
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
(getattrfunc)oss_mixer_getattr, /*tp_getattr*/
|
2002-12-29 23:02:22 -04:00
|
|
|
0, /*tp_setattr*/
|
|
|
|
0, /*tp_compare*/
|
|
|
|
0, /*tp_repr*/
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-11-30 18:47:45 -04:00
|
|
|
static PyObject *
|
2002-11-30 19:20:09 -04:00
|
|
|
ossopen(PyObject *self, PyObject *args)
|
2002-11-30 18:47:45 -04:00
|
|
|
{
|
2002-12-11 10:43:13 -04:00
|
|
|
return (PyObject *)newossobject(args);
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|
|
|
|
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
static PyObject *
|
|
|
|
ossopenmixer(PyObject *self, PyObject *args)
|
|
|
|
{
|
|
|
|
return (PyObject *)newossmixerobject(args);
|
|
|
|
}
|
|
|
|
|
2002-11-30 19:20:09 -04:00
|
|
|
static PyMethodDef ossaudiodev_methods[] = {
|
|
|
|
{ "open", ossopen, METH_VARARGS },
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
{ "openmixer", ossopenmixer, METH_VARARGS },
|
2002-11-30 18:47:45 -04:00
|
|
|
{ 0, 0 },
|
|
|
|
};
|
|
|
|
|
2002-11-30 19:05:26 -04:00
|
|
|
|
|
|
|
#define _EXPORT_INT(mod, name) \
|
|
|
|
if (PyModule_AddIntConstant(mod, #name, (long) (name)) == -1) return;
|
|
|
|
|
2002-12-30 23:23:59 -04:00
|
|
|
|
|
|
|
static char *control_labels[] = SOUND_DEVICE_LABELS;
|
|
|
|
static char *control_names[] = SOUND_DEVICE_NAMES;
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
build_namelists (PyObject *module)
|
|
|
|
{
|
|
|
|
PyObject *labels;
|
|
|
|
PyObject *names;
|
|
|
|
PyObject *s;
|
|
|
|
int num_controls;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
num_controls = sizeof(control_labels) / sizeof(control_labels[0]);
|
|
|
|
assert(num_controls == sizeof(control_names) / sizeof(control_names[0]));
|
|
|
|
|
|
|
|
labels = PyList_New(num_controls);
|
|
|
|
names = PyList_New(num_controls);
|
2006-03-17 15:03:25 -04:00
|
|
|
if (labels == NULL || names == NULL)
|
|
|
|
goto error2;
|
2002-12-30 23:23:59 -04:00
|
|
|
for (i = 0; i < num_controls; i++) {
|
2008-06-09 01:58:54 -03:00
|
|
|
s = PyString_FromString(control_labels[i]);
|
2002-12-30 23:23:59 -04:00
|
|
|
if (s == NULL)
|
2006-03-17 15:03:25 -04:00
|
|
|
goto error2;
|
2002-12-30 23:23:59 -04:00
|
|
|
PyList_SET_ITEM(labels, i, s);
|
2003-06-02 11:15:34 -03:00
|
|
|
|
2008-06-09 01:58:54 -03:00
|
|
|
s = PyString_FromString(control_names[i]);
|
2002-12-30 23:23:59 -04:00
|
|
|
if (s == NULL)
|
2006-03-17 15:03:25 -04:00
|
|
|
goto error2;
|
2002-12-30 23:23:59 -04:00
|
|
|
PyList_SET_ITEM(names, i, s);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PyModule_AddObject(module, "control_labels", labels) == -1)
|
2006-03-17 15:03:25 -04:00
|
|
|
goto error2;
|
2002-12-30 23:23:59 -04:00
|
|
|
if (PyModule_AddObject(module, "control_names", names) == -1)
|
2006-03-17 15:03:25 -04:00
|
|
|
goto error1;
|
2002-12-30 23:23:59 -04:00
|
|
|
|
|
|
|
return 0;
|
2006-03-17 15:03:25 -04:00
|
|
|
|
|
|
|
error2:
|
|
|
|
Py_XDECREF(labels);
|
|
|
|
error1:
|
|
|
|
Py_XDECREF(names);
|
|
|
|
return -1;
|
2003-06-02 11:15:34 -03:00
|
|
|
}
|
2002-12-30 23:23:59 -04:00
|
|
|
|
|
|
|
|
2002-11-30 18:47:45 -04:00
|
|
|
void
|
2002-11-30 19:20:09 -04:00
|
|
|
initossaudiodev(void)
|
2002-11-30 18:47:45 -04:00
|
|
|
{
|
|
|
|
PyObject *m;
|
2003-06-02 11:15:34 -03:00
|
|
|
|
2002-11-30 19:20:09 -04:00
|
|
|
m = Py_InitModule("ossaudiodev", ossaudiodev_methods);
|
2006-01-19 02:09:39 -04:00
|
|
|
if (m == NULL)
|
|
|
|
return;
|
2002-11-30 18:47:45 -04:00
|
|
|
|
2003-06-02 11:15:34 -03:00
|
|
|
OSSAudioError = PyErr_NewException("ossaudiodev.OSSAudioError",
|
|
|
|
NULL, NULL);
|
2003-05-29 18:53:06 -03:00
|
|
|
if (OSSAudioError) {
|
2003-06-02 11:15:34 -03:00
|
|
|
/* Each call to PyModule_AddObject decrefs it; compensate: */
|
|
|
|
Py_INCREF(OSSAudioError);
|
|
|
|
Py_INCREF(OSSAudioError);
|
2002-12-29 23:02:22 -04:00
|
|
|
PyModule_AddObject(m, "error", OSSAudioError);
|
2003-05-29 18:53:06 -03:00
|
|
|
PyModule_AddObject(m, "OSSAudioError", OSSAudioError);
|
|
|
|
}
|
2002-11-30 18:47:45 -04:00
|
|
|
|
2002-12-30 23:23:59 -04:00
|
|
|
/* Build 'control_labels' and 'control_names' lists and add them
|
|
|
|
to the module. */
|
|
|
|
if (build_namelists(m) == -1) /* XXX what to do here? */
|
|
|
|
return;
|
|
|
|
|
2002-11-30 19:05:26 -04:00
|
|
|
/* Expose the audio format numbers -- essential! */
|
|
|
|
_EXPORT_INT(m, AFMT_QUERY);
|
|
|
|
_EXPORT_INT(m, AFMT_MU_LAW);
|
|
|
|
_EXPORT_INT(m, AFMT_A_LAW);
|
|
|
|
_EXPORT_INT(m, AFMT_IMA_ADPCM);
|
|
|
|
_EXPORT_INT(m, AFMT_U8);
|
|
|
|
_EXPORT_INT(m, AFMT_S16_LE);
|
|
|
|
_EXPORT_INT(m, AFMT_S16_BE);
|
|
|
|
_EXPORT_INT(m, AFMT_S8);
|
|
|
|
_EXPORT_INT(m, AFMT_U16_LE);
|
|
|
|
_EXPORT_INT(m, AFMT_U16_BE);
|
|
|
|
_EXPORT_INT(m, AFMT_MPEG);
|
2003-02-13 09:27:07 -04:00
|
|
|
#ifdef AFMT_AC3
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, AFMT_AC3);
|
2003-02-13 09:27:07 -04:00
|
|
|
#endif
|
2003-02-02 13:59:06 -04:00
|
|
|
#ifdef AFMT_S16_NE
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, AFMT_S16_NE);
|
2003-02-02 13:59:06 -04:00
|
|
|
#endif
|
2005-03-27 22:40:46 -04:00
|
|
|
#ifdef AFMT_U16_NE
|
|
|
|
_EXPORT_INT(m, AFMT_U16_NE);
|
|
|
|
#endif
|
|
|
|
#ifdef AFMT_S32_LE
|
|
|
|
_EXPORT_INT(m, AFMT_S32_LE);
|
|
|
|
#endif
|
|
|
|
#ifdef AFMT_S32_BE
|
|
|
|
_EXPORT_INT(m, AFMT_S32_BE);
|
|
|
|
#endif
|
|
|
|
#ifdef AFMT_MPEG
|
|
|
|
_EXPORT_INT(m, AFMT_MPEG);
|
|
|
|
#endif
|
2003-06-02 11:15:34 -03:00
|
|
|
|
2002-12-29 22:43:36 -04:00
|
|
|
/* Expose the sound mixer device numbers. */
|
2002-12-29 22:29:28 -04:00
|
|
|
_EXPORT_INT(m, SOUND_MIXER_NRDEVICES);
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
_EXPORT_INT(m, SOUND_MIXER_VOLUME);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_BASS);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_TREBLE);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_SYNTH);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_PCM);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_SPEAKER);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_LINE);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_MIC);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_CD);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_IMIX);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_ALTPCM);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_RECLEV);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_IGAIN);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_OGAIN);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_LINE1);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_LINE2);
|
|
|
|
_EXPORT_INT(m, SOUND_MIXER_LINE3);
|
2004-05-10 22:34:55 -03:00
|
|
|
#ifdef SOUND_MIXER_DIGITAL1
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
_EXPORT_INT(m, SOUND_MIXER_DIGITAL1);
|
2004-05-10 22:34:55 -03:00
|
|
|
#endif
|
|
|
|
#ifdef SOUND_MIXER_DIGITAL2
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
_EXPORT_INT(m, SOUND_MIXER_DIGITAL2);
|
2004-05-10 22:34:55 -03:00
|
|
|
#endif
|
|
|
|
#ifdef SOUND_MIXER_DIGITAL3
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
_EXPORT_INT(m, SOUND_MIXER_DIGITAL3);
|
2004-05-10 22:34:55 -03:00
|
|
|
#endif
|
|
|
|
#ifdef SOUND_MIXER_PHONEIN
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
_EXPORT_INT(m, SOUND_MIXER_PHONEIN);
|
2004-05-10 22:34:55 -03:00
|
|
|
#endif
|
|
|
|
#ifdef SOUND_MIXER_PHONEOUT
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
_EXPORT_INT(m, SOUND_MIXER_PHONEOUT);
|
2004-05-10 22:34:55 -03:00
|
|
|
#endif
|
|
|
|
#ifdef SOUND_MIXER_VIDEO
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
_EXPORT_INT(m, SOUND_MIXER_VIDEO);
|
2004-05-10 22:34:55 -03:00
|
|
|
#endif
|
|
|
|
#ifdef SOUND_MIXER_RADIO
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
_EXPORT_INT(m, SOUND_MIXER_RADIO);
|
2004-05-10 22:34:55 -03:00
|
|
|
#endif
|
|
|
|
#ifdef SOUND_MIXER_MONITOR
|
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
* add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
* add _do_ioctl_1_internal() to support mixer ioctls
* add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
* add oss_mixer_methods list
* add oss_mixer_getattr() (why?!)
* export SOUND_MIXER_* constants from soundcard.h
2002-12-11 11:12:01 -04:00
|
|
|
_EXPORT_INT(m, SOUND_MIXER_MONITOR);
|
2004-05-10 22:34:55 -03:00
|
|
|
#endif
|
2002-11-30 19:05:26 -04:00
|
|
|
|
|
|
|
/* Expose all the ioctl numbers for masochists who like to do this
|
|
|
|
stuff directly. */
|
|
|
|
_EXPORT_INT(m, SNDCTL_COPR_HALT);
|
|
|
|
_EXPORT_INT(m, SNDCTL_COPR_LOAD);
|
|
|
|
_EXPORT_INT(m, SNDCTL_COPR_RCODE);
|
|
|
|
_EXPORT_INT(m, SNDCTL_COPR_RCVMSG);
|
|
|
|
_EXPORT_INT(m, SNDCTL_COPR_RDATA);
|
|
|
|
_EXPORT_INT(m, SNDCTL_COPR_RESET);
|
|
|
|
_EXPORT_INT(m, SNDCTL_COPR_RUN);
|
|
|
|
_EXPORT_INT(m, SNDCTL_COPR_SENDMSG);
|
|
|
|
_EXPORT_INT(m, SNDCTL_COPR_WCODE);
|
|
|
|
_EXPORT_INT(m, SNDCTL_COPR_WDATA);
|
2003-02-02 13:59:06 -04:00
|
|
|
#ifdef SNDCTL_DSP_BIND_CHANNEL
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_BIND_CHANNEL);
|
2003-02-02 13:59:06 -04:00
|
|
|
#endif
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_CHANNELS);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_GETBLKSIZE);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_GETCAPS);
|
2003-02-02 13:59:06 -04:00
|
|
|
#ifdef SNDCTL_DSP_GETCHANNELMASK
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_GETCHANNELMASK);
|
2003-02-02 13:59:06 -04:00
|
|
|
#endif
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_GETFMTS);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_GETIPTR);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_GETISPACE);
|
2004-05-10 22:34:55 -03:00
|
|
|
#ifdef SNDCTL_DSP_GETODELAY
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_GETODELAY);
|
2004-05-10 22:34:55 -03:00
|
|
|
#endif
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_GETOPTR);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_GETOSPACE);
|
2003-01-10 17:27:54 -04:00
|
|
|
#ifdef SNDCTL_DSP_GETSPDIF
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_GETSPDIF);
|
2003-01-10 17:27:54 -04:00
|
|
|
#endif
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_GETTRIGGER);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_MAPINBUF);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_MAPOUTBUF);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_NONBLOCK);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_POST);
|
2003-02-02 13:59:06 -04:00
|
|
|
#ifdef SNDCTL_DSP_PROFILE
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_PROFILE);
|
2003-02-02 13:59:06 -04:00
|
|
|
#endif
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_RESET);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_SAMPLESIZE);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_SETDUPLEX);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_SETFMT);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_SETFRAGMENT);
|
2003-01-10 17:27:54 -04:00
|
|
|
#ifdef SNDCTL_DSP_SETSPDIF
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_SETSPDIF);
|
2003-01-10 17:27:54 -04:00
|
|
|
#endif
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_SETSYNCRO);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_SETTRIGGER);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_SPEED);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_STEREO);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_SUBDIVIDE);
|
|
|
|
_EXPORT_INT(m, SNDCTL_DSP_SYNC);
|
|
|
|
_EXPORT_INT(m, SNDCTL_FM_4OP_ENABLE);
|
|
|
|
_EXPORT_INT(m, SNDCTL_FM_LOAD_INSTR);
|
|
|
|
_EXPORT_INT(m, SNDCTL_MIDI_INFO);
|
|
|
|
_EXPORT_INT(m, SNDCTL_MIDI_MPUCMD);
|
|
|
|
_EXPORT_INT(m, SNDCTL_MIDI_MPUMODE);
|
|
|
|
_EXPORT_INT(m, SNDCTL_MIDI_PRETIME);
|
|
|
|
_EXPORT_INT(m, SNDCTL_SEQ_CTRLRATE);
|
|
|
|
_EXPORT_INT(m, SNDCTL_SEQ_GETINCOUNT);
|
|
|
|
_EXPORT_INT(m, SNDCTL_SEQ_GETOUTCOUNT);
|
2003-02-02 13:59:06 -04:00
|
|
|
#ifdef SNDCTL_SEQ_GETTIME
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_SEQ_GETTIME);
|
2003-02-02 13:59:06 -04:00
|
|
|
#endif
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_SEQ_NRMIDIS);
|
|
|
|
_EXPORT_INT(m, SNDCTL_SEQ_NRSYNTHS);
|
|
|
|
_EXPORT_INT(m, SNDCTL_SEQ_OUTOFBAND);
|
|
|
|
_EXPORT_INT(m, SNDCTL_SEQ_PANIC);
|
|
|
|
_EXPORT_INT(m, SNDCTL_SEQ_PERCMODE);
|
|
|
|
_EXPORT_INT(m, SNDCTL_SEQ_RESET);
|
|
|
|
_EXPORT_INT(m, SNDCTL_SEQ_RESETSAMPLES);
|
|
|
|
_EXPORT_INT(m, SNDCTL_SEQ_SYNC);
|
|
|
|
_EXPORT_INT(m, SNDCTL_SEQ_TESTMIDI);
|
|
|
|
_EXPORT_INT(m, SNDCTL_SEQ_THRESHOLD);
|
2003-02-02 13:59:06 -04:00
|
|
|
#ifdef SNDCTL_SYNTH_CONTROL
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_SYNTH_CONTROL);
|
2003-02-02 13:59:06 -04:00
|
|
|
#endif
|
|
|
|
#ifdef SNDCTL_SYNTH_ID
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_SYNTH_ID);
|
2003-02-02 13:59:06 -04:00
|
|
|
#endif
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_SYNTH_INFO);
|
|
|
|
_EXPORT_INT(m, SNDCTL_SYNTH_MEMAVL);
|
2003-02-02 13:59:06 -04:00
|
|
|
#ifdef SNDCTL_SYNTH_REMOVESAMPLE
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_SYNTH_REMOVESAMPLE);
|
2003-02-02 13:59:06 -04:00
|
|
|
#endif
|
2002-11-30 19:05:26 -04:00
|
|
|
_EXPORT_INT(m, SNDCTL_TMR_CONTINUE);
|
|
|
|
_EXPORT_INT(m, SNDCTL_TMR_METRONOME);
|
|
|
|
_EXPORT_INT(m, SNDCTL_TMR_SELECT);
|
|
|
|
_EXPORT_INT(m, SNDCTL_TMR_SOURCE);
|
|
|
|
_EXPORT_INT(m, SNDCTL_TMR_START);
|
|
|
|
_EXPORT_INT(m, SNDCTL_TMR_STOP);
|
|
|
|
_EXPORT_INT(m, SNDCTL_TMR_TEMPO);
|
|
|
|
_EXPORT_INT(m, SNDCTL_TMR_TIMEBASE);
|
2002-11-30 18:47:45 -04:00
|
|
|
}
|