Mercurial > cpython-lru_cache-weakref
annotate Modules/ossaudiodev.c @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | dec00ae64ca8 |
| children | e145dddb9d93 |
| 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 | 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 | 106 /* Open the correct device: either the 'device' argument, |
| 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) { |
|
72530
dec00ae64ca8
Issue #13058: ossaudiodev: fix a file descriptor leak on error. Patch by Thomas
Charles-François Natali <neologix@free.fr>
parents:
72113
diff
changeset
|
132 close(fd); |
|
34700
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
133 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
|
134 return NULL; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
135 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
136 /* 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
|
137 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
|
138 close(fd); |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
139 return NULL; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
140 } |
|
34700
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
141 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
|
142 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
|
143 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
|
144 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
|
145 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
|
146 return self; |
|
26477
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 |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
149 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
|
150 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
|
151 { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
152 /* 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
|
153 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
|
154 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
|
155 PyObject_Del(self); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
156 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
157 |
|
26919
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 /* ---------------------------------------------------------------------- |
|
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
160 * 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
|
161 */ |
|
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
162 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
163 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
|
164 newossmixerobject(PyObject *arg) |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
165 { |
|
34700
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
166 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
|
167 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
|
168 oss_mixer_t *self; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
169 |
|
34700
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
170 if (!PyArg_ParseTuple(arg, "|s", &devicename)) { |
| 26840 | 171 return NULL; |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
172 } |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
173 |
|
34700
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
174 if (devicename == NULL) { |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
175 devicename = getenv("MIXERDEV"); |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
176 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
|
177 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
|
178 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
179 |
|
34700
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
180 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
|
181 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
|
182 return NULL; |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
183 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
184 |
|
26921
faf965d73824
Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents:
26920
diff
changeset
|
185 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
|
186 close(fd); |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
187 return NULL; |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
188 } |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
189 |
|
26921
faf965d73824
Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents:
26920
diff
changeset
|
190 self->fd = fd; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
191 |
|
26921
faf965d73824
Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents:
26920
diff
changeset
|
192 return self; |
|
26605
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 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
195 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
|
196 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
|
197 { |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
198 /* 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
|
199 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
|
200 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
|
201 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
|
202 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
203 |
|
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
|
204 |
|
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 /* 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
|
206 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
|
207 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
|
208 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
|
209 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
|
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 |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
212 |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
213 /* ---------------------------------------------------------------------- |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
214 * Helper functions |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
215 */ |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
216 |
|
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
|
217 /* _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
|
218 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
|
219 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
|
220 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
|
221 |
|
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 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
|
223 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
|
224 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
|
225 */ |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
226 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
|
227 _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
|
228 { |
|
26603
bfb2664cdb1b
Prepare for the coming mixer support patch: change _do_ioctl_0() and
Greg Ward <gward@python.net>
parents:
26602
diff
changeset
|
229 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
|
230 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
|
231 |
|
26603
bfb2664cdb1b
Prepare for the coming mixer support patch: change _do_ioctl_0() and
Greg Ward <gward@python.net>
parents:
26602
diff
changeset
|
232 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
|
233 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
|
234 if (!PyArg_ParseTuple(args, argfmt, &arg)) |
| 26840 | 235 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
|
236 |
|
26603
bfb2664cdb1b
Prepare for the coming mixer support patch: change _do_ioctl_0() and
Greg Ward <gward@python.net>
parents:
26602
diff
changeset
|
237 if (ioctl(fd, cmd, &arg) == -1) |
|
26480
7ba072db3828
Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents:
26479
diff
changeset
|
238 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
|
239 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
|
240 } |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
241 |
|
26919
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
242 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
243 /* _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
|
244 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
|
245 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
|
246 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
|
247 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
|
248 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
|
249 way. |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
250 */ |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
251 static PyObject * |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
252 _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
|
253 { |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
254 char argfmt[32] = ":"; |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
255 int arg = 0; |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
256 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
257 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
|
258 strcat(argfmt, fname); |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
259 if (!PyArg_ParseTuple(args, argfmt, &arg)) |
| 26840 | 260 return NULL; |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
261 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
262 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
|
263 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
|
264 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
|
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 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
268 |
|
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
|
269 /* _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
|
270 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
|
271 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
|
272 _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
|
273 { |
|
26603
bfb2664cdb1b
Prepare for the coming mixer support patch: change _do_ioctl_0() and
Greg Ward <gward@python.net>
parents:
26602
diff
changeset
|
274 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
|
275 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
|
276 |
|
26603
bfb2664cdb1b
Prepare for the coming mixer support patch: change _do_ioctl_0() and
Greg Ward <gward@python.net>
parents:
26602
diff
changeset
|
277 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
|
278 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
|
279 if (!PyArg_ParseTuple(args, argfmt)) |
| 26840 | 280 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
|
281 |
|
29274
df80a5b6957b
Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
Greg Ward <gward@python.net>
parents:
29272
diff
changeset
|
282 /* 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
|
283 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
|
284 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
|
285 seconds. */ |
|
df80a5b6957b
Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
Greg Ward <gward@python.net>
parents:
29272
diff
changeset
|
286 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
|
287 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
|
288 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
|
289 |
|
df80a5b6957b
Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
Greg Ward <gward@python.net>
parents:
29272
diff
changeset
|
290 if (rv == -1) |
|
26480
7ba072db3828
Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents:
26479
diff
changeset
|
291 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
|
292 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
|
293 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
|
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 |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
296 |
|
26919
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
297 /* ---------------------------------------------------------------------- |
|
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
|
298 * 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
|
299 */ |
|
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
300 |
|
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
|
301 static PyObject * |
|
38489
3fe3ccdf0155
Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents:
37067
diff
changeset
|
302 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
|
303 { |
|
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 /* 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
|
305 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
|
306 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
|
307 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
|
308 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
|
309 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
|
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 |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
312 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
|
313 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
|
314 { |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
315 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
|
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 |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
318 static PyObject * |
|
38489
3fe3ccdf0155
Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents:
37067
diff
changeset
|
319 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
|
320 { |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
321 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
|
322 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
|
323 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
|
324 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
|
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 |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
327 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
|
328 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
|
329 { |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
330 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
|
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 |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
333 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
|
334 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
|
335 { |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
336 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
|
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 |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
339 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
|
340 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
|
341 { |
|
29274
df80a5b6957b
Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
Greg Ward <gward@python.net>
parents:
29272
diff
changeset
|
342 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
|
343 } |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
344 |
|
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
|
345 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
|
346 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
|
347 { |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
348 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
|
349 } |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
350 |
|
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
|
351 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
|
352 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
|
353 { |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
354 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
|
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 |
|
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 /* 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
|
359 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
|
360 |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
361 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
|
362 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
|
363 { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
364 int size, count; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
365 char *cp; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
366 PyObject *rv; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
367 |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
368 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
|
369 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
|
370 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
|
371 if (rv == NULL) |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
372 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
|
373 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
|
374 |
|
752fc5ea16b9
Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents:
28500
diff
changeset
|
375 Py_BEGIN_ALLOW_THREADS |
|
752fc5ea16b9
Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents:
28500
diff
changeset
|
376 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
|
377 Py_END_ALLOW_THREADS |
|
752fc5ea16b9
Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents:
28500
diff
changeset
|
378 |
|
752fc5ea16b9
Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents:
28500
diff
changeset
|
379 if (count < 0) { |
|
26480
7ba072db3828
Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents:
26479
diff
changeset
|
380 PyErr_SetFromErrno(PyExc_IOError); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
381 Py_DECREF(rv); |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
382 return NULL; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
383 } |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
384 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
|
385 _PyString_Resize(&rv, count); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
386 return rv; |
|
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 |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
389 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
|
390 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
|
391 { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
392 char *cp; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
393 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
|
394 |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
395 if (!PyArg_ParseTuple(args, "s#:write", &cp, &size)) { |
| 26840 | 396 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
|
397 } |
|
29238
752fc5ea16b9
Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents:
28500
diff
changeset
|
398 |
|
752fc5ea16b9
Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents:
28500
diff
changeset
|
399 Py_BEGIN_ALLOW_THREADS |
|
752fc5ea16b9
Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents:
28500
diff
changeset
|
400 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
|
401 Py_END_ALLOW_THREADS |
|
752fc5ea16b9
Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents:
28500
diff
changeset
|
402 |
|
752fc5ea16b9
Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents:
28500
diff
changeset
|
403 if (rv == -1) { |
|
26480
7ba072db3828
Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents:
26479
diff
changeset
|
404 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
|
405 } else { |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
406 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
|
407 } |
|
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 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
|
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 |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
411 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
|
412 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
|
413 { |
|
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 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
|
415 int rv, size; |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
416 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
|
417 int select_rv; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
418 |
|
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
|
419 /* 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
|
420 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
|
421 (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
|
422 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
|
423 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
|
424 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
|
425 |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
426 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
|
427 return NULL; |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
428 |
|
72113
ff6adb867f40
Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is
Charles-François Natali <neologix@free.fr>
parents:
47527
diff
changeset
|
429 if (!_PyIsSelectable_fd(self->fd)) { |
|
ff6adb867f40
Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is
Charles-François Natali <neologix@free.fr>
parents:
47527
diff
changeset
|
430 PyErr_SetString(PyExc_ValueError, |
|
ff6adb867f40
Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is
Charles-François Natali <neologix@free.fr>
parents:
47527
diff
changeset
|
431 "file descriptor out of range for select"); |
|
ff6adb867f40
Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is
Charles-François Natali <neologix@free.fr>
parents:
47527
diff
changeset
|
432 return NULL; |
|
ff6adb867f40
Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is
Charles-François Natali <neologix@free.fr>
parents:
47527
diff
changeset
|
433 } |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
434 /* 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
|
435 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
|
436 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
|
437 |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
438 while (size > 0) { |
|
29238
752fc5ea16b9
Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents:
28500
diff
changeset
|
439 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
|
440 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
|
441 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
|
442 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
|
443 if (select_rv == -1) |
|
26480
7ba072db3828
Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents:
26479
diff
changeset
|
444 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
|
445 |
|
29238
752fc5ea16b9
Release the GIL around read(), write(), and select() calls.
Greg Ward <gward@python.net>
parents:
28500
diff
changeset
|
446 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
|
447 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
|
448 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
|
449 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
|
450 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
|
451 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
|
452 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
|
453 } else /* it's a real error */ |
|
26480
7ba072db3828
Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents:
26479
diff
changeset
|
454 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
|
455 } 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
|
456 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
|
457 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
|
458 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
|
459 } |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
460 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
461 Py_INCREF(Py_None); |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
462 return Py_None; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
463 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
464 |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
465 static PyObject * |
|
38489
3fe3ccdf0155
Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents:
37067
diff
changeset
|
466 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
|
467 { |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
468 if (self->fd >= 0) { |
|
29272
b7cd1ff0019b
Release the GIL in two more methods:
Greg Ward <gward@python.net>
parents:
29238
diff
changeset
|
469 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
|
470 close(self->fd); |
|
29272
b7cd1ff0019b
Release the GIL in two more methods:
Greg Ward <gward@python.net>
parents:
29238
diff
changeset
|
471 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
|
472 self->fd = -1; |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
473 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
474 Py_INCREF(Py_None); |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
475 return Py_None; |
|
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 |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
478 static PyObject * |
|
38489
3fe3ccdf0155
Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents:
37067
diff
changeset
|
479 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
|
480 { |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
481 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
|
482 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
483 |
|
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
|
484 |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
485 /* 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
|
486 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
|
487 |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
488 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
|
489 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
|
490 { |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
491 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
|
492 int fmt, channels, rate; |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
493 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
|
494 |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
495 if (!PyArg_ParseTuple(args, "iii|i:setparameters", |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
496 &wanted_fmt, &wanted_channels, &wanted_rate, |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
497 &strict)) |
| 26840 | 498 return NULL; |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
499 |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
500 fmt = wanted_fmt; |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
501 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
|
502 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
|
503 } |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
504 if (strict && fmt != wanted_fmt) { |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
505 return PyErr_Format |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
506 (OSSAudioError, |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
507 "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
|
508 wanted_fmt, fmt); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
509 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
510 |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
511 channels = wanted_channels; |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
512 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
|
513 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
|
514 } |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
515 if (strict && channels != wanted_channels) { |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
516 return PyErr_Format |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
517 (OSSAudioError, |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
518 "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
|
519 wanted_channels, channels); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
520 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
521 |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
522 rate = wanted_rate; |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
523 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
|
524 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
|
525 } |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
526 if (strict && rate != wanted_rate) { |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
527 return PyErr_Format |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
528 (OSSAudioError, |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
529 "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
|
530 wanted_rate, rate); |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
531 } |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
532 |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
533 /* 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
|
534 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
|
535 rv = PyTuple_New(3); |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
536 if (rv == NULL) |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
537 return NULL; |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
538 PyTuple_SET_ITEM(rv, 0, PyInt_FromLong(fmt)); |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
539 PyTuple_SET_ITEM(rv, 1, PyInt_FromLong(channels)); |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
540 PyTuple_SET_ITEM(rv, 2, PyInt_FromLong(rate)); |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
541 return rv; |
|
26477
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 |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
544 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
|
545 _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
|
546 { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
547 int fmt; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
548 |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
549 fmt = 0; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
550 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
|
551 return -errno; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
552 |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
553 switch (fmt) { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
554 case AFMT_MU_LAW: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
555 case AFMT_A_LAW: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
556 case AFMT_U8: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
557 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
|
558 *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
|
559 break; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
560 case AFMT_S16_LE: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
561 case AFMT_S16_BE: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
562 case AFMT_U16_LE: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
563 case AFMT_U16_BE: |
| 29327 | 564 *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
|
565 break; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
566 case AFMT_MPEG: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
567 case AFMT_IMA_ADPCM: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
568 default: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
569 return -EOPNOTSUPP; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
570 } |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
571 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
|
572 return -errno; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
573 return 0; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
574 } |
|
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 |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
577 /* 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
|
578 of samples */ |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
579 static PyObject * |
|
38489
3fe3ccdf0155
Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents:
37067
diff
changeset
|
580 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
|
581 { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
582 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
|
583 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
|
584 |
|
36785
6e285c69efc0
Rework channelnumber/samplesize detetion code's output variables a bit to
Thomas Wouters <thomas@python.org>
parents:
36324
diff
changeset
|
585 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
|
586 PyErr_SetFromErrno(PyExc_IOError); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
587 return NULL; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
588 } |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
589 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
|
590 PyErr_SetFromErrno(PyExc_IOError); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
591 return NULL; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
592 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
593 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
|
594 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
595 |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
596 /* 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
|
597 hardware for playing */ |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
598 static PyObject * |
|
38489
3fe3ccdf0155
Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents:
37067
diff
changeset
|
599 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
|
600 { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
601 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
|
602 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
|
603 |
|
36785
6e285c69efc0
Rework channelnumber/samplesize detetion code's output variables a bit to
Thomas Wouters <thomas@python.org>
parents:
36324
diff
changeset
|
604 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
|
605 PyErr_SetFromErrno(PyExc_IOError); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
606 return NULL; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
607 } |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
608 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
|
609 PyErr_SetFromErrno(PyExc_IOError); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
610 return NULL; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
611 } |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
612 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
|
613 (ssize * nchannels)); |
|
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 |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
616 /* 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
|
617 blocking */ |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
618 static PyObject * |
|
38489
3fe3ccdf0155
Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents:
37067
diff
changeset
|
619 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
|
620 { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
621 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
|
622 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
|
623 |
|
36785
6e285c69efc0
Rework channelnumber/samplesize detetion code's output variables a bit to
Thomas Wouters <thomas@python.org>
parents:
36324
diff
changeset
|
624 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
|
625 PyErr_SetFromErrno(PyExc_IOError); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
626 return NULL; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
627 } |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
628 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
|
629 PyErr_SetFromErrno(PyExc_IOError); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
630 return NULL; |
|
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 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
|
633 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
634 |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
635 static PyObject * |
|
38489
3fe3ccdf0155
Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents:
37067
diff
changeset
|
636 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
|
637 { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
638 count_info info; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
639 int req; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
640 |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
641 if (self->mode == O_RDONLY) |
| 26840 | 642 req = SNDCTL_DSP_GETIPTR; |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
643 else |
| 26840 | 644 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
|
645 if (ioctl(self->fd, req, &info) == -1) { |
|
26480
7ba072db3828
Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents:
26479
diff
changeset
|
646 PyErr_SetFromErrno(PyExc_IOError); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
647 return NULL; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
648 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
649 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
|
650 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
651 |
|
26919
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
652 |
|
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
653 /* ---------------------------------------------------------------------- |
|
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
654 * 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
|
655 */ |
|
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
656 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
657 static PyObject * |
|
38489
3fe3ccdf0155
Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents:
37067
diff
changeset
|
658 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
|
659 { |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
660 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
|
661 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
|
662 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
|
663 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
664 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
|
665 return Py_None; |
|
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 static PyObject * |
|
38489
3fe3ccdf0155
Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents:
37067
diff
changeset
|
669 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
|
670 { |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
671 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
|
672 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
673 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
674 /* 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
|
675 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
676 static PyObject * |
|
26918
05016bb91766
Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents:
26904
diff
changeset
|
677 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
|
678 { |
|
26918
05016bb91766
Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents:
26904
diff
changeset
|
679 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
|
680 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
|
681 } |
|
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 static PyObject * |
|
26918
05016bb91766
Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents:
26904
diff
changeset
|
684 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
|
685 { |
|
26918
05016bb91766
Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents:
26904
diff
changeset
|
686 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
|
687 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
|
688 } |
|
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 static PyObject * |
|
26918
05016bb91766
Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents:
26904
diff
changeset
|
691 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
|
692 { |
|
26918
05016bb91766
Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents:
26904
diff
changeset
|
693 return _do_ioctl_1_internal(self->fd, args, "reccontrols", |
| 26615 | 694 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
|
695 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
696 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
697 static PyObject * |
|
26839
c44d994b39e5
Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents:
26837
diff
changeset
|
698 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
|
699 { |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
700 int channel, volume; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
701 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
702 /* 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
|
703 if (!PyArg_ParseTuple(args, "i:get", &channel)) |
| 26840 | 704 return NULL; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
705 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
706 if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) { |
| 26840 | 707 PyErr_SetString(OSSAudioError, "Invalid mixer channel specified."); |
| 708 return NULL; | |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
709 } |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
710 |
|
26839
c44d994b39e5
Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents:
26837
diff
changeset
|
711 if (ioctl(self->fd, MIXER_READ(channel), &volume) == -1) |
| 26840 | 712 return PyErr_SetFromErrno(PyExc_IOError); |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
713 |
|
26839
c44d994b39e5
Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents:
26837
diff
changeset
|
714 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
|
715 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
716 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
717 static PyObject * |
|
26839
c44d994b39e5
Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents:
26837
diff
changeset
|
718 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
|
719 { |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
720 int channel, volume, leftVol, rightVol; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
721 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
722 /* 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
|
723 if (!PyArg_ParseTuple(args, "i(ii):set", &channel, &leftVol, &rightVol)) |
| 26840 | 724 return NULL; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
725 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
726 if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) { |
| 26840 | 727 PyErr_SetString(OSSAudioError, "Invalid mixer channel specified."); |
| 728 return NULL; | |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
729 } |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
730 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
731 if (leftVol < 0 || rightVol < 0 || leftVol > 100 || rightVol > 100) { |
| 26840 | 732 PyErr_SetString(OSSAudioError, "Volumes must be between 0 and 100."); |
| 733 return NULL; | |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
734 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
735 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
736 volume = (rightVol << 8) | leftVol; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
737 |
|
26839
c44d994b39e5
Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents:
26837
diff
changeset
|
738 if (ioctl(self->fd, MIXER_WRITE(channel), &volume) == -1) |
| 26840 | 739 return PyErr_SetFromErrno(PyExc_IOError); |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
740 |
|
26839
c44d994b39e5
Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents:
26837
diff
changeset
|
741 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
|
742 } |
|
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 static PyObject * |
|
26904
40db78159177
Rename more mixer methods: getrecsrc() -> get_recsrc(),
Greg Ward <gward@python.net>
parents:
26840
diff
changeset
|
745 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
|
746 { |
|
26904
40db78159177
Rename more mixer methods: getrecsrc() -> get_recsrc(),
Greg Ward <gward@python.net>
parents:
26840
diff
changeset
|
747 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
|
748 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
|
749 } |
|
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 static PyObject * |
|
26904
40db78159177
Rename more mixer methods: getrecsrc() -> get_recsrc(),
Greg Ward <gward@python.net>
parents:
26840
diff
changeset
|
752 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
|
753 { |
|
26904
40db78159177
Rename more mixer methods: getrecsrc() -> get_recsrc(),
Greg Ward <gward@python.net>
parents:
26840
diff
changeset
|
754 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
|
755 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
|
756 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
757 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
758 |
|
26919
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
759 /* ---------------------------------------------------------------------- |
|
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
760 * 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
|
761 */ |
|
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
762 |
|
26602
c163ed17f8ba
Finish expunging the 'linuxaudiodev' name:
Greg Ward <gward@python.net>
parents:
26481
diff
changeset
|
763 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
|
764 /* Regular file methods */ |
| 26840 | 765 { "read", (PyCFunction)oss_read, METH_VARARGS }, |
| 766 { "write", (PyCFunction)oss_write, METH_VARARGS }, | |
| 767 { "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
|
768 { "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
|
769 { "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
|
770 |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
771 /* Simple ioctl wrappers */ |
|
38489
3fe3ccdf0155
Make use of METH_O and METH_NOARGS where possible.
Georg Brandl <georg@python.org>
parents:
37067
diff
changeset
|
772 { "nonblock", (PyCFunction)oss_nonblock, METH_NOARGS }, |
| 26840 | 773 { "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
|
774 { "getfmts", (PyCFunction)oss_getfmts, METH_NOARGS }, |
|
26602
c163ed17f8ba
Finish expunging the 'linuxaudiodev' name:
Greg Ward <gward@python.net>
parents:
26481
diff
changeset
|
775 { "channels", (PyCFunction)oss_channels, METH_VARARGS }, |
|
c163ed17f8ba
Finish expunging the 'linuxaudiodev' name:
Greg Ward <gward@python.net>
parents:
26481
diff
changeset
|
776 { "speed", (PyCFunction)oss_speed, METH_VARARGS }, |
| 26840 | 777 { "sync", (PyCFunction)oss_sync, METH_VARARGS }, |
| 778 { "reset", (PyCFunction)oss_reset, METH_VARARGS }, | |
| 779 { "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
|
780 |
|
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 /* Convenience methods -- wrap a couple of ioctls together */ |
| 26840 | 782 { "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
|
783 { "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
|
784 { "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
|
785 { "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
|
786 { "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
|
787 |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
788 /* Aliases for backwards compatibility */ |
| 26840 | 789 { "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
|
790 |
| 26840 | 791 { NULL, NULL} /* sentinel */ |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
792 }; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
793 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
794 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
|
795 /* 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
|
796 { "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
|
797 { "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
|
798 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
799 /* Simple ioctl wrappers */ |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
800 { "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
|
801 { "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
|
802 { "reccontrols", (PyCFunction)oss_mixer_reccontrols, METH_VARARGS}, |
| 26840 | 803 { "get", (PyCFunction)oss_mixer_get, METH_VARARGS }, |
| 804 { "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
|
805 { "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
|
806 { "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
|
807 |
| 26840 | 808 { NULL, NULL} |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
809 }; |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
810 |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
811 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
|
812 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
|
813 { |
|
34700
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
814 PyObject * rval = NULL; |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
815 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
|
816 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
|
817 Py_INCREF(rval); |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
818 } |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
819 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
|
820 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
|
821 } |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
822 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
|
823 /* 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
|
824 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
|
825 switch(self->mode) { |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
826 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
|
827 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
|
828 break; |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
829 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
|
830 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
|
831 break; |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
832 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
|
833 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
|
834 break; |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
835 } |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
836 } |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
837 else { |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
838 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
|
839 } |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
840 return rval; |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
841 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
842 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
843 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
|
844 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
|
845 { |
|
26921
faf965d73824
Rename the parameter 'xp' in several methods to 'self', since that's
Greg Ward <gward@python.net>
parents:
26920
diff
changeset
|
846 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
|
847 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
848 |
|
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
|
849 static PyTypeObject OSSAudioType = { |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
39992
diff
changeset
|
850 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
|
851 "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
|
852 sizeof(oss_audio_t), /*tp_size*/ |
| 26840 | 853 0, /*tp_itemsize*/ |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
854 /* methods */ |
| 26840 | 855 (destructor)oss_dealloc, /*tp_dealloc*/ |
| 856 0, /*tp_print*/ | |
| 857 (getattrfunc)oss_getattr, /*tp_getattr*/ | |
| 858 0, /*tp_setattr*/ | |
| 859 0, /*tp_compare*/ | |
| 860 0, /*tp_repr*/ | |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
861 }; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
862 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
863 static PyTypeObject OSSMixerType = { |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
39992
diff
changeset
|
864 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
|
865 "ossaudiodev.oss_mixer_device", /*tp_name*/ |
| 26840 | 866 sizeof(oss_mixer_t), /*tp_size*/ |
| 867 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
|
868 /* methods */ |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
869 (destructor)oss_mixer_dealloc, /*tp_dealloc*/ |
| 26840 | 870 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
|
871 (getattrfunc)oss_mixer_getattr, /*tp_getattr*/ |
| 26840 | 872 0, /*tp_setattr*/ |
| 873 0, /*tp_compare*/ | |
| 874 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
|
875 }; |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
876 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
877 |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
878 static PyObject * |
|
26481
b268a6e859cb
Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now!
Greg Ward <gward@python.net>
parents:
26480
diff
changeset
|
879 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
|
880 { |
|
26602
c163ed17f8ba
Finish expunging the 'linuxaudiodev' name:
Greg Ward <gward@python.net>
parents:
26481
diff
changeset
|
881 return (PyObject *)newossobject(args); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
882 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
883 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
884 static PyObject * |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
885 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
|
886 { |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
887 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
|
888 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
889 |
|
26481
b268a6e859cb
Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now!
Greg Ward <gward@python.net>
parents:
26480
diff
changeset
|
890 static PyMethodDef ossaudiodev_methods[] = { |
|
b268a6e859cb
Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now!
Greg Ward <gward@python.net>
parents:
26480
diff
changeset
|
891 { "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
|
892 { "openmixer", ossopenmixer, METH_VARARGS }, |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
893 { 0, 0 }, |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
894 }; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
895 |
|
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
|
896 |
|
d1b4e7016d88
Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents:
26478
diff
changeset
|
897 #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
|
898 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
|
899 |
|
26922
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
900 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
901 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
|
902 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
|
903 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
904 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
905 static int |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
906 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
|
907 { |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
908 PyObject *labels; |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
909 PyObject *names; |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
910 PyObject *s; |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
911 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
|
912 int i; |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
913 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
914 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
|
915 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
|
916 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
917 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
|
918 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
|
919 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
|
920 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
|
921 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
|
922 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
|
923 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
|
924 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
|
925 PyList_SET_ITEM(labels, i, s); |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
926 |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
927 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
|
928 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
|
929 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
|
930 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
|
931 } |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
932 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
933 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
|
934 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
|
935 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
|
936 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
|
937 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
938 return 0; |
|
37067
1f4549865aad
Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents:
36785
diff
changeset
|
939 |
|
1f4549865aad
Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents:
36785
diff
changeset
|
940 error2: |
|
1f4549865aad
Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents:
36785
diff
changeset
|
941 Py_XDECREF(labels); |
|
1f4549865aad
Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents:
36785
diff
changeset
|
942 error1: |
|
1f4549865aad
Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents:
36785
diff
changeset
|
943 Py_XDECREF(names); |
|
1f4549865aad
Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
Georg Brandl <georg@python.org>
parents:
36785
diff
changeset
|
944 return -1; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
945 } |
|
26922
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
946 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
947 |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
948 void |
|
26481
b268a6e859cb
Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now!
Greg Ward <gward@python.net>
parents:
26480
diff
changeset
|
949 initossaudiodev(void) |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
950 { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
951 PyObject *m; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
952 |
|
26481
b268a6e859cb
Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now!
Greg Ward <gward@python.net>
parents:
26480
diff
changeset
|
953 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
|
954 if (m == NULL) |
|
1af7f719ed28
Check return result from Py_InitModule*(). This API can fail.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36221
diff
changeset
|
955 return; |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
956 |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
957 OSSAudioError = PyErr_NewException("ossaudiodev.OSSAudioError", |
|
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
958 NULL, NULL); |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
959 if (OSSAudioError) { |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
960 /* 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
|
961 Py_INCREF(OSSAudioError); |
|
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
962 Py_INCREF(OSSAudioError); |
| 26840 | 963 PyModule_AddObject(m, "error", OSSAudioError); |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
964 PyModule_AddObject(m, "OSSAudioError", OSSAudioError); |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
965 } |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
966 |
|
26922
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
967 /* 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
|
968 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
|
969 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
|
970 return; |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
971 |
|
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
|
972 /* 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
|
973 _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
|
974 _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
|
975 _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
|
976 _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
|
977 _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
|
978 _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
|
979 _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
|
980 _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
|
981 _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
|
982 _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
|
983 _EXPORT_INT(m, AFMT_MPEG); |
|
27863
d19661e198f7
Conditionalize another constant
Andrew M. Kuchling <amk@amk.ca>
parents:
27598
diff
changeset
|
984 #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
|
985 _EXPORT_INT(m, AFMT_AC3); |
|
27863
d19661e198f7
Conditionalize another constant
Andrew M. Kuchling <amk@amk.ca>
parents:
27598
diff
changeset
|
986 #endif |
|
27598
a35dfca93318
Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents:
27210
diff
changeset
|
987 #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
|
988 _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
|
989 #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
|
990 #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
|
991 _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
|
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_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
|
994 _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
|
995 #endif |
|
47c5803aab45
Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents:
34700
diff
changeset
|
996 #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
|
997 _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
|
998 #endif |
|
47c5803aab45
Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents:
34700
diff
changeset
|
999 #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
|
1000 _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
|
1001 #endif |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
1002 |
| 26836 | 1003 /* 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
|
1004 _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
|
1005 _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
|
1006 _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
|
1007 _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
|
1008 _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
|
1009 _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
|
1010 _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
|
1011 _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
|
1012 _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
|
1013 _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
|
1014 _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
|
1015 _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
|
1016 _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
|
1017 _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
|
1018 _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
|
1019 _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
|
1020 _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
|
1021 _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
|
1022 #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
|
1023 _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
|
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_DIGITAL2 |
|
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_DIGITAL2); |
|
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_DIGITAL3 |
|
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_DIGITAL3); |
|
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_PHONEIN |
|
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_PHONEIN); |
|
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_PHONEOUT |
|
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_PHONEOUT); |
|
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_VIDEO |
|
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_VIDEO); |
|
32044
9f6d45f3c023
SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents:
29356
diff
changeset
|
1039 #endif |
|
9f6d45f3c023
SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents:
29356
diff
changeset
|
1040 #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
|
1041 _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
|
1042 #endif |
|
9f6d45f3c023
SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents:
29356
diff
changeset
|
1043 #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
|
1044 _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
|
1045 #endif |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1046 |
|
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
|
1047 /* 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
|
1048 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
|
1049 _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
|
1050 _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
|
1051 _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
|
1052 _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
|
1053 _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
|
1054 _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
|
1055 _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
|
1056 _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
|
1057 _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
|
1058 _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
|
1059 #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
|
1060 _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
|
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_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
|
1063 _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
|
1064 _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
|
1065 #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
|
1066 _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
|
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_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
|
1069 _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
|
1070 _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
|
1071 #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
|
1072 _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
|
1073 #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
|
1074 _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
|
1075 _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
|
1076 #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
|
1077 _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
|
1078 #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
|
1079 _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
|
1080 _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
|
1081 _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
|
1082 _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
|
1083 _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
|
1084 #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
|
1085 _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
|
1086 #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
|
1087 _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
|
1088 _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
|
1089 _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
|
1090 _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
|
1091 _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
|
1092 #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
|
1093 _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
|
1094 #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
|
1095 _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
|
1096 _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
|
1097 _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
|
1098 _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
|
1099 _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
|
1100 _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
|
1101 _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
|
1102 _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
|
1103 _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
|
1104 _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
|
1105 _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
|
1106 _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
|
1107 _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
|
1108 _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
|
1109 _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
|
1110 #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
|
1111 _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
|
1112 #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
|
1113 _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
|
1114 _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
|
1115 _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
|
1116 _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
|
1117 _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
|
1118 _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
|
1119 _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
|
1120 _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
|
1121 _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
|
1122 _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
|
1123 #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
|
1124 _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
|
1125 #endif |
|
a35dfca93318
Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents:
27210
diff
changeset
|
1126 #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
|
1127 _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
|
1128 #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
|
1129 _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
|
1130 _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
|
1131 #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
|
1132 _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
|
1133 #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
|
1134 _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
|
1135 _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
|
1136 _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
|
1137 _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
|
1138 _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
|
1139 _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
|
1140 _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
|
1141 _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
|
1142 } |
