annotate Modules/ossaudiodev.c @ 58925:eecf1bef052d 2.6

Merged revisions 78207 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line #7930: fix stripid ........
author Ezio Melotti <ezio.melotti@gmail.com>
date Tue, 16 Feb 2010 23:29:44 +0000
parents 52294af4b663
children ff6adb867f40
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
1 /*
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
2 * ossaudiodev -- Python interface to the OSS (Open Sound System) API.
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
3 * This is the standard audio API for Linux and some
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
4 * flavours of BSD [XXX which ones?]; it is also available
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
5 * for a wide range of commercial Unices.
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
6 *
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
7 * Originally written by Peter Bosch, March 2000, as linuxaudiodev.
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
8 *
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
9 * Renamed to ossaudiodev and rearranged/revised/hacked up
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
10 * by Greg Ward <gward@python.net>, November 2002.
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
11 * Mixer interface by Nicholas FitzRoy-Dale <wzdd@lardcave.net>, Dec 2002.
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
12 *
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
13 * (c) 2000 Peter Bosch. All Rights Reserved.
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
14 * (c) 2002 Gregory P. Ward. All Rights Reserved.
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
15 * (c) 2002 Python Software Foundation. All Rights Reserved.
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
16 *
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
17 * XXX need a license statement
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
18 *
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
19 * $Id$
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
20 */
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
21
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
22 #include "Python.h"
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
23 #include "structmember.h"
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
24
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
25 #ifdef HAVE_FCNTL_H
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
26 #include <fcntl.h>
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
27 #else
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
28 #define O_RDONLY 00
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
29 #define O_WRONLY 01
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
30 #endif
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
31
28250
4f679aa623c2 <sys/soundcard.h> seems to exist on both Linux and FreeBSD, so include
Greg Ward <gward@python.net>
parents: 27863
diff changeset
32 #include <sys/ioctl.h>
4f679aa623c2 <sys/soundcard.h> seems to exist on both Linux and FreeBSD, so include
Greg Ward <gward@python.net>
parents: 27863
diff changeset
33 #include <sys/soundcard.h>
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
34
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
35 #if defined(linux)
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
36
39992
0c36410c39e8 Compilation problem caused by conflicting typedefs for uint32_t
Armin Rigo <arigo@tunes.org>
parents: 38489
diff changeset
37 #ifndef HAVE_STDINT_H
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
38 typedef unsigned long uint32_t;
39992
0c36410c39e8 Compilation problem caused by conflicting typedefs for uint32_t
Armin Rigo <arigo@tunes.org>
parents: 38489
diff changeset
39 #endif
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
40
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
41 #elif defined(__FreeBSD__)
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
42
28250
4f679aa623c2 <sys/soundcard.h> seems to exist on both Linux and FreeBSD, so include
Greg Ward <gward@python.net>
parents: 27863
diff changeset
43 # ifndef SNDCTL_DSP_CHANNELS
4f679aa623c2 <sys/soundcard.h> seems to exist on both Linux and FreeBSD, so include
Greg Ward <gward@python.net>
parents: 27863
diff changeset
44 # define SNDCTL_DSP_CHANNELS SOUND_PCM_WRITE_CHANNELS
4f679aa623c2 <sys/soundcard.h> seems to exist on both Linux and FreeBSD, so include
Greg Ward <gward@python.net>
parents: 27863
diff changeset
45 # endif
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
46
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
47 #endif
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
48
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
49 typedef struct {
36221
a1b1e451d82e Fix icc warnings: extra semi-colon
Neal Norwitz <nnorwitz@gmail.com>
parents: 34821
diff changeset
50 PyObject_HEAD
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
51 char *devicename; /* name of the device file */
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
52 int fd; /* file descriptor */
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
53 int mode; /* file mode (O_RDONLY, etc.) */
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
54 int icount; /* input count */
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
55 int ocount; /* output count */
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
56 uint32_t afmts; /* audio formats supported by hardware */
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
57 } oss_audio_t;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
58
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
59 typedef struct {
36221
a1b1e451d82e Fix icc warnings: extra semi-colon
Neal Norwitz <nnorwitz@gmail.com>
parents: 34821
diff changeset
60 PyObject_HEAD
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
61 int fd; /* The open mixer device */
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
62 } oss_mixer_t;
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
63
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
64
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
65 static PyTypeObject OSSAudioType;
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
66 static PyTypeObject OSSMixerType;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
67
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
68 static PyObject *OSSAudioError;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
69
26919
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
70
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
71 /* ----------------------------------------------------------------------
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
72 * DSP object initialization/deallocation
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
73 */
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
74
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
75 static oss_audio_t *
26602
c163ed17f8ba Finish expunging the 'linuxaudiodev' name:
Greg Ward <gward@python.net>
parents: 26481
diff changeset
76 newossobject(PyObject *arg)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
77 {
26921
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
78 oss_audio_t *self;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
79 int fd, afmts, imode;
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
80 char *devicename = NULL;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
81 char *mode = NULL;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
82
26481
b268a6e859cb Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now!
Greg Ward <gward@python.net>
parents: 26480
diff changeset
83 /* Two ways to call open():
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
84 open(device, mode) (for consistency with builtin open())
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
85 open(mode) (for backwards compatibility)
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
86 because the *first* argument is optional, parsing args is
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
87 a wee bit tricky. */
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
88 if (!PyArg_ParseTuple(arg, "s|s:open", &devicename, &mode))
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
89 return NULL;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
90 if (mode == NULL) { /* only one arg supplied */
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
91 mode = devicename;
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
92 devicename = NULL;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
93 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
94
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
95 if (strcmp(mode, "r") == 0)
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
96 imode = O_RDONLY;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
97 else if (strcmp(mode, "w") == 0)
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
98 imode = O_WRONLY;
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
99 else if (strcmp(mode, "rw") == 0)
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
100 imode = O_RDWR;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
101 else {
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
102 PyErr_SetString(OSSAudioError, "mode must be 'r', 'w', or 'rw'");
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
103 return NULL;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
104 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
105
26837
15bb676f2e8c Comment fix.
Greg Ward <gward@python.net>
parents: 26836
diff changeset
106 /* Open the correct device: either the 'device' argument,
15bb676f2e8c Comment fix.
Greg Ward <gward@python.net>
parents: 26836
diff changeset
107 or the AUDIODEV environment variable, or "/dev/dsp". */
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
108 if (devicename == NULL) { /* called with one arg */
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
109 devicename = getenv("AUDIODEV");
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
110 if (devicename == NULL) /* $AUDIODEV not set */
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
111 devicename = "/dev/dsp";
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
112 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
113
28278
459c4291f759 Open with O_NONBLOCK to avoid hanging on open().
Greg Ward <gward@python.net>
parents: 28250
diff changeset
114 /* Open with O_NONBLOCK to avoid hanging on devices that only allow
459c4291f759 Open with O_NONBLOCK to avoid hanging on open().
Greg Ward <gward@python.net>
parents: 28250
diff changeset
115 one open at a time. This does *not* affect later I/O; OSS
459c4291f759 Open with O_NONBLOCK to avoid hanging on open().
Greg Ward <gward@python.net>
parents: 28250
diff changeset
116 provides a special ioctl() for non-blocking read/write, which is
459c4291f759 Open with O_NONBLOCK to avoid hanging on open().
Greg Ward <gward@python.net>
parents: 28250
diff changeset
117 exposed via oss_nonblock() below. */
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
118 if ((fd = open(devicename, imode|O_NONBLOCK)) == -1) {
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
119 PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
120 return NULL;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
121 }
28500
cba0aeee0d65 Use fcntl() to put the audio device *back* into blocking mode after
Greg Ward <gward@python.net>
parents: 28278
diff changeset
122
cba0aeee0d65 Use fcntl() to put the audio device *back* into blocking mode after
Greg Ward <gward@python.net>
parents: 28278
diff changeset
123 /* And (try to) put it back in blocking mode so we get the
cba0aeee0d65 Use fcntl() to put the audio device *back* into blocking mode after
Greg Ward <gward@python.net>
parents: 28278
diff changeset
124 expected write() semantics. */
cba0aeee0d65 Use fcntl() to put the audio device *back* into blocking mode after
Greg Ward <gward@python.net>
parents: 28278
diff changeset
125 if (fcntl(fd, F_SETFL, 0) == -1) {
cba0aeee0d65 Use fcntl() to put the audio device *back* into blocking mode after
Greg Ward <gward@python.net>
parents: 28278
diff changeset
126 close(fd);
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
127 PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename);
28500
cba0aeee0d65 Use fcntl() to put the audio device *back* into blocking mode after
Greg Ward <gward@python.net>
parents: 28278
diff changeset
128 return NULL;
cba0aeee0d65 Use fcntl() to put the audio device *back* into blocking mode after
Greg Ward <gward@python.net>
parents: 28278
diff changeset
129 }
cba0aeee0d65 Use fcntl() to put the audio device *back* into blocking mode after
Greg Ward <gward@python.net>
parents: 28278
diff changeset
130
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
131 if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) {
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
132 PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
133 return NULL;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
134 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
135 /* Create and initialize the object */
26921
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
136 if ((self = PyObject_New(oss_audio_t, &OSSAudioType)) == NULL) {
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
137 close(fd);
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
138 return NULL;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
139 }
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
140 self->devicename = devicename;
26921
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
141 self->fd = fd;
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
142 self->mode = imode;
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
143 self->icount = self->ocount = 0;
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
144 self->afmts = afmts;
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
145 return self;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
146 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
147
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
148 static void
26921
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
149 oss_dealloc(oss_audio_t *self)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
150 {
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
151 /* if already closed, don't reclose it */
26921
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
152 if (self->fd != -1)
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
153 close(self->fd);
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
154 PyObject_Del(self);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
155 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
156
26919
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
157
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
158 /* ----------------------------------------------------------------------
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
159 * Mixer object initialization/deallocation
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
160 */
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
161
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
162 static oss_mixer_t *
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
163 newossmixerobject(PyObject *arg)
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
164 {
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
165 char *devicename = NULL;
28250
4f679aa623c2 <sys/soundcard.h> seems to exist on both Linux and FreeBSD, so include
Greg Ward <gward@python.net>
parents: 27863
diff changeset
166 int fd;
26921
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
167 oss_mixer_t *self;
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
168
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
169 if (!PyArg_ParseTuple(arg, "|s", &devicename)) {
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
170 return NULL;
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
171 }
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
172
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
173 if (devicename == NULL) {
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
174 devicename = getenv("MIXERDEV");
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
175 if (devicename == NULL) /* MIXERDEV not set */
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
176 devicename = "/dev/mixer";
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
177 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
178
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
179 if ((fd = open(devicename, O_RDWR)) == -1) {
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
180 PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename);
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
181 return NULL;
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
182 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
183
26921
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
184 if ((self = PyObject_New(oss_mixer_t, &OSSMixerType)) == NULL) {
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
185 close(fd);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
186 return NULL;
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
187 }
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
188
26921
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
189 self->fd = fd;
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
190
26921
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
191 return self;
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
192 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
193
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
194 static void
26921
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
195 oss_mixer_dealloc(oss_mixer_t *self)
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
196 {
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
197 /* if already closed, don't reclose it */
26921
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
198 if (self->fd != -1)
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
199 close(self->fd);
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
200 PyObject_Del(self);
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
201 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
202
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
203
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
204 /* Methods to wrap the OSS ioctls. The calling convention is pretty
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
205 simple:
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
206 nonblock() -> ioctl(fd, SNDCTL_DSP_NONBLOCK)
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
207 fmt = setfmt(fmt) -> ioctl(fd, SNDCTL_DSP_SETFMT, &fmt)
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
208 etc.
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
209 */
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
210
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
211
29324
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
212 /* ----------------------------------------------------------------------
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
213 * Helper functions
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
214 */
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
215
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
216 /* _do_ioctl_1() is a private helper function used for the OSS ioctls --
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
217 SNDCTL_DSP_{SETFMT,CHANNELS,SPEED} -- that that are called from C
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
218 like this:
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
219 ioctl(fd, SNDCTL_DSP_cmd, &arg)
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
220
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
221 where arg is the value to set, and on return the driver sets arg to
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
222 the value that was actually set. Mapping this to Python is obvious:
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
223 arg = dsp.xxx(arg)
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
224 */
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
225 static PyObject *
26603
bfb2664cdb1b Prepare for the coming mixer support patch: change _do_ioctl_0() and
Greg Ward <gward@python.net>
parents: 26602
diff changeset
226 _do_ioctl_1(int fd, PyObject *args, char *fname, int cmd)
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
227 {
26603
bfb2664cdb1b Prepare for the coming mixer support patch: change _do_ioctl_0() and
Greg Ward <gward@python.net>
parents: 26602
diff changeset
228 char argfmt[33] = "i:";
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
229 int arg;
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
230
26603
bfb2664cdb1b Prepare for the coming mixer support patch: change _do_ioctl_0() and
Greg Ward <gward@python.net>
parents: 26602
diff changeset
231 assert(strlen(fname) <= 30);
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
232 strcat(argfmt, fname);
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
233 if (!PyArg_ParseTuple(args, argfmt, &arg))
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
234 return NULL;
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
235
26603
bfb2664cdb1b Prepare for the coming mixer support patch: change _do_ioctl_0() and
Greg Ward <gward@python.net>
parents: 26602
diff changeset
236 if (ioctl(fd, cmd, &arg) == -1)
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
237 return PyErr_SetFromErrno(PyExc_IOError);
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
238 return PyInt_FromLong(arg);
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
239 }
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
240
26919
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
241
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
242 /* _do_ioctl_1_internal() is a wrapper for ioctls that take no inputs
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
243 but return an output -- ie. we need to pass a pointer to a local C
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
244 variable so the driver can write its output there, but from Python
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
245 all we see is the return value. For example,
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
246 SOUND_MIXER_READ_DEVMASK returns a bitmask of available mixer
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
247 devices, but does not use the value of the parameter passed-in in any
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
248 way.
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
249 */
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
250 static PyObject *
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
251 _do_ioctl_1_internal(int fd, PyObject *args, char *fname, int cmd)
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
252 {
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
253 char argfmt[32] = ":";
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
254 int arg = 0;
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
255
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
256 assert(strlen(fname) <= 30);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
257 strcat(argfmt, fname);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
258 if (!PyArg_ParseTuple(args, argfmt, &arg))
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
259 return NULL;
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
260
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
261 if (ioctl(fd, cmd, &arg) == -1)
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
262 return PyErr_SetFromErrno(PyExc_IOError);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
263 return PyInt_FromLong(arg);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
264 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
265
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
266
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
267
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
268 /* _do_ioctl_0() is a private helper for the no-argument ioctls:
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
269 SNDCTL_DSP_{SYNC,RESET,POST}. */
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
270 static PyObject *
26603
bfb2664cdb1b Prepare for the coming mixer support patch: change _do_ioctl_0() and
Greg Ward <gward@python.net>
parents: 26602
diff changeset
271 _do_ioctl_0(int fd, PyObject *args, char *fname, int cmd)
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
272 {
26603
bfb2664cdb1b Prepare for the coming mixer support patch: change _do_ioctl_0() and
Greg Ward <gward@python.net>
parents: 26602
diff changeset
273 char argfmt[32] = ":";
29274
df80a5b6957b Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
Greg Ward <gward@python.net>
parents: 29272
diff changeset
274 int rv;
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
275
26603
bfb2664cdb1b Prepare for the coming mixer support patch: change _do_ioctl_0() and
Greg Ward <gward@python.net>
parents: 26602
diff changeset
276 assert(strlen(fname) <= 30);
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
277 strcat(argfmt, fname);
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
278 if (!PyArg_ParseTuple(args, argfmt))
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
279 return NULL;
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
280
29274
df80a5b6957b Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
Greg Ward <gward@python.net>
parents: 29272
diff changeset
281 /* According to hannu@opensound.com, all three of the ioctls that
df80a5b6957b Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
Greg Ward <gward@python.net>
parents: 29272
diff changeset
282 use this function can block, so release the GIL. This is
df80a5b6957b Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
Greg Ward <gward@python.net>
parents: 29272
diff changeset
283 especially important for SYNC, which can block for several
df80a5b6957b Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
Greg Ward <gward@python.net>
parents: 29272
diff changeset
284 seconds. */
df80a5b6957b Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
Greg Ward <gward@python.net>
parents: 29272
diff changeset
285 Py_BEGIN_ALLOW_THREADS
df80a5b6957b Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
Greg Ward <gward@python.net>
parents: 29272
diff changeset
286 rv = ioctl(fd, cmd, 0);
df80a5b6957b Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
Greg Ward <gward@python.net>
parents: 29272
diff changeset
287 Py_END_ALLOW_THREADS
df80a5b6957b Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
Greg Ward <gward@python.net>
parents: 29272
diff changeset
288
df80a5b6957b Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
Greg Ward <gward@python.net>
parents: 29272
diff changeset
289 if (rv == -1)
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
290 return PyErr_SetFromErrno(PyExc_IOError);
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
291 Py_INCREF(Py_None);
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
292 return Py_None;
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
293 }
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
294
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
295
26919
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
296 /* ----------------------------------------------------------------------
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
297 * Methods of DSP objects (OSSAudioType)
26919
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
298 */
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
299
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
300 static PyObject *
38489
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
301 oss_nonblock(oss_audio_t *self, PyObject *unused)
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
302 {
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
303 /* Hmmm: it doesn't appear to be possible to return to blocking
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
304 mode once we're in non-blocking mode! */
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
305 if (ioctl(self->fd, SNDCTL_DSP_NONBLOCK, NULL) == -1)
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
306 return PyErr_SetFromErrno(PyExc_IOError);
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
307 Py_INCREF(Py_None);
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
308 return Py_None;
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
309 }
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
310
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
311 static PyObject *
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
312 oss_setfmt(oss_audio_t *self, PyObject *args)
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
313 {
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
314 return _do_ioctl_1(self->fd, args, "setfmt", SNDCTL_DSP_SETFMT);
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
315 }
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
316
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
317 static PyObject *
38489
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
318 oss_getfmts(oss_audio_t *self, PyObject *unused)
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
319 {
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
320 int mask;
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
321 if (ioctl(self->fd, SNDCTL_DSP_GETFMTS, &mask) == -1)
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
322 return PyErr_SetFromErrno(PyExc_IOError);
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
323 return PyInt_FromLong(mask);
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
324 }
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
325
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
326 static PyObject *
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
327 oss_channels(oss_audio_t *self, PyObject *args)
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
328 {
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
329 return _do_ioctl_1(self->fd, args, "channels", SNDCTL_DSP_CHANNELS);
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
330 }
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
331
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
332 static PyObject *
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
333 oss_speed(oss_audio_t *self, PyObject *args)
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
334 {
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
335 return _do_ioctl_1(self->fd, args, "speed", SNDCTL_DSP_SPEED);
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
336 }
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
337
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
338 static PyObject *
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
339 oss_sync(oss_audio_t *self, PyObject *args)
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
340 {
29274
df80a5b6957b Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
Greg Ward <gward@python.net>
parents: 29272
diff changeset
341 return _do_ioctl_0(self->fd, args, "sync", SNDCTL_DSP_SYNC);
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
342 }
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
343
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
344 static PyObject *
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
345 oss_reset(oss_audio_t *self, PyObject *args)
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
346 {
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
347 return _do_ioctl_0(self->fd, args, "reset", SNDCTL_DSP_RESET);
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
348 }
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
349
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
350 static PyObject *
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
351 oss_post(oss_audio_t *self, PyObject *args)
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
352 {
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
353 return _do_ioctl_0(self->fd, args, "post", SNDCTL_DSP_POST);
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
354 }
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
355
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
356
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
357 /* Regular file methods: read(), write(), close(), etc. as well
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
358 as one convenience method, writeall(). */
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
359
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
360 static PyObject *
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
361 oss_read(oss_audio_t *self, PyObject *args)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
362 {
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
363 int size, count;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
364 char *cp;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
365 PyObject *rv;
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
366
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
367 if (!PyArg_ParseTuple(args, "i:read", &size))
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
368 return NULL;
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
369 rv = PyString_FromStringAndSize(NULL, size);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
370 if (rv == NULL)
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
371 return NULL;
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
372 cp = PyString_AS_STRING(rv);
29238
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
373
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
374 Py_BEGIN_ALLOW_THREADS
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
375 count = read(self->fd, cp, size);
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
376 Py_END_ALLOW_THREADS
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
377
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
378 if (count < 0) {
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
379 PyErr_SetFromErrno(PyExc_IOError);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
380 Py_DECREF(rv);
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
381 return NULL;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
382 }
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
383 self->icount += count;
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
384 _PyString_Resize(&rv, count);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
385 return rv;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
386 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
387
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
388 static PyObject *
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
389 oss_write(oss_audio_t *self, PyObject *args)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
390 {
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
391 char *cp;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
392 int rv, size;
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
393
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
394 if (!PyArg_ParseTuple(args, "s#:write", &cp, &size)) {
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
395 return NULL;
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
396 }
29238
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
397
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
398 Py_BEGIN_ALLOW_THREADS
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
399 rv = write(self->fd, cp, size);
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
400 Py_END_ALLOW_THREADS
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
401
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
402 if (rv == -1) {
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
403 return PyErr_SetFromErrno(PyExc_IOError);
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
404 } else {
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
405 self->ocount += rv;
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
406 }
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
407 return PyInt_FromLong(rv);
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
408 }
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
409
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
410 static PyObject *
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
411 oss_writeall(oss_audio_t *self, PyObject *args)
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
412 {
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
413 char *cp;
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
414 int rv, size;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
415 fd_set write_set_fds;
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
416 int select_rv;
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
417
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
418 /* NB. writeall() is only useful in non-blocking mode: according to
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
419 Guenter Geiger <geiger@xdv.org> on the linux-audio-dev list
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
420 (http://eca.cx/lad/2002/11/0380.html), OSS guarantees that
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
421 write() in blocking mode consumes the whole buffer. In blocking
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
422 mode, the behaviour of write() and writeall() from Python is
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
423 indistinguishable. */
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
424
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
425 if (!PyArg_ParseTuple(args, "s#:write", &cp, &size))
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
426 return NULL;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
427
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
428 /* use select to wait for audio device to be available */
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
429 FD_ZERO(&write_set_fds);
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
430 FD_SET(self->fd, &write_set_fds);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
431
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
432 while (size > 0) {
29238
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
433 Py_BEGIN_ALLOW_THREADS
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
434 select_rv = select(self->fd+1, NULL, &write_set_fds, NULL, NULL);
29238
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
435 Py_END_ALLOW_THREADS
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
436 assert(select_rv != 0); /* no timeout, can't expire */
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
437 if (select_rv == -1)
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
438 return PyErr_SetFromErrno(PyExc_IOError);
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
439
29238
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
440 Py_BEGIN_ALLOW_THREADS
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
441 rv = write(self->fd, cp, size);
29238
752fc5ea16b9 Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents: 28500
diff changeset
442 Py_END_ALLOW_THREADS
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
443 if (rv == -1) {
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
444 if (errno == EAGAIN) { /* buffer is full, try again */
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
445 errno = 0;
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
446 continue;
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
447 } else /* it's a real error */
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
448 return PyErr_SetFromErrno(PyExc_IOError);
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
449 } else { /* wrote rv bytes */
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
450 self->ocount += rv;
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
451 size -= rv;
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
452 cp += rv;
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
453 }
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
454 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
455 Py_INCREF(Py_None);
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
456 return Py_None;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
457 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
458
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
459 static PyObject *
38489
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
460 oss_close(oss_audio_t *self, PyObject *unused)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
461 {
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
462 if (self->fd >= 0) {
29272
b7cd1ff0019b Release the GIL in two more methods:
Greg Ward <gward@python.net>
parents: 29238
diff changeset
463 Py_BEGIN_ALLOW_THREADS
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
464 close(self->fd);
29272
b7cd1ff0019b Release the GIL in two more methods:
Greg Ward <gward@python.net>
parents: 29238
diff changeset
465 Py_END_ALLOW_THREADS
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
466 self->fd = -1;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
467 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
468 Py_INCREF(Py_None);
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
469 return Py_None;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
470 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
471
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
472 static PyObject *
38489
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
473 oss_fileno(oss_audio_t *self, PyObject *unused)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
474 {
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
475 return PyInt_FromLong(self->fd);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
476 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
477
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
479 /* Convenience methods: these generally wrap a couple of ioctls into one
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
480 common task. */
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
481
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
482 static PyObject *
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
483 oss_setparameters(oss_audio_t *self, PyObject *args)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
484 {
29324
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
485 int wanted_fmt, wanted_channels, wanted_rate, strict=0;
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
486 int fmt, channels, rate;
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
487 PyObject * rv; /* return tuple (fmt, channels, rate) */
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
488
29324
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
489 if (!PyArg_ParseTuple(args, "iii|i:setparameters",
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
490 &wanted_fmt, &wanted_channels, &wanted_rate,
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
491 &strict))
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
492 return NULL;
29324
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
493
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
494 fmt = wanted_fmt;
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
495 if (ioctl(self->fd, SNDCTL_DSP_SETFMT, &fmt) == -1) {
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
496 return PyErr_SetFromErrno(PyExc_IOError);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
497 }
29324
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
498 if (strict && fmt != wanted_fmt) {
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
499 return PyErr_Format
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
500 (OSSAudioError,
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
501 "unable to set requested format (wanted %d, got %d)",
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
502 wanted_fmt, fmt);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
503 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
504
29324
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
505 channels = wanted_channels;
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
506 if (ioctl(self->fd, SNDCTL_DSP_CHANNELS, &channels) == -1) {
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
507 return PyErr_SetFromErrno(PyExc_IOError);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
508 }
29324
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
509 if (strict && channels != wanted_channels) {
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
510 return PyErr_Format
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
511 (OSSAudioError,
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
512 "unable to set requested channels (wanted %d, got %d)",
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
513 wanted_channels, channels);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
514 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
515
29324
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
516 rate = wanted_rate;
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
517 if (ioctl(self->fd, SNDCTL_DSP_SPEED, &rate) == -1) {
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
518 return PyErr_SetFromErrno(PyExc_IOError);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
519 }
29324
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
520 if (strict && rate != wanted_rate) {
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
521 return PyErr_Format
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
522 (OSSAudioError,
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
523 "unable to set requested rate (wanted %d, got %d)",
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
524 wanted_rate, rate);
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
525 }
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
526
29324
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
527 /* Construct the return value: a (fmt, channels, rate) tuple that
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
528 tells what the audio hardware was actually set to. */
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
529 rv = PyTuple_New(3);
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
530 if (rv == NULL)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
531 return NULL;
29324
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
532 PyTuple_SET_ITEM(rv, 0, PyInt_FromLong(fmt));
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
533 PyTuple_SET_ITEM(rv, 1, PyInt_FromLong(channels));
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
534 PyTuple_SET_ITEM(rv, 2, PyInt_FromLong(rate));
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
535 return rv;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
536 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
537
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
538 static int
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
539 _ssize(oss_audio_t *self, int *nchannels, int *ssize)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
540 {
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
541 int fmt;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
542
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
543 fmt = 0;
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
544 if (ioctl(self->fd, SNDCTL_DSP_SETFMT, &fmt) < 0)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
545 return -errno;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
546
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
547 switch (fmt) {
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
548 case AFMT_MU_LAW:
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
549 case AFMT_A_LAW:
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
550 case AFMT_U8:
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
551 case AFMT_S8:
29325
7bec628998fe Change _ssize() so it doesn't rely on sizeof(char) or sizeof(short):
Greg Ward <gward@python.net>
parents: 29324
diff changeset
552 *ssize = 1; /* 8 bit formats: 1 byte */
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
553 break;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
554 case AFMT_S16_LE:
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
555 case AFMT_S16_BE:
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
556 case AFMT_U16_LE:
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
557 case AFMT_U16_BE:
29327
3682aa27141b Comment fix.
Greg Ward <gward@python.net>
parents: 29325
diff changeset
558 *ssize = 2; /* 16 bit formats: 2 byte */
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
559 break;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
560 case AFMT_MPEG:
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
561 case AFMT_IMA_ADPCM:
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
562 default:
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
563 return -EOPNOTSUPP;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
564 }
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
565 if (ioctl(self->fd, SNDCTL_DSP_CHANNELS, nchannels) < 0)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
566 return -errno;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
567 return 0;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
568 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
569
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
570
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
571 /* bufsize returns the size of the hardware audio buffer in number
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
572 of samples */
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
573 static PyObject *
38489
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
574 oss_bufsize(oss_audio_t *self, PyObject *unused)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
575 {
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
576 audio_buf_info ai;
36785
6e285c69efc0 Rework channelnumber/samplesize detetion code's output variables a bit to
Thomas Wouters <thomas@python.org>
parents: 36324
diff changeset
577 int nchannels=0, ssize=0;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
578
36785
6e285c69efc0 Rework channelnumber/samplesize detetion code's output variables a bit to
Thomas Wouters <thomas@python.org>
parents: 36324
diff changeset
579 if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) {
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
580 PyErr_SetFromErrno(PyExc_IOError);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
581 return NULL;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
582 }
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
583 if (ioctl(self->fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) {
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
584 PyErr_SetFromErrno(PyExc_IOError);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
585 return NULL;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
586 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
587 return PyInt_FromLong((ai.fragstotal * ai.fragsize) / (nchannels * ssize));
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
588 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
589
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
590 /* obufcount returns the number of samples that are available in the
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
591 hardware for playing */
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
592 static PyObject *
38489
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
593 oss_obufcount(oss_audio_t *self, PyObject *unused)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
594 {
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
595 audio_buf_info ai;
36785
6e285c69efc0 Rework channelnumber/samplesize detetion code's output variables a bit to
Thomas Wouters <thomas@python.org>
parents: 36324
diff changeset
596 int nchannels=0, ssize=0;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
597
36785
6e285c69efc0 Rework channelnumber/samplesize detetion code's output variables a bit to
Thomas Wouters <thomas@python.org>
parents: 36324
diff changeset
598 if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) {
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
599 PyErr_SetFromErrno(PyExc_IOError);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
600 return NULL;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
601 }
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
602 if (ioctl(self->fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) {
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
603 PyErr_SetFromErrno(PyExc_IOError);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
604 return NULL;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
605 }
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
606 return PyInt_FromLong((ai.fragstotal * ai.fragsize - ai.bytes) /
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
607 (ssize * nchannels));
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
608 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
609
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
610 /* obufcount returns the number of samples that can be played without
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
611 blocking */
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
612 static PyObject *
38489
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
613 oss_obuffree(oss_audio_t *self, PyObject *unused)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
614 {
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
615 audio_buf_info ai;
36785
6e285c69efc0 Rework channelnumber/samplesize detetion code's output variables a bit to
Thomas Wouters <thomas@python.org>
parents: 36324
diff changeset
616 int nchannels=0, ssize=0;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
617
36785
6e285c69efc0 Rework channelnumber/samplesize detetion code's output variables a bit to
Thomas Wouters <thomas@python.org>
parents: 36324
diff changeset
618 if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) {
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
619 PyErr_SetFromErrno(PyExc_IOError);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
620 return NULL;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
621 }
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
622 if (ioctl(self->fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) {
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
623 PyErr_SetFromErrno(PyExc_IOError);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
624 return NULL;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
625 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
626 return PyInt_FromLong(ai.bytes / (ssize * nchannels));
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
627 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
628
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
629 static PyObject *
38489
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
630 oss_getptr(oss_audio_t *self, PyObject *unused)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
631 {
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
632 count_info info;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
633 int req;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
634
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
635 if (self->mode == O_RDONLY)
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
636 req = SNDCTL_DSP_GETIPTR;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
637 else
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
638 req = SNDCTL_DSP_GETOPTR;
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
639 if (ioctl(self->fd, req, &info) == -1) {
26480
7ba072db3828 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents: 26479
diff changeset
640 PyErr_SetFromErrno(PyExc_IOError);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
641 return NULL;
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
642 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
643 return Py_BuildValue("iii", info.bytes, info.blocks, info.ptr);
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
644 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
645
26919
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
646
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
647 /* ----------------------------------------------------------------------
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
648 * Methods of mixer objects (OSSMixerType)
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
649 */
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
650
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
651 static PyObject *
38489
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
652 oss_mixer_close(oss_mixer_t *self, PyObject *unused)
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
653 {
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
654 if (self->fd >= 0) {
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
655 close(self->fd);
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
656 self->fd = -1;
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
657 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
658 Py_INCREF(Py_None);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
659 return Py_None;
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
660 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
661
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
662 static PyObject *
38489
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
663 oss_mixer_fileno(oss_mixer_t *self, PyObject *unused)
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
664 {
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
665 return PyInt_FromLong(self->fd);
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
666 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
667
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
668 /* Simple mixer interface methods */
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
669
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
670 static PyObject *
26918
05016bb91766 Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents: 26904
diff changeset
671 oss_mixer_controls(oss_mixer_t *self, PyObject *args)
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
672 {
26918
05016bb91766 Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents: 26904
diff changeset
673 return _do_ioctl_1_internal(self->fd, args, "controls",
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
674 SOUND_MIXER_READ_DEVMASK);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
675 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
676
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
677 static PyObject *
26918
05016bb91766 Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents: 26904
diff changeset
678 oss_mixer_stereocontrols(oss_mixer_t *self, PyObject *args)
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
679 {
26918
05016bb91766 Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents: 26904
diff changeset
680 return _do_ioctl_1_internal(self->fd, args, "stereocontrols",
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
681 SOUND_MIXER_READ_STEREODEVS);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
682 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
683
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
684 static PyObject *
26918
05016bb91766 Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents: 26904
diff changeset
685 oss_mixer_reccontrols(oss_mixer_t *self, PyObject *args)
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
686 {
26918
05016bb91766 Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents: 26904
diff changeset
687 return _do_ioctl_1_internal(self->fd, args, "reccontrols",
26615
02785248e00a Typo fix.
Greg Ward <gward@python.net>
parents: 26605
diff changeset
688 SOUND_MIXER_READ_RECMASK);
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
689 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
690
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
691 static PyObject *
26839
c44d994b39e5 Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents: 26837
diff changeset
692 oss_mixer_get(oss_mixer_t *self, PyObject *args)
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
693 {
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
694 int channel, volume;
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
695
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
696 /* Can't use _do_ioctl_1 because of encoded arg thingy. */
26839
c44d994b39e5 Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents: 26837
diff changeset
697 if (!PyArg_ParseTuple(args, "i:get", &channel))
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
698 return NULL;
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
699
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
700 if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) {
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
701 PyErr_SetString(OSSAudioError, "Invalid mixer channel specified.");
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
702 return NULL;
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
703 }
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
704
26839
c44d994b39e5 Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents: 26837
diff changeset
705 if (ioctl(self->fd, MIXER_READ(channel), &volume) == -1)
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
706 return PyErr_SetFromErrno(PyExc_IOError);
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
707
26839
c44d994b39e5 Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents: 26837
diff changeset
708 return Py_BuildValue("(ii)", volume & 0xff, (volume & 0xff00) >> 8);
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
709 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
710
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
711 static PyObject *
26839
c44d994b39e5 Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents: 26837
diff changeset
712 oss_mixer_set(oss_mixer_t *self, PyObject *args)
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
713 {
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
714 int channel, volume, leftVol, rightVol;
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
715
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
716 /* Can't use _do_ioctl_1 because of encoded arg thingy. */
26839
c44d994b39e5 Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents: 26837
diff changeset
717 if (!PyArg_ParseTuple(args, "i(ii):set", &channel, &leftVol, &rightVol))
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
718 return NULL;
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
719
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
720 if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) {
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
721 PyErr_SetString(OSSAudioError, "Invalid mixer channel specified.");
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
722 return NULL;
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
723 }
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
724
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
725 if (leftVol < 0 || rightVol < 0 || leftVol > 100 || rightVol > 100) {
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
726 PyErr_SetString(OSSAudioError, "Volumes must be between 0 and 100.");
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
727 return NULL;
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
728 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
729
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
730 volume = (rightVol << 8) | leftVol;
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
731
26839
c44d994b39e5 Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents: 26837
diff changeset
732 if (ioctl(self->fd, MIXER_WRITE(channel), &volume) == -1)
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
733 return PyErr_SetFromErrno(PyExc_IOError);
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
734
26839
c44d994b39e5 Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents: 26837
diff changeset
735 return Py_BuildValue("(ii)", volume & 0xff, (volume & 0xff00) >> 8);
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
736 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
737
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
738 static PyObject *
26904
40db78159177 Rename more mixer methods: getrecsrc() -> get_recsrc(),
Greg Ward <gward@python.net>
parents: 26840
diff changeset
739 oss_mixer_get_recsrc(oss_mixer_t *self, PyObject *args)
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
740 {
26904
40db78159177 Rename more mixer methods: getrecsrc() -> get_recsrc(),
Greg Ward <gward@python.net>
parents: 26840
diff changeset
741 return _do_ioctl_1_internal(self->fd, args, "get_recsrc",
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
742 SOUND_MIXER_READ_RECSRC);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
743 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
744
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
745 static PyObject *
26904
40db78159177 Rename more mixer methods: getrecsrc() -> get_recsrc(),
Greg Ward <gward@python.net>
parents: 26840
diff changeset
746 oss_mixer_set_recsrc(oss_mixer_t *self, PyObject *args)
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
747 {
26904
40db78159177 Rename more mixer methods: getrecsrc() -> get_recsrc(),
Greg Ward <gward@python.net>
parents: 26840
diff changeset
748 return _do_ioctl_1(self->fd, args, "set_recsrc",
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
749 SOUND_MIXER_WRITE_RECSRC);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
750 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
751
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
752
26919
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
753 /* ----------------------------------------------------------------------
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
754 * Method tables and other bureaucracy
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
755 */
b93845226db6 Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents: 26918
diff changeset
756
26602
c163ed17f8ba Finish expunging the 'linuxaudiodev' name:
Greg Ward <gward@python.net>
parents: 26481
diff changeset
757 static PyMethodDef oss_methods[] = {
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
758 /* Regular file methods */
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
759 { "read", (PyCFunction)oss_read, METH_VARARGS },
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
760 { "write", (PyCFunction)oss_write, METH_VARARGS },
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
761 { "writeall", (PyCFunction)oss_writeall, METH_VARARGS },
38489
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
762 { "close", (PyCFunction)oss_close, METH_NOARGS },
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
763 { "fileno", (PyCFunction)oss_fileno, METH_NOARGS },
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
764
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
765 /* Simple ioctl wrappers */
38489
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
766 { "nonblock", (PyCFunction)oss_nonblock, METH_NOARGS },
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
767 { "setfmt", (PyCFunction)oss_setfmt, METH_VARARGS },
38489
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
768 { "getfmts", (PyCFunction)oss_getfmts, METH_NOARGS },
26602
c163ed17f8ba Finish expunging the 'linuxaudiodev' name:
Greg Ward <gward@python.net>
parents: 26481
diff changeset
769 { "channels", (PyCFunction)oss_channels, METH_VARARGS },
c163ed17f8ba Finish expunging the 'linuxaudiodev' name:
Greg Ward <gward@python.net>
parents: 26481
diff changeset
770 { "speed", (PyCFunction)oss_speed, METH_VARARGS },
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
771 { "sync", (PyCFunction)oss_sync, METH_VARARGS },
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
772 { "reset", (PyCFunction)oss_reset, METH_VARARGS },
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
773 { "post", (PyCFunction)oss_post, METH_VARARGS },
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
774
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
775 /* Convenience methods -- wrap a couple of ioctls together */
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
776 { "setparameters", (PyCFunction)oss_setparameters, METH_VARARGS },
38489
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
777 { "bufsize", (PyCFunction)oss_bufsize, METH_NOARGS },
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
778 { "obufcount", (PyCFunction)oss_obufcount, METH_NOARGS },
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
779 { "obuffree", (PyCFunction)oss_obuffree, METH_NOARGS },
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
780 { "getptr", (PyCFunction)oss_getptr, METH_NOARGS },
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
781
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
782 /* Aliases for backwards compatibility */
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
783 { "flush", (PyCFunction)oss_sync, METH_VARARGS },
26478
7468b68e9828 * Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents: 26477
diff changeset
784
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
785 { NULL, NULL} /* sentinel */
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
786 };
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
787
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
788 static PyMethodDef oss_mixer_methods[] = {
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
789 /* Regular file method - OSS mixers are ioctl-only interface */
38489
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
790 { "close", (PyCFunction)oss_mixer_close, METH_NOARGS },
3fe3ccdf0155 Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents: 37067
diff changeset
791 { "fileno", (PyCFunction)oss_mixer_fileno, METH_NOARGS },
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
792
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
793 /* Simple ioctl wrappers */
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
794 { "controls", (PyCFunction)oss_mixer_controls, METH_VARARGS },
26918
05016bb91766 Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents: 26904
diff changeset
795 { "stereocontrols", (PyCFunction)oss_mixer_stereocontrols, METH_VARARGS},
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
796 { "reccontrols", (PyCFunction)oss_mixer_reccontrols, METH_VARARGS},
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
797 { "get", (PyCFunction)oss_mixer_get, METH_VARARGS },
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
798 { "set", (PyCFunction)oss_mixer_set, METH_VARARGS },
26904
40db78159177 Rename more mixer methods: getrecsrc() -> get_recsrc(),
Greg Ward <gward@python.net>
parents: 26840
diff changeset
799 { "get_recsrc", (PyCFunction)oss_mixer_get_recsrc, METH_VARARGS },
40db78159177 Rename more mixer methods: getrecsrc() -> get_recsrc(),
Greg Ward <gward@python.net>
parents: 26840
diff changeset
800 { "set_recsrc", (PyCFunction)oss_mixer_set_recsrc, METH_VARARGS },
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
801
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
802 { NULL, NULL}
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
803 };
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
804
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
805 static PyObject *
26921
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
806 oss_getattr(oss_audio_t *self, char *name)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
807 {
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
808 PyObject * rval = NULL;
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
809 if (strcmp(name, "closed") == 0) {
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
810 rval = (self->fd == -1) ? Py_True : Py_False;
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
811 Py_INCREF(rval);
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
812 }
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
813 else if (strcmp(name, "name") == 0) {
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
814 rval = PyString_FromString(self->devicename);
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
815 }
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
816 else if (strcmp(name, "mode") == 0) {
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
817 /* No need for a "default" in this switch: from newossobject(),
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
818 self->mode can only be one of these three values. */
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
819 switch(self->mode) {
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
820 case O_RDONLY:
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
821 rval = PyString_FromString("r");
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
822 break;
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
823 case O_RDWR:
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
824 rval = PyString_FromString("rw");
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
825 break;
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
826 case O_WRONLY:
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
827 rval = PyString_FromString("w");
34700
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
828 break;
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
829 }
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
830 }
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
831 else {
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
832 rval = Py_FindMethod(oss_methods, (PyObject *)self, name);
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
833 }
84859b4a62c6 SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents: 32044
diff changeset
834 return rval;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
835 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
836
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
837 static PyObject *
26921
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
838 oss_mixer_getattr(oss_mixer_t *self, char *name)
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
839 {
26921
faf965d73824 Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents: 26920
diff changeset
840 return Py_FindMethod(oss_mixer_methods, (PyObject *)self, name);
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
841 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
842
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
843 static PyTypeObject OSSAudioType = {
42334
e70cdce0e8b2 Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 39992
diff changeset
844 PyVarObject_HEAD_INIT(&PyType_Type, 0)
26481
b268a6e859cb Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now!
Greg Ward <gward@python.net>
parents: 26480
diff changeset
845 "ossaudiodev.oss_audio_device", /*tp_name*/
26920
42f19a6c6570 For symmetry with the mixer interface, rename oss_t to oss_audio_t and
Greg Ward <gward@python.net>
parents: 26919
diff changeset
846 sizeof(oss_audio_t), /*tp_size*/
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
847 0, /*tp_itemsize*/
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
848 /* methods */
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
849 (destructor)oss_dealloc, /*tp_dealloc*/
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
850 0, /*tp_print*/
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
851 (getattrfunc)oss_getattr, /*tp_getattr*/
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
852 0, /*tp_setattr*/
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
853 0, /*tp_compare*/
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
854 0, /*tp_repr*/
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
855 };
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
856
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
857 static PyTypeObject OSSMixerType = {
42334
e70cdce0e8b2 Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 39992
diff changeset
858 PyVarObject_HEAD_INIT(&PyType_Type, 0)
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
859 "ossaudiodev.oss_mixer_device", /*tp_name*/
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
860 sizeof(oss_mixer_t), /*tp_size*/
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
861 0, /*tp_itemsize*/
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
862 /* methods */
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
863 (destructor)oss_mixer_dealloc, /*tp_dealloc*/
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
864 0, /*tp_print*/
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
865 (getattrfunc)oss_mixer_getattr, /*tp_getattr*/
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
866 0, /*tp_setattr*/
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
867 0, /*tp_compare*/
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
868 0, /*tp_repr*/
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
869 };
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
870
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
871
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
872 static PyObject *
26481
b268a6e859cb Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now!
Greg Ward <gward@python.net>
parents: 26480
diff changeset
873 ossopen(PyObject *self, PyObject *args)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
874 {
26602
c163ed17f8ba Finish expunging the 'linuxaudiodev' name:
Greg Ward <gward@python.net>
parents: 26481
diff changeset
875 return (PyObject *)newossobject(args);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
876 }
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
877
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
878 static PyObject *
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
879 ossopenmixer(PyObject *self, PyObject *args)
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
880 {
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
881 return (PyObject *)newossmixerobject(args);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
882 }
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
883
26481
b268a6e859cb Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now!
Greg Ward <gward@python.net>
parents: 26480
diff changeset
884 static PyMethodDef ossaudiodev_methods[] = {
b268a6e859cb Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now!
Greg Ward <gward@python.net>
parents: 26480
diff changeset
885 { "open", ossopen, METH_VARARGS },
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
886 { "openmixer", ossopenmixer, METH_VARARGS },
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
887 { 0, 0 },
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
888 };
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
889
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
890
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
891 #define _EXPORT_INT(mod, name) \
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
892 if (PyModule_AddIntConstant(mod, #name, (long) (name)) == -1) return;
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
893
26922
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
894
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
895 static char *control_labels[] = SOUND_DEVICE_LABELS;
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
896 static char *control_names[] = SOUND_DEVICE_NAMES;
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
897
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
898
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
899 static int
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
900 build_namelists (PyObject *module)
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
901 {
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
902 PyObject *labels;
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
903 PyObject *names;
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
904 PyObject *s;
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
905 int num_controls;
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
906 int i;
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
907
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
908 num_controls = sizeof(control_labels) / sizeof(control_labels[0]);
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
909 assert(num_controls == sizeof(control_names) / sizeof(control_names[0]));
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
910
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
911 labels = PyList_New(num_controls);
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
912 names = PyList_New(num_controls);
37067
1f4549865aad Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents: 36785
diff changeset
913 if (labels == NULL || names == NULL)
1f4549865aad Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents: 36785
diff changeset
914 goto error2;
26922
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
915 for (i = 0; i < num_controls; i++) {
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
916 s = PyString_FromString(control_labels[i]);
26922
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
917 if (s == NULL)
37067
1f4549865aad Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents: 36785
diff changeset
918 goto error2;
26922
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
919 PyList_SET_ITEM(labels, i, s);
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
920
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
921 s = PyString_FromString(control_names[i]);
26922
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
922 if (s == NULL)
37067
1f4549865aad Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents: 36785
diff changeset
923 goto error2;
26922
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
924 PyList_SET_ITEM(names, i, s);
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
925 }
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
926
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
927 if (PyModule_AddObject(module, "control_labels", labels) == -1)
37067
1f4549865aad Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents: 36785
diff changeset
928 goto error2;
26922
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
929 if (PyModule_AddObject(module, "control_names", names) == -1)
37067
1f4549865aad Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents: 36785
diff changeset
930 goto error1;
26922
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
931
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
932 return 0;
37067
1f4549865aad Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents: 36785
diff changeset
933
1f4549865aad Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents: 36785
diff changeset
934 error2:
1f4549865aad Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents: 36785
diff changeset
935 Py_XDECREF(labels);
1f4549865aad Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents: 36785
diff changeset
936 error1:
1f4549865aad Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents: 36785
diff changeset
937 Py_XDECREF(names);
1f4549865aad Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents: 36785
diff changeset
938 return -1;
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
939 }
26922
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
940
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
941
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
942 void
26481
b268a6e859cb Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now!
Greg Ward <gward@python.net>
parents: 26480
diff changeset
943 initossaudiodev(void)
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
944 {
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
945 PyObject *m;
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
946
26481
b268a6e859cb Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now!
Greg Ward <gward@python.net>
parents: 26480
diff changeset
947 m = Py_InitModule("ossaudiodev", ossaudiodev_methods);
36324
1af7f719ed28 Check return result from Py_InitModule*(). This API can fail.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36221
diff changeset
948 if (m == NULL)
1af7f719ed28 Check return result from Py_InitModule*(). This API can fail.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36221
diff changeset
949 return;
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
950
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
951 OSSAudioError = PyErr_NewException("ossaudiodev.OSSAudioError",
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
952 NULL, NULL);
29324
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
953 if (OSSAudioError) {
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
954 /* Each call to PyModule_AddObject decrefs it; compensate: */
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
955 Py_INCREF(OSSAudioError);
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
956 Py_INCREF(OSSAudioError);
26840
786798e86469 Untabify.
Greg Ward <gward@python.net>
parents: 26839
diff changeset
957 PyModule_AddObject(m, "error", OSSAudioError);
29324
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
958 PyModule_AddObject(m, "OSSAudioError", OSSAudioError);
008cd101269d Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents: 29274
diff changeset
959 }
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
960
26922
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
961 /* Build 'control_labels' and 'control_names' lists and add them
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
962 to the module. */
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
963 if (build_namelists(m) == -1) /* XXX what to do here? */
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
964 return;
9d0580acb45f Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents: 26921
diff changeset
965
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
966 /* Expose the audio format numbers -- essential! */
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
967 _EXPORT_INT(m, AFMT_QUERY);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
968 _EXPORT_INT(m, AFMT_MU_LAW);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
969 _EXPORT_INT(m, AFMT_A_LAW);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
970 _EXPORT_INT(m, AFMT_IMA_ADPCM);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
971 _EXPORT_INT(m, AFMT_U8);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
972 _EXPORT_INT(m, AFMT_S16_LE);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
973 _EXPORT_INT(m, AFMT_S16_BE);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
974 _EXPORT_INT(m, AFMT_S8);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
975 _EXPORT_INT(m, AFMT_U16_LE);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
976 _EXPORT_INT(m, AFMT_U16_BE);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
977 _EXPORT_INT(m, AFMT_MPEG);
27863
d19661e198f7 Conditionalize another constant
Andrew M. Kuchling <amk@amk.ca>
parents: 27598
diff changeset
978 #ifdef AFMT_AC3
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
979 _EXPORT_INT(m, AFMT_AC3);
27863
d19661e198f7 Conditionalize another constant
Andrew M. Kuchling <amk@amk.ca>
parents: 27598
diff changeset
980 #endif
27598
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
981 #ifdef AFMT_S16_NE
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
982 _EXPORT_INT(m, AFMT_S16_NE);
27598
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
983 #endif
34821
47c5803aab45 Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents: 34700
diff changeset
984 #ifdef AFMT_U16_NE
47c5803aab45 Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents: 34700
diff changeset
985 _EXPORT_INT(m, AFMT_U16_NE);
47c5803aab45 Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents: 34700
diff changeset
986 #endif
47c5803aab45 Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents: 34700
diff changeset
987 #ifdef AFMT_S32_LE
47c5803aab45 Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents: 34700
diff changeset
988 _EXPORT_INT(m, AFMT_S32_LE);
47c5803aab45 Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents: 34700
diff changeset
989 #endif
47c5803aab45 Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents: 34700
diff changeset
990 #ifdef AFMT_S32_BE
47c5803aab45 Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents: 34700
diff changeset
991 _EXPORT_INT(m, AFMT_S32_BE);
47c5803aab45 Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents: 34700
diff changeset
992 #endif
47c5803aab45 Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents: 34700
diff changeset
993 #ifdef AFMT_MPEG
47c5803aab45 Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents: 34700
diff changeset
994 _EXPORT_INT(m, AFMT_MPEG);
47c5803aab45 Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents: 34700
diff changeset
995 #endif
29356
a369336224dd Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents: 29355
diff changeset
996
26836
79c9a07b2896 Rename some mixer methods:
Greg Ward <gward@python.net>
parents: 26835
diff changeset
997 /* Expose the sound mixer device numbers. */
26835
5ccde8a1526a Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents: 26615
diff changeset
998 _EXPORT_INT(m, SOUND_MIXER_NRDEVICES);
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
999 _EXPORT_INT(m, SOUND_MIXER_VOLUME);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1000 _EXPORT_INT(m, SOUND_MIXER_BASS);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1001 _EXPORT_INT(m, SOUND_MIXER_TREBLE);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1002 _EXPORT_INT(m, SOUND_MIXER_SYNTH);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1003 _EXPORT_INT(m, SOUND_MIXER_PCM);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1004 _EXPORT_INT(m, SOUND_MIXER_SPEAKER);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1005 _EXPORT_INT(m, SOUND_MIXER_LINE);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1006 _EXPORT_INT(m, SOUND_MIXER_MIC);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1007 _EXPORT_INT(m, SOUND_MIXER_CD);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1008 _EXPORT_INT(m, SOUND_MIXER_IMIX);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1009 _EXPORT_INT(m, SOUND_MIXER_ALTPCM);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1010 _EXPORT_INT(m, SOUND_MIXER_RECLEV);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1011 _EXPORT_INT(m, SOUND_MIXER_IGAIN);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1012 _EXPORT_INT(m, SOUND_MIXER_OGAIN);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1013 _EXPORT_INT(m, SOUND_MIXER_LINE1);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1014 _EXPORT_INT(m, SOUND_MIXER_LINE2);
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1015 _EXPORT_INT(m, SOUND_MIXER_LINE3);
32044
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1016 #ifdef SOUND_MIXER_DIGITAL1
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1017 _EXPORT_INT(m, SOUND_MIXER_DIGITAL1);
32044
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1018 #endif
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1019 #ifdef SOUND_MIXER_DIGITAL2
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1020 _EXPORT_INT(m, SOUND_MIXER_DIGITAL2);
32044
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1021 #endif
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1022 #ifdef SOUND_MIXER_DIGITAL3
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1023 _EXPORT_INT(m, SOUND_MIXER_DIGITAL3);
32044
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1024 #endif
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1025 #ifdef SOUND_MIXER_PHONEIN
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1026 _EXPORT_INT(m, SOUND_MIXER_PHONEIN);
32044
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1027 #endif
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1028 #ifdef SOUND_MIXER_PHONEOUT
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1029 _EXPORT_INT(m, SOUND_MIXER_PHONEOUT);
32044
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1030 #endif
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1031 #ifdef SOUND_MIXER_VIDEO
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1032 _EXPORT_INT(m, SOUND_MIXER_VIDEO);
32044
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1033 #endif
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1034 #ifdef SOUND_MIXER_RADIO
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1035 _EXPORT_INT(m, SOUND_MIXER_RADIO);
32044
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1036 #endif
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1037 #ifdef SOUND_MIXER_MONITOR
26605
378ce020d9e6 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents: 26603
diff changeset
1038 _EXPORT_INT(m, SOUND_MIXER_MONITOR);
32044
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1039 #endif
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
1040
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1041 /* Expose all the ioctl numbers for masochists who like to do this
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1042 stuff directly. */
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1043 _EXPORT_INT(m, SNDCTL_COPR_HALT);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1044 _EXPORT_INT(m, SNDCTL_COPR_LOAD);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1045 _EXPORT_INT(m, SNDCTL_COPR_RCODE);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1046 _EXPORT_INT(m, SNDCTL_COPR_RCVMSG);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1047 _EXPORT_INT(m, SNDCTL_COPR_RDATA);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1048 _EXPORT_INT(m, SNDCTL_COPR_RESET);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1049 _EXPORT_INT(m, SNDCTL_COPR_RUN);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1050 _EXPORT_INT(m, SNDCTL_COPR_SENDMSG);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1051 _EXPORT_INT(m, SNDCTL_COPR_WCODE);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1052 _EXPORT_INT(m, SNDCTL_COPR_WDATA);
27598
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
1053 #ifdef SNDCTL_DSP_BIND_CHANNEL
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1054 _EXPORT_INT(m, SNDCTL_DSP_BIND_CHANNEL);
27598
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
1055 #endif
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1056 _EXPORT_INT(m, SNDCTL_DSP_CHANNELS);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1057 _EXPORT_INT(m, SNDCTL_DSP_GETBLKSIZE);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1058 _EXPORT_INT(m, SNDCTL_DSP_GETCAPS);
27598
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
1059 #ifdef SNDCTL_DSP_GETCHANNELMASK
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1060 _EXPORT_INT(m, SNDCTL_DSP_GETCHANNELMASK);
27598
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
1061 #endif
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1062 _EXPORT_INT(m, SNDCTL_DSP_GETFMTS);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1063 _EXPORT_INT(m, SNDCTL_DSP_GETIPTR);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1064 _EXPORT_INT(m, SNDCTL_DSP_GETISPACE);
32044
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1065 #ifdef SNDCTL_DSP_GETODELAY
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1066 _EXPORT_INT(m, SNDCTL_DSP_GETODELAY);
32044
9f6d45f3c023 SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents: 29356
diff changeset
1067 #endif
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1068 _EXPORT_INT(m, SNDCTL_DSP_GETOPTR);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1069 _EXPORT_INT(m, SNDCTL_DSP_GETOSPACE);
27210
428eecdfd57f Get build working on Redhat 7.2 linux 2.4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 26922
diff changeset
1070 #ifdef SNDCTL_DSP_GETSPDIF
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1071 _EXPORT_INT(m, SNDCTL_DSP_GETSPDIF);
27210
428eecdfd57f Get build working on Redhat 7.2 linux 2.4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 26922
diff changeset
1072 #endif
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1073 _EXPORT_INT(m, SNDCTL_DSP_GETTRIGGER);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1074 _EXPORT_INT(m, SNDCTL_DSP_MAPINBUF);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1075 _EXPORT_INT(m, SNDCTL_DSP_MAPOUTBUF);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1076 _EXPORT_INT(m, SNDCTL_DSP_NONBLOCK);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1077 _EXPORT_INT(m, SNDCTL_DSP_POST);
27598
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
1078 #ifdef SNDCTL_DSP_PROFILE
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1079 _EXPORT_INT(m, SNDCTL_DSP_PROFILE);
27598
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
1080 #endif
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1081 _EXPORT_INT(m, SNDCTL_DSP_RESET);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1082 _EXPORT_INT(m, SNDCTL_DSP_SAMPLESIZE);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1083 _EXPORT_INT(m, SNDCTL_DSP_SETDUPLEX);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1084 _EXPORT_INT(m, SNDCTL_DSP_SETFMT);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1085 _EXPORT_INT(m, SNDCTL_DSP_SETFRAGMENT);
27210
428eecdfd57f Get build working on Redhat 7.2 linux 2.4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 26922
diff changeset
1086 #ifdef SNDCTL_DSP_SETSPDIF
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1087 _EXPORT_INT(m, SNDCTL_DSP_SETSPDIF);
27210
428eecdfd57f Get build working on Redhat 7.2 linux 2.4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 26922
diff changeset
1088 #endif
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1089 _EXPORT_INT(m, SNDCTL_DSP_SETSYNCRO);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1090 _EXPORT_INT(m, SNDCTL_DSP_SETTRIGGER);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1091 _EXPORT_INT(m, SNDCTL_DSP_SPEED);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1092 _EXPORT_INT(m, SNDCTL_DSP_STEREO);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1093 _EXPORT_INT(m, SNDCTL_DSP_SUBDIVIDE);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1094 _EXPORT_INT(m, SNDCTL_DSP_SYNC);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1095 _EXPORT_INT(m, SNDCTL_FM_4OP_ENABLE);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1096 _EXPORT_INT(m, SNDCTL_FM_LOAD_INSTR);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1097 _EXPORT_INT(m, SNDCTL_MIDI_INFO);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1098 _EXPORT_INT(m, SNDCTL_MIDI_MPUCMD);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1099 _EXPORT_INT(m, SNDCTL_MIDI_MPUMODE);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1100 _EXPORT_INT(m, SNDCTL_MIDI_PRETIME);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1101 _EXPORT_INT(m, SNDCTL_SEQ_CTRLRATE);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1102 _EXPORT_INT(m, SNDCTL_SEQ_GETINCOUNT);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1103 _EXPORT_INT(m, SNDCTL_SEQ_GETOUTCOUNT);
27598
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
1104 #ifdef SNDCTL_SEQ_GETTIME
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1105 _EXPORT_INT(m, SNDCTL_SEQ_GETTIME);
27598
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
1106 #endif
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1107 _EXPORT_INT(m, SNDCTL_SEQ_NRMIDIS);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1108 _EXPORT_INT(m, SNDCTL_SEQ_NRSYNTHS);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1109 _EXPORT_INT(m, SNDCTL_SEQ_OUTOFBAND);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1110 _EXPORT_INT(m, SNDCTL_SEQ_PANIC);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1111 _EXPORT_INT(m, SNDCTL_SEQ_PERCMODE);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1112 _EXPORT_INT(m, SNDCTL_SEQ_RESET);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1113 _EXPORT_INT(m, SNDCTL_SEQ_RESETSAMPLES);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1114 _EXPORT_INT(m, SNDCTL_SEQ_SYNC);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1115 _EXPORT_INT(m, SNDCTL_SEQ_TESTMIDI);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1116 _EXPORT_INT(m, SNDCTL_SEQ_THRESHOLD);
27598
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
1117 #ifdef SNDCTL_SYNTH_CONTROL
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1118 _EXPORT_INT(m, SNDCTL_SYNTH_CONTROL);
27598
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
1119 #endif
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
1120 #ifdef SNDCTL_SYNTH_ID
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1121 _EXPORT_INT(m, SNDCTL_SYNTH_ID);
27598
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
1122 #endif
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1123 _EXPORT_INT(m, SNDCTL_SYNTH_INFO);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1124 _EXPORT_INT(m, SNDCTL_SYNTH_MEMAVL);
27598
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
1125 #ifdef SNDCTL_SYNTH_REMOVESAMPLE
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1126 _EXPORT_INT(m, SNDCTL_SYNTH_REMOVESAMPLE);
27598
a35dfca93318 Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents: 27210
diff changeset
1127 #endif
26479
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1128 _EXPORT_INT(m, SNDCTL_TMR_CONTINUE);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1129 _EXPORT_INT(m, SNDCTL_TMR_METRONOME);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1130 _EXPORT_INT(m, SNDCTL_TMR_SELECT);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1131 _EXPORT_INT(m, SNDCTL_TMR_SOURCE);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1132 _EXPORT_INT(m, SNDCTL_TMR_START);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1133 _EXPORT_INT(m, SNDCTL_TMR_STOP);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1134 _EXPORT_INT(m, SNDCTL_TMR_TEMPO);
d1b4e7016d88 Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents: 26478
diff changeset
1135 _EXPORT_INT(m, SNDCTL_TMR_TIMEBASE);
26477
e07948d5cf67 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff changeset
1136 }