Mercurial > cpython-lru_cache-weakref
annotate Modules/sunaudiodev.c @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | 2f2760c3dd90 |
| children | 2c29b8982643 |
| rev | line source |
|---|---|
| 885 | 1 /*********************************************************** |
|
2061
172ba04a5191
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
|
172ba04a5191
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
3 The Netherlands. |
| 885 | 4 |
| 5 All Rights Reserved | |
| 6 | |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
| 885 | 9 provided that the above copyright notice appear in all copies and that |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
| 885 | 11 supporting documentation, and that the names of Stichting Mathematisch |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
12 Centrum or CWI or Corporation for National Research Initiatives or |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
13 CNRI not be used in advertising or publicity pertaining to |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
14 distribution of the software without specific, written prior |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
15 permission. |
| 885 | 16 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
17 While CWI is the initial source for this software, a modified version |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
18 is made available by the Corporation for National Research Initiatives |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
19 (CNRI) at the Internet address ftp://ftp.python.org. |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
20 |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4298
diff
changeset
|
28 PERFORMANCE OF THIS SOFTWARE. |
| 885 | 29 |
| 30 ******************************************************************/ | |
| 31 | |
| 32 /* Sad objects */ | |
| 33 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
34 #include "Python.h" |
| 885 | 35 #include "structmember.h" |
| 36 | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
37 #ifdef HAVE_SYS_AUDIOIO_H |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
38 #define SOLARIS |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
39 #endif |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
40 |
|
4652
3d87cb1b3d17
Make gcc -Wall happy; remove dummy variable (can't see where it's needed).
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
41 #ifdef HAVE_UNISTD_H |
|
3d87cb1b3d17
Make gcc -Wall happy; remove dummy variable (can't see where it's needed).
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
42 #include <unistd.h> |
|
3d87cb1b3d17
Make gcc -Wall happy; remove dummy variable (can't see where it's needed).
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
43 #endif |
|
3d87cb1b3d17
Make gcc -Wall happy; remove dummy variable (can't see where it's needed).
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
44 |
|
3d87cb1b3d17
Make gcc -Wall happy; remove dummy variable (can't see where it's needed).
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
45 #ifdef HAVE_FCNTL_H |
|
3d87cb1b3d17
Make gcc -Wall happy; remove dummy variable (can't see where it's needed).
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
46 #include <fcntl.h> |
|
3d87cb1b3d17
Make gcc -Wall happy; remove dummy variable (can't see where it's needed).
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
47 #endif |
|
3d87cb1b3d17
Make gcc -Wall happy; remove dummy variable (can't see where it's needed).
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
48 |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
49 #include <stropts.h> |
| 885 | 50 #include <sys/ioctl.h> |
| 1418 | 51 #ifdef SOLARIS |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
52 #include <sys/audioio.h> |
| 1418 | 53 #else |
| 885 | 54 #include <sun/audioio.h> |
| 1418 | 55 #endif |
| 885 | 56 |
| 57 /* #define offsetof(str,mem) ((int)(((str *)0)->mem)) */ | |
| 58 | |
| 59 typedef struct { | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
60 PyObject_HEAD |
| 885 | 61 int x_fd; /* The open file */ |
| 62 int x_icount; /* # samples read */ | |
| 63 int x_ocount; /* # samples written */ | |
| 64 int x_isctl; /* True if control device */ | |
| 65 | |
| 66 } sadobject; | |
| 67 | |
| 68 typedef struct { | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
69 PyObject_HEAD |
| 885 | 70 audio_info_t ai; |
| 71 } sadstatusobject; | |
| 72 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
73 staticforward PyTypeObject Sadtype; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
74 staticforward PyTypeObject Sadstatustype; |
| 1418 | 75 static sadstatusobject *sads_alloc(); /* Forward */ |
| 885 | 76 |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
77 static PyObject *SunAudioError; |
| 885 | 78 |
| 79 #define is_sadobject(v) ((v)->ob_type == &Sadtype) | |
| 80 #define is_sadstatusobject(v) ((v)->ob_type == &Sadstatustype) | |
| 81 | |
| 82 static sadobject * | |
| 83 newsadobject(arg) | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
84 PyObject *arg; |
| 885 | 85 { |
| 86 sadobject *xp; | |
| 87 int fd; | |
| 88 char *mode; | |
| 89 int imode; | |
| 90 | |
| 91 /* Check arg for r/w/rw */ | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
92 if (!PyArg_Parse(arg, "s", &mode)) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
93 return NULL; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
94 if (strcmp(mode, "r") == 0) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
95 imode = 0; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
96 else if (strcmp(mode, "w") == 0) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
97 imode = 1; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
98 else if (strcmp(mode, "rw") == 0) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
99 imode = 2; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
100 else if (strcmp(mode, "control") == 0) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
101 imode = -1; |
| 885 | 102 else { |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
103 PyErr_SetString(SunAudioError, |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
104 "Mode should be one of 'r', 'w', 'rw' or 'control'"); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
105 return NULL; |
| 885 | 106 } |
| 107 | |
| 108 /* Open the correct device */ | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
109 if (imode < 0) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
110 /* XXXX Check that this works */ |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
111 fd = open("/dev/audioctl", 2); |
| 885 | 112 else |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
113 fd = open("/dev/audio", imode); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
114 if (fd < 0) { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
115 PyErr_SetFromErrno(SunAudioError); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
116 return NULL; |
| 885 | 117 } |
| 118 | |
| 119 /* Create and initialize the object */ | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
120 xp = PyObject_NEW(sadobject, &Sadtype); |
|
4919
f8e5bc5351a9
Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents:
4708
diff
changeset
|
121 if (xp == NULL) { |
|
f8e5bc5351a9
Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents:
4708
diff
changeset
|
122 close(fd); |
| 885 | 123 return NULL; |
|
4919
f8e5bc5351a9
Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents:
4708
diff
changeset
|
124 } |
| 885 | 125 xp->x_fd = fd; |
| 126 xp->x_icount = xp->x_ocount = 0; | |
| 127 xp->x_isctl = (imode < 0); | |
| 128 | |
| 129 return xp; | |
| 130 } | |
| 131 | |
| 132 /* Sad methods */ | |
| 133 | |
| 134 static void | |
| 135 sad_dealloc(xp) | |
| 136 sadobject *xp; | |
| 137 { | |
| 138 close(xp->x_fd); | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
139 PyMem_DEL(xp); |
| 885 | 140 } |
| 141 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
142 static PyObject * |
| 885 | 143 sad_read(self, args) |
| 144 sadobject *self; | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
145 PyObject *args; |
| 885 | 146 { |
| 147 int size, count; | |
| 148 char *cp; | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
149 PyObject *rv; |
| 885 | 150 |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
151 if (!PyArg_Parse(args, "i", &size)) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
152 return NULL; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
153 rv = PyString_FromStringAndSize(NULL, size); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
154 if (rv == NULL) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
155 return NULL; |
| 885 | 156 |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
157 if (!(cp = PyString_AsString(rv))) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
158 goto finally; |
| 885 | 159 |
| 160 count = read(self->x_fd, cp, size); | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
161 if (count < 0) { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
162 PyErr_SetFromErrno(SunAudioError); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
163 goto finally; |
| 885 | 164 } |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
165 #if 0 |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
166 /* TBD: why print this message if you can handle the condition? |
|
4919
f8e5bc5351a9
Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents:
4708
diff
changeset
|
167 * assume it's debugging info which we can just as well get rid |
|
f8e5bc5351a9
Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents:
4708
diff
changeset
|
168 * of. in any case this message should *not* be using printf! |
|
f8e5bc5351a9
Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents:
4708
diff
changeset
|
169 */ |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
170 if (count != size) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
171 printf("sunaudio: funny read rv %d wtd %d\n", count, size); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
172 #endif |
| 885 | 173 self->x_icount += count; |
| 174 return rv; | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
175 |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
176 finally: |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
177 Py_DECREF(rv); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
178 return NULL; |
| 885 | 179 } |
| 180 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
181 static PyObject * |
| 885 | 182 sad_write(self, args) |
| 183 sadobject *self; | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
184 PyObject *args; |
| 885 | 185 { |
| 186 char *cp; | |
| 187 int count, size; | |
| 188 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
189 if (!PyArg_Parse(args, "s#", &cp, &size)) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
190 return NULL; |
| 885 | 191 |
| 192 count = write(self->x_fd, cp, size); | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
193 if (count < 0) { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
194 PyErr_SetFromErrno(SunAudioError); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
195 return NULL; |
| 885 | 196 } |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
197 #if 0 |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
198 if (count != size) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
199 printf("sunaudio: funny write rv %d wanted %d\n", count, size); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
200 #endif |
| 885 | 201 self->x_ocount += count; |
| 202 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
203 Py_INCREF(Py_None); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
204 return Py_None; |
| 885 | 205 } |
| 206 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
207 static PyObject * |
| 885 | 208 sad_getinfo(self, args) |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
209 sadobject *self; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
210 PyObject *args; |
| 885 | 211 { |
| 212 sadstatusobject *rv; | |
| 213 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
214 if (!PyArg_Parse(args, "")) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
215 return NULL; |
|
4919
f8e5bc5351a9
Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents:
4708
diff
changeset
|
216 if (!(rv = sads_alloc())) |
|
f8e5bc5351a9
Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents:
4708
diff
changeset
|
217 return NULL; |
|
f8e5bc5351a9
Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents:
4708
diff
changeset
|
218 |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
219 if (ioctl(self->x_fd, AUDIO_GETINFO, &rv->ai) < 0) { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
220 PyErr_SetFromErrno(SunAudioError); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
221 Py_DECREF(rv); |
| 885 | 222 return NULL; |
| 223 } | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
224 return (PyObject *)rv; |
| 885 | 225 } |
| 226 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
227 static PyObject * |
| 885 | 228 sad_setinfo(self, arg) |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
229 sadobject *self; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
230 sadstatusobject *arg; |
| 885 | 231 { |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
232 if (!is_sadstatusobject(arg)) { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
233 PyErr_SetString(PyExc_TypeError, |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
234 "Must be sun audio status object"); |
| 885 | 235 return NULL; |
| 236 } | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
237 if (ioctl(self->x_fd, AUDIO_SETINFO, &arg->ai) < 0) { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
238 PyErr_SetFromErrno(SunAudioError); |
| 885 | 239 return NULL; |
| 240 } | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
241 Py_INCREF(Py_None); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
242 return Py_None; |
| 885 | 243 } |
| 244 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
245 static PyObject * |
| 885 | 246 sad_ibufcount(self, args) |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
247 sadobject *self; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
248 PyObject *args; |
| 885 | 249 { |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
250 audio_info_t ai; |
| 885 | 251 |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
252 if (!PyArg_Parse(args, "")) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
253 return NULL; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
254 if (ioctl(self->x_fd, AUDIO_GETINFO, &ai) < 0) { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
255 PyErr_SetFromErrno(SunAudioError); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
256 return NULL; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
257 } |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
258 return PyInt_FromLong(ai.record.samples - self->x_icount); |
| 885 | 259 } |
| 260 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
261 static PyObject * |
| 885 | 262 sad_obufcount(self, args) |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
263 sadobject *self; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
264 PyObject *args; |
| 885 | 265 { |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
266 audio_info_t ai; |
| 885 | 267 |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
268 if (!PyArg_Parse(args, "")) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
269 return NULL; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
270 if (ioctl(self->x_fd, AUDIO_GETINFO, &ai) < 0) { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
271 PyErr_SetFromErrno(SunAudioError); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
272 return NULL; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
273 } |
| 5295 | 274 /* x_ocount is in bytes, wheras play.samples is in frames */ |
| 275 /* we want frames */ | |
| 276 return PyInt_FromLong(self->x_ocount / (ai.play.channels * | |
| 277 ai.play.precision / 8) - | |
| 278 ai.play.samples); | |
| 885 | 279 } |
| 280 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
281 static PyObject * |
| 885 | 282 sad_drain(self, args) |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
283 sadobject *self; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
284 PyObject *args; |
| 885 | 285 { |
| 286 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
287 if (!PyArg_Parse(args, "")) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
288 return NULL; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
289 if (ioctl(self->x_fd, AUDIO_DRAIN, 0) < 0) { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
290 PyErr_SetFromErrno(SunAudioError); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
291 return NULL; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
292 } |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
293 Py_INCREF(Py_None); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
294 return Py_None; |
| 885 | 295 } |
| 296 | |
| 1418 | 297 #ifdef SOLARIS |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
298 static PyObject * |
| 1418 | 299 sad_getdev(self, args) |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
300 sadobject *self; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
301 PyObject *args; |
| 1418 | 302 { |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
303 struct audio_device ad; |
| 1418 | 304 |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
305 if (!PyArg_Parse(args, "")) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
306 return NULL; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
307 if (ioctl(self->x_fd, AUDIO_GETDEV, &ad) < 0) { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
308 PyErr_SetFromErrno(SunAudioError); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
309 return NULL; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
310 } |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
311 return Py_BuildValue("(sss)", ad.name, ad.version, ad.config); |
| 1418 | 312 } |
| 313 #endif | |
| 314 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
315 static PyObject * |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
316 sad_flush(self, args) |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
317 sadobject *self; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
318 PyObject *args; |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
319 { |
|
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
320 |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
321 if (!PyArg_Parse(args, "")) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
322 return NULL; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
323 if (ioctl(self->x_fd, I_FLUSH, FLUSHW) < 0) { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
324 PyErr_SetFromErrno(SunAudioError); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
325 return NULL; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
326 } |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
327 Py_INCREF(Py_None); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
328 return Py_None; |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
329 } |
|
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
330 |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
331 static PyObject * |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
332 sad_close(self, args) |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
333 sadobject *self; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
334 PyObject *args; |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
335 { |
|
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
336 |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
337 if (!PyArg_Parse(args, "")) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
338 return NULL; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
339 if (self->x_fd >= 0) { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
340 close(self->x_fd); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
341 self->x_fd = -1; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
342 } |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
343 Py_INCREF(Py_None); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
344 return Py_None; |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
345 } |
|
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
346 |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
347 static PyMethodDef sad_methods[] = { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
348 { "read", (PyCFunction)sad_read }, |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
349 { "write", (PyCFunction)sad_write }, |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
350 { "ibufcount", (PyCFunction)sad_ibufcount }, |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
351 { "obufcount", (PyCFunction)sad_obufcount }, |
| 885 | 352 #define CTL_METHODS 4 |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
353 { "getinfo", (PyCFunction)sad_getinfo }, |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
354 { "setinfo", (PyCFunction)sad_setinfo }, |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
355 { "drain", (PyCFunction)sad_drain }, |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
356 { "flush", (PyCFunction)sad_flush }, |
| 1418 | 357 #ifdef SOLARIS |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
358 { "getdev", (PyCFunction)sad_getdev }, |
| 1418 | 359 #endif |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
360 { "close", (PyCFunction)sad_close }, |
| 885 | 361 {NULL, NULL} /* sentinel */ |
| 362 }; | |
| 363 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
364 static PyObject * |
| 885 | 365 sad_getattr(xp, name) |
| 366 sadobject *xp; | |
| 367 char *name; | |
| 368 { | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
369 if (xp->x_isctl) |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
370 return Py_FindMethod(sad_methods+CTL_METHODS, |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
371 (PyObject *)xp, name); |
| 885 | 372 else |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
373 return Py_FindMethod(sad_methods, (PyObject *)xp, name); |
| 885 | 374 } |
| 375 | |
| 376 /* ----------------------------------------------------------------- */ | |
| 377 | |
| 378 static sadstatusobject * | |
| 379 sads_alloc() { | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
380 return PyObject_NEW(sadstatusobject, &Sadstatustype); |
| 885 | 381 } |
| 382 | |
| 383 static void | |
| 384 sads_dealloc(xp) | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
385 sadstatusobject *xp; |
| 885 | 386 { |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
387 PyMem_DEL(xp); |
| 885 | 388 } |
| 389 | |
| 390 #define OFF(x) offsetof(audio_info_t,x) | |
| 391 static struct memberlist sads_ml[] = { | |
| 392 { "i_sample_rate", T_UINT, OFF(record.sample_rate) }, | |
| 393 { "i_channels", T_UINT, OFF(record.channels) }, | |
| 394 { "i_precision", T_UINT, OFF(record.precision) }, | |
| 395 { "i_encoding", T_UINT, OFF(record.encoding) }, | |
| 396 { "i_gain", T_UINT, OFF(record.gain) }, | |
| 397 { "i_port", T_UINT, OFF(record.port) }, | |
| 398 { "i_samples", T_UINT, OFF(record.samples) }, | |
| 399 { "i_eof", T_UINT, OFF(record.eof) }, | |
| 400 { "i_pause", T_UBYTE, OFF(record.pause) }, | |
| 401 { "i_error", T_UBYTE, OFF(record.error) }, | |
| 402 { "i_waiting", T_UBYTE, OFF(record.waiting) }, | |
| 403 { "i_open", T_UBYTE, OFF(record.open) , RO}, | |
| 404 { "i_active", T_UBYTE, OFF(record.active) , RO}, | |
| 1418 | 405 #ifdef SOLARIS |
| 406 { "i_buffer_size", T_UINT, OFF(record.buffer_size) }, | |
| 407 { "i_balance", T_UBYTE, OFF(record.balance) }, | |
| 408 { "i_avail_ports", T_UINT, OFF(record.avail_ports) }, | |
| 409 #endif | |
| 885 | 410 |
| 411 { "o_sample_rate", T_UINT, OFF(play.sample_rate) }, | |
| 412 { "o_channels", T_UINT, OFF(play.channels) }, | |
| 413 { "o_precision", T_UINT, OFF(play.precision) }, | |
| 414 { "o_encoding", T_UINT, OFF(play.encoding) }, | |
| 415 { "o_gain", T_UINT, OFF(play.gain) }, | |
| 416 { "o_port", T_UINT, OFF(play.port) }, | |
| 417 { "o_samples", T_UINT, OFF(play.samples) }, | |
| 418 { "o_eof", T_UINT, OFF(play.eof) }, | |
| 419 { "o_pause", T_UBYTE, OFF(play.pause) }, | |
| 420 { "o_error", T_UBYTE, OFF(play.error) }, | |
| 421 { "o_waiting", T_UBYTE, OFF(play.waiting) }, | |
| 422 { "o_open", T_UBYTE, OFF(play.open) , RO}, | |
| 423 { "o_active", T_UBYTE, OFF(play.active) , RO}, | |
| 1418 | 424 #ifdef SOLARIS |
| 425 { "o_buffer_size", T_UINT, OFF(play.buffer_size) }, | |
| 426 { "o_balance", T_UBYTE, OFF(play.balance) }, | |
| 427 { "o_avail_ports", T_UINT, OFF(play.avail_ports) }, | |
| 428 #endif | |
| 885 | 429 |
| 430 { "monitor_gain", T_UINT, OFF(monitor_gain) }, | |
| 431 { NULL, 0, 0}, | |
| 432 }; | |
| 433 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
434 static PyObject * |
| 885 | 435 sads_getattr(xp, name) |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
436 sadstatusobject *xp; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
437 char *name; |
| 885 | 438 { |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
439 return PyMember_Get((char *)&xp->ai, sads_ml, name); |
| 885 | 440 } |
| 441 | |
| 442 static int | |
| 443 sads_setattr(xp, name, v) | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
444 sadstatusobject *xp; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
445 char *name; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
446 PyObject *v; |
| 885 | 447 { |
|
1031
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
885
diff
changeset
|
448 |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
885
diff
changeset
|
449 if (v == NULL) { |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
450 PyErr_SetString(PyExc_TypeError, |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
451 "can't delete sun audio status attributes"); |
|
4298
6f7090a82645
Correct typo: return -1 for error, not 0
Guido van Rossum <guido@python.org>
parents:
2569
diff
changeset
|
452 return -1; |
|
1031
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
885
diff
changeset
|
453 } |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
454 return PyMember_Set((char *)&xp->ai, sads_ml, name, v); |
| 885 | 455 } |
| 456 | |
| 457 /* ------------------------------------------------------------------- */ | |
| 458 | |
| 459 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
460 static PyTypeObject Sadtype = { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
461 PyObject_HEAD_INIT(&PyType_Type) |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
462 0, /*ob_size*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
463 "sun_audio_device", /*tp_name*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
464 sizeof(sadobject), /*tp_size*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
465 0, /*tp_itemsize*/ |
| 885 | 466 /* methods */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
467 (destructor)sad_dealloc, /*tp_dealloc*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
468 0, /*tp_print*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
469 (getattrfunc)sad_getattr, /*tp_getattr*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
470 0, /*tp_setattr*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
471 0, /*tp_compare*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
472 0, /*tp_repr*/ |
| 885 | 473 }; |
| 474 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
475 static PyTypeObject Sadstatustype = { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
476 PyObject_HEAD_INIT(&PyType_Type) |
| 885 | 477 0, /*ob_size*/ |
| 478 "sun_audio_device_status", /*tp_name*/ | |
| 479 sizeof(sadstatusobject), /*tp_size*/ | |
| 480 0, /*tp_itemsize*/ | |
| 481 /* methods */ | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
482 (destructor)sads_dealloc, /*tp_dealloc*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
483 0, /*tp_print*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
484 (getattrfunc)sads_getattr, /*tp_getattr*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
485 (setattrfunc)sads_setattr, /*tp_setattr*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
486 0, /*tp_compare*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
487 0, /*tp_repr*/ |
| 885 | 488 }; |
| 489 /* ------------------------------------------------------------------- */ | |
| 490 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
491 static PyObject * |
| 885 | 492 sadopen(self, args) |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
493 PyObject *self; |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
494 PyObject *args; |
| 885 | 495 { |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
496 return (PyObject *)newsadobject(args); |
| 885 | 497 } |
| 498 | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
499 static PyMethodDef sunaudiodev_methods[] = { |
| 885 | 500 { "open", sadopen }, |
| 501 { 0, 0 }, | |
| 502 }; | |
| 503 | |
| 504 void | |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
505 initsunaudiodev() |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
506 { |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
507 PyObject *m, *d; |
| 885 | 508 |
|
4708
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
509 m = Py_InitModule("sunaudiodev", sunaudiodev_methods); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
510 d = PyModule_GetDict(m); |
|
775a7d0c2960
Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents:
4652
diff
changeset
|
511 SunAudioError = PyString_FromString("sunaudiodev.error"); |
|
4919
f8e5bc5351a9
Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents:
4708
diff
changeset
|
512 if (SunAudioError) |
|
f8e5bc5351a9
Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents:
4708
diff
changeset
|
513 PyDict_SetItemString(d, "error", SunAudioError); |
|
f8e5bc5351a9
Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents:
4708
diff
changeset
|
514 if (PyErr_Occurred()) |
|
f8e5bc5351a9
Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents:
4708
diff
changeset
|
515 Py_FatalError("can't initialize sunaudiodev module"); |
| 885 | 516 } |
