Mercurial > cpython-lru_cache-weakref
annotate Modules/ossaudiodev.c @ 78069:a8aa77458e12 3.2
Add c_size_t and c_ssize_t to the ctypes summary table.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Thu, 12 Jul 2012 20:31:50 +0200 |
| parents | 160b52c9e8b3 |
| children | e9ba9f21a828 d8dc24c4e83d |
| 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 |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
38669
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; |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
38669
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) { |
|
72531
160b52c9e8b3
Issue #13058: ossaudiodev: fix a file descriptor leak on error. Patch by Thomas
Charles-François Natali <neologix@free.fr>
parents:
72115
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); |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
42857
diff
changeset
|
239 return PyLong_FromLong(arg); |
|
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
|
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); |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
42857
diff
changeset
|
264 return PyLong_FromLong(arg); |
|
26605
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 * |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
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 * |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
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); |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
42857
diff
changeset
|
324 return PyLong_FromLong(mask); |
|
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
|
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; |
|
49057
8ffec372040e
fixes deferred/release blocker issue #3797: Fixed the dbm, marshal, mmap,
Gregory P. Smith <greg@mad-scientist.com>
parents:
48660
diff
changeset
|
370 rv = PyBytes_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; |
|
49057
8ffec372040e
fixes deferred/release blocker issue #3797: Fixed the dbm, marshal, mmap,
Gregory P. Smith <greg@mad-scientist.com>
parents:
48660
diff
changeset
|
373 cp = PyBytes_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; |
|
49057
8ffec372040e
fixes deferred/release blocker issue #3797: Fixed the dbm, marshal, mmap,
Gregory P. Smith <greg@mad-scientist.com>
parents:
48660
diff
changeset
|
385 _PyBytes_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 |
| 42857 | 395 if (!PyArg_ParseTuple(args, "y#: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 } |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
42857
diff
changeset
|
408 return PyLong_FromLong(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
|
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 |
| 42857 | 426 if (!PyArg_ParseTuple(args, "y#: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 |
|
72115
852ca32eb18d
Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is
Charles-François Natali <neologix@free.fr>
parents:
65628
diff
changeset
|
429 if (!_PyIsSelectable_fd(self->fd)) { |
|
852ca32eb18d
Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is
Charles-François Natali <neologix@free.fr>
parents:
65628
diff
changeset
|
430 PyErr_SetString(PyExc_ValueError, |
|
852ca32eb18d
Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is
Charles-François Natali <neologix@free.fr>
parents:
65628
diff
changeset
|
431 "file descriptor out of range for select"); |
|
852ca32eb18d
Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is
Charles-François Natali <neologix@free.fr>
parents:
65628
diff
changeset
|
432 return NULL; |
|
852ca32eb18d
Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is
Charles-François Natali <neologix@free.fr>
parents:
65628
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 * |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
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 * |
|
65628
cb6418f4d60b
These are true PyCFunctions, after adding the second argument to oss_self, no need to cast.
Georg Brandl <georg@python.org>
parents:
65622
diff
changeset
|
479 oss_self(PyObject *self, PyObject *unused) |
|
65607
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
480 { |
|
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
481 Py_INCREF(self); |
|
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
482 return self; |
|
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
483 } |
|
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
484 |
|
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
485 static PyObject * |
|
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
486 oss_exit(PyObject *self, PyObject *unused) |
|
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
487 { |
|
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
488 PyObject *ret = PyObject_CallMethod(self, "close", NULL); |
|
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
489 if (!ret) |
|
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
490 return NULL; |
|
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
491 Py_DECREF(ret); |
|
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
492 Py_RETURN_NONE; |
|
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
493 } |
|
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
494 |
|
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
495 static PyObject * |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
496 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
|
497 { |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
42857
diff
changeset
|
498 return PyLong_FromLong(self->fd); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
499 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
500 |
|
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
|
501 |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
502 /* 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
|
503 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
|
504 |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
505 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
|
506 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
|
507 { |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
508 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
|
509 int fmt, channels, rate; |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
510 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
|
511 |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
512 if (!PyArg_ParseTuple(args, "iii|i:setparameters", |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
513 &wanted_fmt, &wanted_channels, &wanted_rate, |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
514 &strict)) |
| 26840 | 515 return NULL; |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
516 |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
517 fmt = wanted_fmt; |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
518 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
|
519 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
|
520 } |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
521 if (strict && fmt != wanted_fmt) { |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
522 return PyErr_Format |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
523 (OSSAudioError, |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
524 "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
|
525 wanted_fmt, fmt); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
526 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
527 |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
528 channels = wanted_channels; |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
529 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
|
530 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
|
531 } |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
532 if (strict && channels != wanted_channels) { |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
533 return PyErr_Format |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
534 (OSSAudioError, |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
535 "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
|
536 wanted_channels, channels); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
537 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
538 |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
539 rate = wanted_rate; |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
540 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
|
541 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
|
542 } |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
543 if (strict && rate != wanted_rate) { |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
544 return PyErr_Format |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
545 (OSSAudioError, |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
546 "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
|
547 wanted_rate, rate); |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
548 } |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
549 |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
550 /* 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
|
551 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
|
552 rv = PyTuple_New(3); |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
553 if (rv == NULL) |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
554 return NULL; |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
42857
diff
changeset
|
555 PyTuple_SET_ITEM(rv, 0, PyLong_FromLong(fmt)); |
|
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
42857
diff
changeset
|
556 PyTuple_SET_ITEM(rv, 1, PyLong_FromLong(channels)); |
|
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
42857
diff
changeset
|
557 PyTuple_SET_ITEM(rv, 2, PyLong_FromLong(rate)); |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
558 return rv; |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
559 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
560 |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
561 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
|
562 _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
|
563 { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
564 int fmt; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
565 |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
566 fmt = 0; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
567 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
|
568 return -errno; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
569 |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
570 switch (fmt) { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
571 case AFMT_MU_LAW: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
572 case AFMT_A_LAW: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
573 case AFMT_U8: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
574 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
|
575 *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
|
576 break; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
577 case AFMT_S16_LE: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
578 case AFMT_S16_BE: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
579 case AFMT_U16_LE: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
580 case AFMT_U16_BE: |
| 29327 | 581 *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
|
582 break; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
583 case AFMT_MPEG: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
584 case AFMT_IMA_ADPCM: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
585 default: |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
586 return -EOPNOTSUPP; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
587 } |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
588 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
|
589 return -errno; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
590 return 0; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
591 } |
|
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 |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
594 /* 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
|
595 of samples */ |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
596 static PyObject * |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
597 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
|
598 { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
599 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
|
600 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
|
601 |
|
36785
6e285c69efc0
Rework channelnumber/samplesize detetion code's output variables a bit to
Thomas Wouters <thomas@python.org>
parents:
36324
diff
changeset
|
602 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
|
603 PyErr_SetFromErrno(PyExc_IOError); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
604 return NULL; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
605 } |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
606 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
|
607 PyErr_SetFromErrno(PyExc_IOError); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
608 return NULL; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
609 } |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
42857
diff
changeset
|
610 return PyLong_FromLong((ai.fragstotal * ai.fragsize) / (nchannels * ssize)); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
611 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
612 |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
613 /* 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
|
614 hardware for playing */ |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
615 static PyObject * |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
616 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
|
617 { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
618 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
|
619 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
|
620 |
|
36785
6e285c69efc0
Rework channelnumber/samplesize detetion code's output variables a bit to
Thomas Wouters <thomas@python.org>
parents:
36324
diff
changeset
|
621 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
|
622 PyErr_SetFromErrno(PyExc_IOError); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
623 return NULL; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
624 } |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
625 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
|
626 PyErr_SetFromErrno(PyExc_IOError); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
627 return NULL; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
628 } |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
42857
diff
changeset
|
629 return PyLong_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
|
630 (ssize * nchannels)); |
|
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 |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
633 /* 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
|
634 blocking */ |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
635 static PyObject * |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
636 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
|
637 { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
638 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
|
639 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
|
640 |
|
36785
6e285c69efc0
Rework channelnumber/samplesize detetion code's output variables a bit to
Thomas Wouters <thomas@python.org>
parents:
36324
diff
changeset
|
641 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
|
642 PyErr_SetFromErrno(PyExc_IOError); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
643 return NULL; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
644 } |
|
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, SNDCTL_DSP_GETOSPACE, &ai) < 0) { |
|
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 } |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
42857
diff
changeset
|
649 return PyLong_FromLong(ai.bytes / (ssize * nchannels)); |
|
26477
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 |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
652 static PyObject * |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
653 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
|
654 { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
655 count_info info; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
656 int req; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
657 |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
658 if (self->mode == O_RDONLY) |
| 26840 | 659 req = SNDCTL_DSP_GETIPTR; |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
660 else |
| 26840 | 661 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
|
662 if (ioctl(self->fd, req, &info) == -1) { |
|
26480
7ba072db3828
Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Greg Ward <gward@python.net>
parents:
26479
diff
changeset
|
663 PyErr_SetFromErrno(PyExc_IOError); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
664 return NULL; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
665 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
666 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
|
667 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
668 |
|
26919
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
669 |
|
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
670 /* ---------------------------------------------------------------------- |
|
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
671 * 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
|
672 */ |
|
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
673 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
674 static PyObject * |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
675 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
|
676 { |
|
26835
5ccde8a1526a
Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
Greg Ward <gward@python.net>
parents:
26615
diff
changeset
|
677 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
|
678 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
|
679 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
|
680 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
681 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
|
682 return Py_None; |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
683 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
684 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
685 static PyObject * |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
686 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
|
687 { |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
42857
diff
changeset
|
688 return PyLong_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
|
689 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
690 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
691 /* 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
|
692 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
693 static PyObject * |
|
26918
05016bb91766
Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents:
26904
diff
changeset
|
694 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
|
695 { |
|
26918
05016bb91766
Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents:
26904
diff
changeset
|
696 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
|
697 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
|
698 } |
|
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 static PyObject * |
|
26918
05016bb91766
Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents:
26904
diff
changeset
|
701 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
|
702 { |
|
26918
05016bb91766
Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents:
26904
diff
changeset
|
703 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
|
704 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
|
705 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
706 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
707 static PyObject * |
|
26918
05016bb91766
Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents:
26904
diff
changeset
|
708 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
|
709 { |
|
26918
05016bb91766
Yet another renaming of some mixer methods:
Greg Ward <gward@python.net>
parents:
26904
diff
changeset
|
710 return _do_ioctl_1_internal(self->fd, args, "reccontrols", |
| 26615 | 711 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
|
712 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
713 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
714 static PyObject * |
|
26839
c44d994b39e5
Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents:
26837
diff
changeset
|
715 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
|
716 { |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
717 int channel, volume; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
718 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
719 /* 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
|
720 if (!PyArg_ParseTuple(args, "i:get", &channel)) |
| 26840 | 721 return NULL; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
722 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
723 if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) { |
| 26840 | 724 PyErr_SetString(OSSAudioError, "Invalid mixer channel specified."); |
| 725 return NULL; | |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
726 } |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
727 |
|
26839
c44d994b39e5
Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents:
26837
diff
changeset
|
728 if (ioctl(self->fd, MIXER_READ(channel), &volume) == -1) |
| 26840 | 729 return PyErr_SetFromErrno(PyExc_IOError); |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
730 |
|
26839
c44d994b39e5
Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents:
26837
diff
changeset
|
731 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
|
732 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
733 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
734 static PyObject * |
|
26839
c44d994b39e5
Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents:
26837
diff
changeset
|
735 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
|
736 { |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
737 int channel, volume, leftVol, rightVol; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
738 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
739 /* 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
|
740 if (!PyArg_ParseTuple(args, "i(ii):set", &channel, &leftVol, &rightVol)) |
| 26840 | 741 return NULL; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
742 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
743 if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) { |
| 26840 | 744 PyErr_SetString(OSSAudioError, "Invalid mixer channel specified."); |
| 745 return NULL; | |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
746 } |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
747 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
748 if (leftVol < 0 || rightVol < 0 || leftVol > 100 || rightVol > 100) { |
| 26840 | 749 PyErr_SetString(OSSAudioError, "Volumes must be between 0 and 100."); |
| 750 return NULL; | |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
751 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
752 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
753 volume = (rightVol << 8) | leftVol; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
754 |
|
26839
c44d994b39e5
Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents:
26837
diff
changeset
|
755 if (ioctl(self->fd, MIXER_WRITE(channel), &volume) == -1) |
| 26840 | 756 return PyErr_SetFromErrno(PyExc_IOError); |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
757 |
|
26839
c44d994b39e5
Whitespace fixes to conform to coding standards.
Greg Ward <gward@python.net>
parents:
26837
diff
changeset
|
758 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
|
759 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
760 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
761 static PyObject * |
|
26904
40db78159177
Rename more mixer methods: getrecsrc() -> get_recsrc(),
Greg Ward <gward@python.net>
parents:
26840
diff
changeset
|
762 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
|
763 { |
|
26904
40db78159177
Rename more mixer methods: getrecsrc() -> get_recsrc(),
Greg Ward <gward@python.net>
parents:
26840
diff
changeset
|
764 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
|
765 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
|
766 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
767 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
768 static PyObject * |
|
26904
40db78159177
Rename more mixer methods: getrecsrc() -> get_recsrc(),
Greg Ward <gward@python.net>
parents:
26840
diff
changeset
|
769 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
|
770 { |
|
26904
40db78159177
Rename more mixer methods: getrecsrc() -> get_recsrc(),
Greg Ward <gward@python.net>
parents:
26840
diff
changeset
|
771 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
|
772 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
|
773 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
774 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
775 |
|
26919
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
776 /* ---------------------------------------------------------------------- |
|
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
777 * 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
|
778 */ |
|
b93845226db6
Add a bunch of comments to clearly delineate sections of the code.
Greg Ward <gward@python.net>
parents:
26918
diff
changeset
|
779 |
|
26602
c163ed17f8ba
Finish expunging the 'linuxaudiodev' name:
Greg Ward <gward@python.net>
parents:
26481
diff
changeset
|
780 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
|
781 /* Regular file methods */ |
| 26840 | 782 { "read", (PyCFunction)oss_read, METH_VARARGS }, |
| 783 { "write", (PyCFunction)oss_write, METH_VARARGS }, | |
| 784 { "writeall", (PyCFunction)oss_writeall, METH_VARARGS }, | |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
785 { "close", (PyCFunction)oss_close, METH_NOARGS }, |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
786 { "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
|
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 /* Simple ioctl wrappers */ |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
789 { "nonblock", (PyCFunction)oss_nonblock, METH_NOARGS }, |
| 26840 | 790 { "setfmt", (PyCFunction)oss_setfmt, METH_VARARGS }, |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
791 { "getfmts", (PyCFunction)oss_getfmts, METH_NOARGS }, |
|
26602
c163ed17f8ba
Finish expunging the 'linuxaudiodev' name:
Greg Ward <gward@python.net>
parents:
26481
diff
changeset
|
792 { "channels", (PyCFunction)oss_channels, METH_VARARGS }, |
|
c163ed17f8ba
Finish expunging the 'linuxaudiodev' name:
Greg Ward <gward@python.net>
parents:
26481
diff
changeset
|
793 { "speed", (PyCFunction)oss_speed, METH_VARARGS }, |
| 26840 | 794 { "sync", (PyCFunction)oss_sync, METH_VARARGS }, |
| 795 { "reset", (PyCFunction)oss_reset, METH_VARARGS }, | |
| 796 { "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
|
797 |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
798 /* Convenience methods -- wrap a couple of ioctls together */ |
| 26840 | 799 { "setparameters", (PyCFunction)oss_setparameters, METH_VARARGS }, |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
800 { "bufsize", (PyCFunction)oss_bufsize, METH_NOARGS }, |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
801 { "obufcount", (PyCFunction)oss_obufcount, METH_NOARGS }, |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
802 { "obuffree", (PyCFunction)oss_obuffree, METH_NOARGS }, |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
803 { "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
|
804 |
|
7468b68e9828
* Don't put the device in non-blocking mode at open() time; this makes
Greg Ward <gward@python.net>
parents:
26477
diff
changeset
|
805 /* Aliases for backwards compatibility */ |
| 26840 | 806 { "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
|
807 |
|
65607
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
808 /* Support for the context manager protocol */ |
|
65628
cb6418f4d60b
These are true PyCFunctions, after adding the second argument to oss_self, no need to cast.
Georg Brandl <georg@python.org>
parents:
65622
diff
changeset
|
809 { "__enter__", oss_self, METH_NOARGS }, |
|
cb6418f4d60b
These are true PyCFunctions, after adding the second argument to oss_self, no need to cast.
Georg Brandl <georg@python.org>
parents:
65622
diff
changeset
|
810 { "__exit__", oss_exit, METH_VARARGS }, |
|
65607
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
811 |
| 26840 | 812 { NULL, NULL} /* sentinel */ |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
813 }; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
814 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
815 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
|
816 /* Regular file method - OSS mixers are ioctl-only interface */ |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
817 { "close", (PyCFunction)oss_mixer_close, METH_NOARGS }, |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
818 { "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
|
819 |
|
65607
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
820 /* Support for the context manager protocol */ |
|
65628
cb6418f4d60b
These are true PyCFunctions, after adding the second argument to oss_self, no need to cast.
Georg Brandl <georg@python.org>
parents:
65622
diff
changeset
|
821 { "__enter__", oss_self, METH_NOARGS }, |
|
cb6418f4d60b
These are true PyCFunctions, after adding the second argument to oss_self, no need to cast.
Georg Brandl <georg@python.org>
parents:
65622
diff
changeset
|
822 { "__exit__", oss_exit, METH_VARARGS }, |
|
65607
792005de277c
#6518: enable context manager protocol for ossaudiodev types.
Georg Brandl <georg@python.org>
parents:
61466
diff
changeset
|
823 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
824 /* Simple ioctl wrappers */ |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
825 { "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
|
826 { "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
|
827 { "reccontrols", (PyCFunction)oss_mixer_reccontrols, METH_VARARGS}, |
| 26840 | 828 { "get", (PyCFunction)oss_mixer_get, METH_VARARGS }, |
| 829 { "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
|
830 { "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
|
831 { "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
|
832 |
| 26840 | 833 { NULL, NULL} |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
834 }; |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
835 |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
836 static PyObject * |
|
48418
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
837 oss_getattro(oss_audio_t *self, PyObject *nameobj) |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
838 { |
|
48418
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
839 char *name = ""; |
|
34700
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
840 PyObject * rval = NULL; |
|
48418
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
841 |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
842 if (PyUnicode_Check(nameobj)) |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59929
diff
changeset
|
843 name = _PyUnicode_AsString(nameobj); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59929
diff
changeset
|
844 |
|
34700
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
845 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
|
846 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
|
847 Py_INCREF(rval); |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
848 } |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
849 else if (strcmp(name, "name") == 0) { |
| 42857 | 850 rval = PyUnicode_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
|
851 } |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
852 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
|
853 /* 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
|
854 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
|
855 switch(self->mode) { |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
856 case O_RDONLY: |
| 42857 | 857 rval = PyUnicode_FromString("r"); |
|
34700
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
858 break; |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
859 case O_RDWR: |
| 42857 | 860 rval = PyUnicode_FromString("rw"); |
|
34700
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
861 break; |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
862 case O_WRONLY: |
| 42857 | 863 rval = PyUnicode_FromString("w"); |
|
34700
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
864 break; |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
865 } |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
866 } |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
867 else { |
|
48418
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
868 rval = PyObject_GenericGetAttr((PyObject *)self, nameobj); |
|
34700
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
869 } |
|
84859b4a62c6
SF #818006: merge from release24-maint branch: add useful read-only
Greg Ward <gward@python.net>
parents:
32044
diff
changeset
|
870 return rval; |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
871 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
872 |
|
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
|
873 static PyTypeObject OSSAudioType = { |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
40450
diff
changeset
|
874 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
|
875 "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
|
876 sizeof(oss_audio_t), /*tp_size*/ |
| 26840 | 877 0, /*tp_itemsize*/ |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
878 /* methods */ |
| 26840 | 879 (destructor)oss_dealloc, /*tp_dealloc*/ |
| 880 0, /*tp_print*/ | |
|
48418
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
881 0, /*tp_getattr*/ |
| 26840 | 882 0, /*tp_setattr*/ |
|
51271
87fbbf22adf3
Merged revisions 69214 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents:
49057
diff
changeset
|
883 0, /*tp_reserved*/ |
| 26840 | 884 0, /*tp_repr*/ |
|
48418
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
885 0, /*tp_as_number*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
886 0, /*tp_as_sequence*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
887 0, /*tp_as_mapping*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
888 0, /*tp_hash*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
889 0, /*tp_call*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
890 0, /*tp_str*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
891 (getattrofunc)oss_getattro, /*tp_getattro*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
892 0, /*tp_setattro*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
893 0, /*tp_as_buffer*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
894 Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
895 0, /*tp_doc*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
896 0, /*tp_traverse*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
897 0, /*tp_clear*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
898 0, /*tp_richcompare*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
899 0, /*tp_weaklistoffset*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
900 0, /*tp_iter*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
901 0, /*tp_iternext*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
902 oss_methods, /*tp_methods*/ |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
903 }; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
904 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
905 static PyTypeObject OSSMixerType = { |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
40450
diff
changeset
|
906 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
|
907 "ossaudiodev.oss_mixer_device", /*tp_name*/ |
| 26840 | 908 sizeof(oss_mixer_t), /*tp_size*/ |
| 909 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
|
910 /* methods */ |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
911 (destructor)oss_mixer_dealloc, /*tp_dealloc*/ |
| 26840 | 912 0, /*tp_print*/ |
|
48418
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
913 0, /*tp_getattr*/ |
| 26840 | 914 0, /*tp_setattr*/ |
|
51271
87fbbf22adf3
Merged revisions 69214 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents:
49057
diff
changeset
|
915 0, /*tp_reserved*/ |
| 26840 | 916 0, /*tp_repr*/ |
|
48418
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
917 0, /*tp_as_number*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
918 0, /*tp_as_sequence*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
919 0, /*tp_as_mapping*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
920 0, /*tp_hash*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
921 0, /*tp_call*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
922 0, /*tp_str*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
923 0, /*tp_getattro*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
924 0, /*tp_setattro*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
925 0, /*tp_as_buffer*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
926 Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
927 0, /*tp_doc*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
928 0, /*tp_traverse*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
929 0, /*tp_clear*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
930 0, /*tp_richcompare*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
931 0, /*tp_weaklistoffset*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
932 0, /*tp_iter*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
933 0, /*tp_iternext*/ |
|
aa1fbe321acf
#3247: get rid of Py_FindMethod
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
934 oss_mixer_methods, /*tp_methods*/ |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
935 }; |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
936 |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
937 |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
938 static PyObject * |
|
26481
b268a6e859cb
Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now!
Greg Ward <gward@python.net>
parents:
26480
diff
changeset
|
939 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
|
940 { |
|
26602
c163ed17f8ba
Finish expunging the 'linuxaudiodev' name:
Greg Ward <gward@python.net>
parents:
26481
diff
changeset
|
941 return (PyObject *)newossobject(args); |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
942 } |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
943 |
|
26605
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
944 static PyObject * |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
945 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
|
946 { |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
947 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
|
948 } |
|
378ce020d9e6
Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
Greg Ward <gward@python.net>
parents:
26603
diff
changeset
|
949 |
|
26481
b268a6e859cb
Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now!
Greg Ward <gward@python.net>
parents:
26480
diff
changeset
|
950 static PyMethodDef ossaudiodev_methods[] = { |
|
b268a6e859cb
Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now!
Greg Ward <gward@python.net>
parents:
26480
diff
changeset
|
951 { "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
|
952 { "openmixer", ossopenmixer, METH_VARARGS }, |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
953 { 0, 0 }, |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
954 }; |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
955 |
|
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
|
956 |
|
d1b4e7016d88
Added mode 'rw' for full-duplex (play and record at the same time) mode.
Greg Ward <gward@python.net>
parents:
26478
diff
changeset
|
957 #define _EXPORT_INT(mod, name) \ |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47300
diff
changeset
|
958 if (PyModule_AddIntConstant(mod, #name, (long) (name)) == -1) return NULL; |
|
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
|
959 |
|
26922
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
960 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
961 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
|
962 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
|
963 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
964 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
965 static int |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
966 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
|
967 { |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
968 PyObject *labels; |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
969 PyObject *names; |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
970 PyObject *s; |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
971 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
|
972 int i; |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
973 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
974 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
|
975 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
|
976 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
977 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
|
978 names = PyList_New(num_controls); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36785
diff
changeset
|
979 if (labels == NULL || names == NULL) |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36785
diff
changeset
|
980 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
|
981 for (i = 0; i < num_controls; i++) { |
| 42857 | 982 s = PyUnicode_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
|
983 if (s == NULL) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36785
diff
changeset
|
984 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
|
985 PyList_SET_ITEM(labels, i, s); |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
986 |
| 42857 | 987 s = PyUnicode_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
|
988 if (s == NULL) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36785
diff
changeset
|
989 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
|
990 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
|
991 } |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
992 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
993 if (PyModule_AddObject(module, "control_labels", labels) == -1) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36785
diff
changeset
|
994 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
|
995 if (PyModule_AddObject(module, "control_names", names) == -1) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36785
diff
changeset
|
996 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
|
997 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
998 return 0; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36785
diff
changeset
|
999 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36785
diff
changeset
|
1000 error2: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36785
diff
changeset
|
1001 Py_XDECREF(labels); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36785
diff
changeset
|
1002 error1: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36785
diff
changeset
|
1003 Py_XDECREF(names); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36785
diff
changeset
|
1004 return -1; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
1005 } |
|
26922
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
1006 |
|
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
1007 |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47300
diff
changeset
|
1008 static struct PyModuleDef ossaudiodevmodule = { |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59929
diff
changeset
|
1009 PyModuleDef_HEAD_INIT, |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59929
diff
changeset
|
1010 "ossaudiodev", |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59929
diff
changeset
|
1011 NULL, |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59929
diff
changeset
|
1012 -1, |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59929
diff
changeset
|
1013 ossaudiodev_methods, |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59929
diff
changeset
|
1014 NULL, |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59929
diff
changeset
|
1015 NULL, |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59929
diff
changeset
|
1016 NULL, |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59929
diff
changeset
|
1017 NULL |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47300
diff
changeset
|
1018 }; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47300
diff
changeset
|
1019 |
|
59929
3244efb6d88f
Issue #8139: ossaudiodev didn't initialize its types properly, therefore
Antoine Pitrou <solipsis@pitrou.net>
parents:
51271
diff
changeset
|
1020 PyMODINIT_FUNC |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47300
diff
changeset
|
1021 PyInit_ossaudiodev(void) |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1022 { |
|
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1023 PyObject *m; |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
1024 |
|
59929
3244efb6d88f
Issue #8139: ossaudiodev didn't initialize its types properly, therefore
Antoine Pitrou <solipsis@pitrou.net>
parents:
51271
diff
changeset
|
1025 if (PyType_Ready(&OSSAudioType) < 0) |
|
3244efb6d88f
Issue #8139: ossaudiodev didn't initialize its types properly, therefore
Antoine Pitrou <solipsis@pitrou.net>
parents:
51271
diff
changeset
|
1026 return NULL; |
|
3244efb6d88f
Issue #8139: ossaudiodev didn't initialize its types properly, therefore
Antoine Pitrou <solipsis@pitrou.net>
parents:
51271
diff
changeset
|
1027 |
|
3244efb6d88f
Issue #8139: ossaudiodev didn't initialize its types properly, therefore
Antoine Pitrou <solipsis@pitrou.net>
parents:
51271
diff
changeset
|
1028 if (PyType_Ready(&OSSMixerType) < 0) |
|
3244efb6d88f
Issue #8139: ossaudiodev didn't initialize its types properly, therefore
Antoine Pitrou <solipsis@pitrou.net>
parents:
51271
diff
changeset
|
1029 return NULL; |
|
3244efb6d88f
Issue #8139: ossaudiodev didn't initialize its types properly, therefore
Antoine Pitrou <solipsis@pitrou.net>
parents:
51271
diff
changeset
|
1030 |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47300
diff
changeset
|
1031 m = PyModule_Create(&ossaudiodevmodule); |
|
36324
1af7f719ed28
Check return result from Py_InitModule*(). This API can fail.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36221
diff
changeset
|
1032 if (m == NULL) |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59929
diff
changeset
|
1033 return NULL; |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1034 |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
1035 OSSAudioError = PyErr_NewException("ossaudiodev.OSSAudioError", |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59929
diff
changeset
|
1036 NULL, NULL); |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
1037 if (OSSAudioError) { |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
1038 /* 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
|
1039 Py_INCREF(OSSAudioError); |
|
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
1040 Py_INCREF(OSSAudioError); |
| 26840 | 1041 PyModule_AddObject(m, "error", OSSAudioError); |
|
29324
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
1042 PyModule_AddObject(m, "OSSAudioError", OSSAudioError); |
|
008cd101269d
Completely change the interface to setparameters():
Greg Ward <gward@python.net>
parents:
29274
diff
changeset
|
1043 } |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1044 |
|
26922
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
1045 /* 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
|
1046 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
|
1047 if (build_namelists(m) == -1) /* XXX what to do here? */ |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47300
diff
changeset
|
1048 return NULL; |
|
26922
9d0580acb45f
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
Greg Ward <gward@python.net>
parents:
26921
diff
changeset
|
1049 |
|
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
|
1050 /* 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
|
1051 _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
|
1052 _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
|
1053 _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
|
1054 _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
|
1055 _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
|
1056 _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
|
1057 _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
|
1058 _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
|
1059 _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
|
1060 _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
|
1061 _EXPORT_INT(m, AFMT_MPEG); |
|
27863
d19661e198f7
Conditionalize another constant
Andrew M. Kuchling <amk@amk.ca>
parents:
27598
diff
changeset
|
1062 #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
|
1063 _EXPORT_INT(m, AFMT_AC3); |
|
27863
d19661e198f7
Conditionalize another constant
Andrew M. Kuchling <amk@amk.ca>
parents:
27598
diff
changeset
|
1064 #endif |
|
27598
a35dfca93318
Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents:
27210
diff
changeset
|
1065 #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
|
1066 _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
|
1067 #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
|
1068 #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
|
1069 _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
|
1070 #endif |
|
47c5803aab45
Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents:
34700
diff
changeset
|
1071 #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
|
1072 _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
|
1073 #endif |
|
47c5803aab45
Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents:
34700
diff
changeset
|
1074 #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
|
1075 _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
|
1076 #endif |
|
47c5803aab45
Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE,
Greg Ward <gward@python.net>
parents:
34700
diff
changeset
|
1077 #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
|
1078 _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
|
1079 #endif |
|
29356
a369336224dd
Whitespace normalization; break a long line.
Guido van Rossum <guido@python.org>
parents:
29355
diff
changeset
|
1080 |
| 26836 | 1081 /* 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
|
1082 _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
|
1083 _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
|
1084 _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
|
1085 _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
|
1086 _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
|
1087 _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
|
1088 _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
|
1089 _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
|
1090 _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
|
1091 _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
|
1092 _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
|
1093 _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
|
1094 _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
|
1095 _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
|
1096 _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
|
1097 _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
|
1098 _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
|
1099 _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
|
1100 #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
|
1101 _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
|
1102 #endif |
|
9f6d45f3c023
SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents:
29356
diff
changeset
|
1103 #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
|
1104 _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
|
1105 #endif |
|
9f6d45f3c023
SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents:
29356
diff
changeset
|
1106 #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
|
1107 _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
|
1108 #endif |
|
9f6d45f3c023
SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents:
29356
diff
changeset
|
1109 #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
|
1110 _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
|
1111 #endif |
|
9f6d45f3c023
SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents:
29356
diff
changeset
|
1112 #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
|
1113 _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
|
1114 #endif |
|
9f6d45f3c023
SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents:
29356
diff
changeset
|
1115 #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
|
1116 _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
|
1117 #endif |
|
9f6d45f3c023
SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents:
29356
diff
changeset
|
1118 #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
|
1119 _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
|
1120 #endif |
|
9f6d45f3c023
SF #832236: merge from release23-maint branch: wrap a bunch of
Greg Ward <gward@python.net>
parents:
29356
diff
changeset
|
1121 #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
|
1122 _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
|
1123 #endif |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1124 |
|
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
|
1125 /* 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
|
1126 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
|
1127 _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
|
1128 _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
|
1129 _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
|
1130 _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
|
1131 _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
|
1132 _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
|
1133 _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
|
1134 _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
|
1135 _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
|
1136 _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
|
1137 #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
|
1138 _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
|
1139 #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
|
1140 _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
|
1141 _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
|
1142 _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
|
1143 #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
|
1144 _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
|
1145 #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
|
1146 _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
|
1147 _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
|
1148 _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
|
1149 #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
|
1150 _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
|
1151 #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
|
1152 _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
|
1153 _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
|
1154 #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
|
1155 _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
|
1156 #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
|
1157 _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
|
1158 _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
|
1159 _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
|
1160 _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
|
1161 _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
|
1162 #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
|
1163 _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
|
1164 #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
|
1165 _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
|
1166 _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
|
1167 _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
|
1168 _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
|
1169 _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
|
1170 #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
|
1171 _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
|
1172 #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
|
1173 _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
|
1174 _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
|
1175 _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
|
1176 _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
|
1177 _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
|
1178 _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
|
1179 _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
|
1180 _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
|
1181 _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
|
1182 _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
|
1183 _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
|
1184 _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
|
1185 _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
|
1186 _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
|
1187 _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
|
1188 #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
|
1189 _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
|
1190 #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
|
1191 _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
|
1192 _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
|
1193 _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
|
1194 _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
|
1195 _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
|
1196 _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
|
1197 _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
|
1198 _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
|
1199 _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
|
1200 _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
|
1201 #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
|
1202 _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
|
1203 #endif |
|
a35dfca93318
Get ossaudiodev to compile on freebsd 4.7
Neal Norwitz <nnorwitz@gmail.com>
parents:
27210
diff
changeset
|
1204 #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
|
1205 _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
|
1206 #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
|
1207 _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
|
1208 _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
|
1209 #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
|
1210 _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
|
1211 #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
|
1212 _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
|
1213 _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
|
1214 _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
|
1215 _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
|
1216 _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
|
1217 _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
|
1218 _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
|
1219 _EXPORT_INT(m, SNDCTL_TMR_TIMEBASE); |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47300
diff
changeset
|
1220 return m; |
|
26477
e07948d5cf67
ossaudiodev -- Python interface to the OSS (Open Sound System) API.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1221 } |
