Mercurial > cpython-lru_cache-weakref
annotate Modules/almodule.c @ 4566:6403c94de50d legacy-trunk
Added safeguard against failure in __del__.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 27 Nov 1996 19:39:58 +0000 |
| parents | 65d2d8e67da3 |
| children | d36250aefb82 |
| rev | line source |
|---|---|
| 367 | 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. |
| 367 | 4 |
| 5 All Rights Reserved | |
| 6 | |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
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:
2061
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
| 367 | 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:
2061
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
| 367 | 11 supporting documentation, and that the names of Stichting Mathematisch |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
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:
2061
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:
2061
diff
changeset
|
14 distribution of the software without specific, written prior |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
15 permission. |
| 367 | 16 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
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:
2061
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:
2061
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:
2061
diff
changeset
|
20 |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
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:
2061
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:
2061
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:
2061
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:
2061
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:
2061
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:
2061
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:
2061
diff
changeset
|
28 PERFORMANCE OF THIS SOFTWARE. |
| 367 | 29 |
| 30 ******************************************************************/ | |
| 31 | |
|
864
e58f40c2f285
Mark's name is Callow, not Callows
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
32 /* AL module -- interface to Mark Callow's Audio Library (AL). */ |
| 367 | 33 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
34 #include <audio.h> |
| 367 | 35 |
|
1214
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
36 /* Check which version audio library we have: */ |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
37 #ifdef AL_ERROR_NUMBER |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
38 #define AL_405 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
39 /* XXXX 4.0.5 libaudio also allows us to provide better error |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
40 ** handling (with ALseterrorhandler). We should implement that |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
41 ** sometime. |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
42 */ |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
43 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
44 #endif |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
45 |
| 367 | 46 #include "allobjects.h" |
| 47 #include "import.h" | |
| 48 #include "modsupport.h" | |
| 49 #include "structmember.h" | |
|
947
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
864
diff
changeset
|
50 #include "ceval.h" |
| 367 | 51 |
| 52 | |
| 53 /* Config objects */ | |
| 54 | |
| 55 typedef struct { | |
| 56 OB_HEAD | |
| 57 ALconfig ob_config; | |
| 58 } configobject; | |
| 59 | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
60 staticforward typeobject Configtype; |
| 367 | 61 |
| 62 #define is_configobject(v) ((v)->ob_type == &Configtype) | |
| 63 | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
64 /* Forward */ |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
65 static int getconfigarg PROTO((object *, ALconfig *)); |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
66 static int getstrstrconfigarg PROTO((object *, char **, char **, ALconfig *)); |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
67 |
| 367 | 68 static object * |
| 69 setConfig (self, args, func) | |
| 70 configobject *self; | |
| 71 object *args; | |
| 72 void (*func)(ALconfig, long); | |
| 73 { | |
| 74 long par; | |
| 75 | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
76 if (!getlongarg (args, &par)) return NULL; |
| 367 | 77 |
| 78 (*func) (self-> ob_config, par); | |
| 79 | |
| 80 INCREF (None); | |
| 81 return None; | |
| 82 } | |
| 83 | |
| 84 static object * | |
| 85 getConfig (self, args, func) | |
| 86 configobject *self; | |
| 87 object *args; | |
| 88 long (*func)(ALconfig); | |
| 89 { | |
| 90 long par; | |
| 91 | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
92 if (!getnoarg (args)) return NULL; |
| 367 | 93 |
| 94 par = (*func) (self-> ob_config); | |
| 95 | |
| 96 return newintobject (par); | |
| 97 } | |
| 98 | |
| 99 static object * | |
| 100 al_setqueuesize (self, args) | |
| 101 configobject *self; | |
| 102 object *args; | |
| 103 { | |
| 104 return (setConfig (self, args, ALsetqueuesize)); | |
| 105 } | |
| 106 | |
| 107 static object * | |
| 108 al_getqueuesize (self, args) | |
| 109 configobject *self; | |
| 110 object *args; | |
| 111 { | |
| 112 return (getConfig (self, args, ALgetqueuesize)); | |
| 113 } | |
| 114 | |
| 115 static object * | |
| 116 al_setwidth (self, args) | |
| 117 configobject *self; | |
| 118 object *args; | |
| 119 { | |
| 120 return (setConfig (self, args, ALsetwidth)); | |
| 121 } | |
| 122 | |
| 123 static object * | |
| 124 al_getwidth (self, args) | |
| 125 configobject *self; | |
| 126 object *args; | |
| 127 { | |
| 128 return (getConfig (self, args, ALgetwidth)); | |
| 129 } | |
| 130 | |
| 131 static object * | |
| 132 al_getchannels (self, args) | |
| 133 configobject *self; | |
| 134 object *args; | |
| 135 { | |
| 136 return (getConfig (self, args, ALgetchannels)); | |
| 137 } | |
| 138 | |
| 139 static object * | |
| 140 al_setchannels (self, args) | |
| 141 configobject *self; | |
| 142 object *args; | |
| 143 { | |
| 144 return (setConfig (self, args, ALsetchannels)); | |
| 145 } | |
| 146 | |
|
1214
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
147 #ifdef AL_405 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
148 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
149 static object * |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
150 al_getsampfmt (self, args) |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
151 configobject *self; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
152 object *args; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
153 { |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
154 return (getConfig (self, args, ALgetsampfmt)); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
155 } |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
156 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
157 static object * |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
158 al_setsampfmt (self, args) |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
159 configobject *self; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
160 object *args; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
161 { |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
162 return (setConfig (self, args, ALsetsampfmt)); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
163 } |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
164 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
165 static object * |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
166 al_getfloatmax(self, args) |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
167 configobject *self; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
168 object *args; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
169 { |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
170 double arg; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
171 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
172 if ( !getnoarg(args) ) |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
173 return 0; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
174 arg = ALgetfloatmax(self->ob_config); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
175 return newfloatobject(arg); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
176 } |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
177 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
178 static object * |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
179 al_setfloatmax(self, args) |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
180 configobject *self; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
181 object *args; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
182 { |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
183 double arg; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
184 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
185 if ( !getargs(args, "d", &arg) ) |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
186 return 0; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
187 ALsetfloatmax(self->ob_config, arg); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
188 INCREF(None); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
189 return None; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
190 } |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
191 #endif /* AL_405 */ |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
192 |
| 367 | 193 static struct methodlist config_methods[] = { |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
194 {"getqueuesize", (method)al_getqueuesize}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
195 {"setqueuesize", (method)al_setqueuesize}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
196 {"getwidth", (method)al_getwidth}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
197 {"setwidth", (method)al_setwidth}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
198 {"getchannels", (method)al_getchannels}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
199 {"setchannels", (method)al_setchannels}, |
|
1214
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
200 #ifdef AL_405 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
201 {"getsampfmt", (method)al_getsampfmt}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
202 {"setsampfmt", (method)al_setsampfmt}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
203 {"getfloatmax", (method)al_getfloatmax}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
204 {"setfloatmax", (method)al_setfloatmax}, |
|
1214
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
205 #endif /* AL_405 */ |
| 367 | 206 {NULL, NULL} /* sentinel */ |
| 207 }; | |
| 208 | |
| 209 static void | |
| 210 config_dealloc(self) | |
| 211 configobject *self; | |
| 212 { | |
| 213 ALfreeconfig(self->ob_config); | |
| 214 DEL(self); | |
| 215 } | |
| 216 | |
| 217 static object * | |
| 218 config_getattr(self, name) | |
| 219 configobject *self; | |
| 220 char *name; | |
| 221 { | |
| 222 return findmethod(config_methods, (object *)self, name); | |
| 223 } | |
| 224 | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
225 static typeobject Configtype = { |
| 367 | 226 OB_HEAD_INIT(&Typetype) |
| 227 0, /*ob_size*/ | |
| 228 "config", /*tp_name*/ | |
| 229 sizeof(configobject), /*tp_size*/ | |
| 230 0, /*tp_itemsize*/ | |
| 231 /* methods */ | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
232 (destructor)config_dealloc, /*tp_dealloc*/ |
| 367 | 233 0, /*tp_print*/ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
234 (getattrfunc)config_getattr, /*tp_getattr*/ |
| 367 | 235 0, /*tp_setattr*/ |
| 236 0, /*tp_compare*/ | |
| 237 0, /*tp_repr*/ | |
| 238 }; | |
| 239 | |
| 240 static object * | |
| 241 newconfigobject(config) | |
| 242 ALconfig config; | |
| 243 { | |
| 244 configobject *p; | |
| 245 | |
| 246 p = NEWOBJ(configobject, &Configtype); | |
| 247 if (p == NULL) | |
| 248 return NULL; | |
| 249 p->ob_config = config; | |
| 250 return (object *)p; | |
| 251 } | |
| 252 | |
| 253 /* Port objects */ | |
| 254 | |
| 255 typedef struct { | |
| 256 OB_HEAD | |
| 257 ALport ob_port; | |
| 258 } portobject; | |
| 259 | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
260 staticforward typeobject Porttype; |
| 367 | 261 |
| 262 #define is_portobject(v) ((v)->ob_type == &Porttype) | |
| 263 | |
| 264 static object * | |
| 265 al_closeport (self, args) | |
| 266 portobject *self; | |
| 267 object *args; | |
| 268 { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
269 if (!getnoarg (args)) return NULL; |
| 367 | 270 |
| 271 if (self->ob_port != NULL) { | |
| 272 ALcloseport (self-> ob_port); | |
| 273 self->ob_port = NULL; | |
| 274 /* XXX Using a closed port may dump core! */ | |
| 275 } | |
| 276 | |
| 277 INCREF (None); | |
| 278 return None; | |
| 279 } | |
| 280 | |
| 281 static object * | |
| 282 al_getfd (self, args) | |
| 283 portobject *self; | |
| 284 object *args; | |
| 285 { | |
| 286 int fd; | |
| 287 | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
288 if (!getnoarg (args)) return NULL; |
| 367 | 289 |
| 290 fd = ALgetfd (self-> ob_port); | |
| 291 | |
| 292 return newintobject (fd); | |
| 293 } | |
| 294 | |
| 295 static object * | |
| 296 al_getfilled (self, args) | |
| 297 portobject *self; | |
| 298 object *args; | |
| 299 { | |
| 300 long count; | |
| 301 | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
302 if (!getnoarg (args)) return NULL; |
| 367 | 303 |
| 304 count = ALgetfilled (self-> ob_port); | |
| 305 | |
| 306 return newintobject (count); | |
| 307 } | |
| 308 | |
| 309 static object * | |
| 310 al_getfillable (self, args) | |
| 311 portobject *self; | |
| 312 object *args; | |
| 313 { | |
| 314 long count; | |
| 315 | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
316 if (!getnoarg (args)) return NULL; |
| 367 | 317 |
| 318 count = ALgetfillable (self-> ob_port); | |
| 319 | |
| 320 return newintobject (count); | |
| 321 } | |
| 322 | |
| 323 static object * | |
| 324 al_readsamps (self, args) | |
| 325 portobject *self; | |
| 326 object *args; | |
| 327 { | |
| 328 long count; | |
| 329 object *v; | |
|
369
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
330 ALconfig c; |
| 367 | 331 int width; |
| 332 | |
| 333 if (!getlongarg (args, &count)) return NULL; | |
| 334 | |
| 335 if (count <= 0) | |
| 336 { | |
| 337 err_setstr (RuntimeError, "al.readsamps : arg <= 0"); | |
| 338 return NULL; | |
| 339 } | |
| 340 | |
|
369
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
341 c = ALgetconfig(self->ob_port); |
|
1214
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
342 #ifdef AL_405 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
343 width = ALgetsampfmt(c); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
344 if ( width == AL_SAMPFMT_FLOAT ) |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
345 width = sizeof(float); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
346 else if ( width == AL_SAMPFMT_DOUBLE ) |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
347 width = sizeof(double); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
348 else |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
349 width = ALgetwidth(c); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
350 #else |
|
369
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
351 width = ALgetwidth(c); |
|
1214
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
352 #endif /* AL_405 */ |
|
369
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
353 ALfreeconfig(c); |
| 367 | 354 v = newsizedstringobject ((char *)NULL, width * count); |
| 355 if (v == NULL) return NULL; | |
| 356 | |
|
947
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
864
diff
changeset
|
357 BGN_SAVE |
| 367 | 358 ALreadsamps (self-> ob_port, (void *) getstringvalue(v), count); |
|
947
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
864
diff
changeset
|
359 END_SAVE |
| 367 | 360 |
| 361 return (v); | |
| 362 } | |
| 363 | |
| 364 static object * | |
| 365 al_writesamps (self, args) | |
| 366 portobject *self; | |
| 367 object *args; | |
| 368 { | |
| 369 long count; | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
370 char *buf; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
371 int size, width; |
|
369
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
372 ALconfig c; |
| 367 | 373 |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
374 if (!getargs (args, "s#", &buf, &size)) return NULL; |
| 367 | 375 |
|
369
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
376 c = ALgetconfig(self->ob_port); |
|
1214
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
377 #ifdef AL_405 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
378 width = ALgetsampfmt(c); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
379 if ( width == AL_SAMPFMT_FLOAT ) |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
380 width = sizeof(float); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
381 else if ( width == AL_SAMPFMT_DOUBLE ) |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
382 width = sizeof(double); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
383 else |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
384 width = ALgetwidth(c); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
385 #else |
|
369
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
386 width = ALgetwidth(c); |
|
1214
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
387 #endif /* AL_405 */ |
|
369
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
388 ALfreeconfig(c); |
|
947
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
864
diff
changeset
|
389 BGN_SAVE |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
390 ALwritesamps (self-> ob_port, (void *) buf, (long) size / width); |
|
947
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
864
diff
changeset
|
391 END_SAVE |
| 367 | 392 |
| 393 INCREF (None); | |
| 394 return None; | |
| 395 } | |
| 396 | |
| 397 static object * | |
| 398 al_getfillpoint (self, args) | |
| 399 portobject *self; | |
| 400 object *args; | |
| 401 { | |
| 402 long count; | |
| 403 | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
404 if (!getnoarg (args)) return NULL; |
| 367 | 405 |
| 406 count = ALgetfillpoint (self-> ob_port); | |
| 407 | |
| 408 return newintobject (count); | |
| 409 } | |
| 410 | |
| 411 static object * | |
| 412 al_setfillpoint (self, args) | |
| 413 portobject *self; | |
| 414 object *args; | |
| 415 { | |
| 416 long count; | |
| 417 | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
418 if (!getlongarg (args, &count)) return NULL; |
| 367 | 419 |
| 420 ALsetfillpoint (self-> ob_port, count); | |
| 421 | |
| 422 INCREF (None); | |
| 423 return (None); | |
| 424 } | |
| 425 | |
| 426 static object * | |
| 427 al_setconfig (self, args) | |
| 428 portobject *self; | |
| 429 object *args; | |
| 430 { | |
| 431 ALconfig config; | |
| 432 | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
433 if (!getconfigarg (args, &config)) return NULL; |
| 367 | 434 |
| 435 ALsetconfig (self-> ob_port, config); | |
| 436 | |
| 437 INCREF (None); | |
| 438 return (None); | |
| 439 } | |
| 440 | |
| 441 static object * | |
| 442 al_getconfig (self, args) | |
| 443 portobject *self; | |
| 444 object *args; | |
| 445 { | |
| 446 ALconfig config; | |
| 447 | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
448 if (!getnoarg (args)) return NULL; |
| 367 | 449 |
| 450 config = ALgetconfig (self-> ob_port); | |
| 451 | |
| 452 return newconfigobject (config); | |
| 453 } | |
| 454 | |
|
1214
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
455 #ifdef AL_405 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
456 static object * |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
457 al_getstatus (self, args) |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
458 portobject *self; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
459 object *args; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
460 { |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
461 object *list, *v; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
462 long *PVbuffer; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
463 long length; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
464 int i; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
465 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
466 if (!getargs(args, "O", &list)) |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
467 return NULL; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
468 if (!is_listobject(list)) { |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
469 err_badarg(); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
470 return NULL; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
471 } |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
472 length = getlistsize(list); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
473 PVbuffer = NEW(long, length); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
474 if (PVbuffer == NULL) |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
475 return err_nomem(); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
476 for (i = 0; i < length; i++) { |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
477 v = getlistitem(list, i); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
478 if (!is_intobject(v)) { |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
479 DEL(PVbuffer); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
480 err_badarg(); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
481 return NULL; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
482 } |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
483 PVbuffer[i] = getintvalue(v); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
484 } |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
485 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
486 ALgetstatus(self->ob_port, PVbuffer, length); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
487 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
488 for (i = 0; i < length; i++) |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
489 setlistitem(list, i, newintobject(PVbuffer[i])); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
490 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
491 DEL(PVbuffer); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
492 |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
493 INCREF(None); |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
494 return None; |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
495 } |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
496 #endif /* AL_405 */ |
|
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
497 |
| 367 | 498 static struct methodlist port_methods[] = { |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
499 {"closeport", (method)al_closeport}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
500 {"getfd", (method)al_getfd}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
501 {"fileno", (method)al_getfd}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
502 {"getfilled", (method)al_getfilled}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
503 {"getfillable", (method)al_getfillable}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
504 {"readsamps", (method)al_readsamps}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
505 {"writesamps", (method)al_writesamps}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
506 {"setfillpoint", (method)al_setfillpoint}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
507 {"getfillpoint", (method)al_getfillpoint}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
508 {"setconfig", (method)al_setconfig}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
509 {"getconfig", (method)al_getconfig}, |
|
1214
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
510 #ifdef AL_405 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
511 {"getstatus", (method)al_getstatus}, |
|
1214
416a8a886a82
Added new audio library functionality (getstatus, float sample fmts)
Jack Jansen <jack.jansen@cwi.nl>
parents:
973
diff
changeset
|
512 #endif /* AL_405 */ |
| 367 | 513 {NULL, NULL} /* sentinel */ |
| 514 }; | |
| 515 | |
| 516 static void | |
| 517 port_dealloc(p) | |
| 518 portobject *p; | |
| 519 { | |
| 520 if (p->ob_port != NULL) | |
| 521 ALcloseport(p->ob_port); | |
| 522 DEL(p); | |
| 523 } | |
| 524 | |
| 525 static object * | |
| 526 port_getattr(p, name) | |
| 527 portobject *p; | |
| 528 char *name; | |
| 529 { | |
| 530 return findmethod(port_methods, (object *)p, name); | |
| 531 } | |
| 532 | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
533 static typeobject Porttype = { |
| 367 | 534 OB_HEAD_INIT(&Typetype) |
| 535 0, /*ob_size*/ | |
| 536 "port", /*tp_name*/ | |
| 537 sizeof(portobject), /*tp_size*/ | |
| 538 0, /*tp_itemsize*/ | |
| 539 /* methods */ | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
540 (destructor)port_dealloc, /*tp_dealloc*/ |
| 367 | 541 0, /*tp_print*/ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
542 (getattrfunc)port_getattr, /*tp_getattr*/ |
| 367 | 543 0, /*tp_setattr*/ |
| 544 0, /*tp_compare*/ | |
| 545 0, /*tp_repr*/ | |
| 546 }; | |
| 547 | |
| 548 static object * | |
| 549 newportobject(port) | |
| 550 ALport port; | |
| 551 { | |
| 552 portobject *p; | |
| 553 | |
| 554 p = NEWOBJ(portobject, &Porttype); | |
| 555 if (p == NULL) | |
| 556 return NULL; | |
| 557 p->ob_port = port; | |
| 558 return (object *)p; | |
| 559 } | |
| 560 | |
| 561 /* the module al */ | |
| 562 | |
| 563 static object * | |
| 564 al_openport (self, args) | |
| 565 object *self, *args; | |
| 566 { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
567 char *name, *dir; |
| 367 | 568 ALport port; |
| 569 ALconfig config = NULL; | |
|
384
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
570 int size; |
| 367 | 571 |
|
384
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
572 if (args == NULL || !is_tupleobject(args)) { |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
573 err_badarg (); |
|
384
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
574 return NULL; |
|
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
575 } |
|
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
576 size = gettuplesize(args); |
| 367 | 577 if (size == 2) { |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
578 if (!getargs (args, "(ss)", &name, &dir)) |
| 367 | 579 return NULL; |
| 580 } | |
| 581 else if (size == 3) { | |
| 582 if (!getstrstrconfigarg (args, &name, &dir, &config)) | |
| 583 return NULL; | |
| 584 } | |
| 585 else { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
586 err_badarg (); |
| 367 | 587 return NULL; |
| 588 } | |
| 589 | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
590 port = ALopenport(name, dir, config); |
| 367 | 591 |
|
384
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
592 if (port == NULL) { |
|
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
593 err_errno(RuntimeError); |
|
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
594 return NULL; |
|
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
595 } |
|
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
596 |
| 367 | 597 return newportobject (port); |
| 598 } | |
| 599 | |
| 600 static object * | |
| 601 al_newconfig (self, args) | |
| 602 object *self, *args; | |
| 603 { | |
| 604 ALconfig config; | |
| 605 | |
| 606 if (!getnoarg (args)) return NULL; | |
| 607 | |
| 608 config = ALnewconfig (); | |
|
384
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
609 if (config == NULL) { |
|
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
610 err_errno(RuntimeError); |
|
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
611 return NULL; |
|
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
612 } |
| 367 | 613 |
| 614 return newconfigobject (config); | |
| 615 } | |
|
369
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
616 |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
617 static object * |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
618 al_queryparams(self, args) |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
619 object *self, *args; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
620 { |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
621 long device; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
622 long length; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
623 long *PVbuffer; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
624 long PVdummy[2]; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
625 object *v; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
626 object *w; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
627 |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
628 if (!getlongarg (args, &device)) |
|
369
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
629 return NULL; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
630 length = ALqueryparams(device, PVdummy, 2L); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
631 PVbuffer = NEW(long, length); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
632 if (PVbuffer == NULL) |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
633 return err_nomem(); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
634 (void) ALqueryparams(device, PVbuffer, length); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
635 v = newlistobject((int)length); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
636 if (v != NULL) { |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
637 int i; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
638 for (i = 0; i < length; i++) |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
639 setlistitem(v, i, newintobject(PVbuffer[i])); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
640 } |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
641 DEL(PVbuffer); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
642 return v; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
643 } |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
644 |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
645 static object * |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
646 doParams(args, func, modified) |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
647 object *args; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
648 void (*func)(long, long *, long); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
649 int modified; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
650 { |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
651 long device; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
652 object *list, *v; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
653 long *PVbuffer; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
654 long length; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
655 int i; |
| 367 | 656 |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
657 if (!getargs(args, "(lO)", &device, &list)) |
|
369
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
658 return NULL; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
659 if (!is_listobject(list)) { |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
660 err_badarg(); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
661 return NULL; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
662 } |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
663 length = getlistsize(list); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
664 PVbuffer = NEW(long, length); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
665 if (PVbuffer == NULL) |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
666 return err_nomem(); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
667 for (i = 0; i < length; i++) { |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
668 v = getlistitem(list, i); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
669 if (!is_intobject(v)) { |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
670 DEL(PVbuffer); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
671 err_badarg(); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
672 return NULL; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
673 } |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
674 PVbuffer[i] = getintvalue(v); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
675 } |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
676 |
|
375
86828cc1c646
Call (*func), not ALgetparams!
Guido van Rossum <guido@python.org>
parents:
369
diff
changeset
|
677 (*func)(device, PVbuffer, length); |
|
369
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
678 |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
679 if (modified) { |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
680 for (i = 0; i < length; i++) |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
681 setlistitem(list, i, newintobject(PVbuffer[i])); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
682 } |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
683 |
|
384
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
684 DEL(PVbuffer); |
|
a3d4d461d442
Added some error checks.
Guido van Rossum <guido@python.org>
parents:
375
diff
changeset
|
685 |
|
369
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
686 INCREF(None); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
687 return None; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
688 } |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
689 |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
690 static object * |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
691 al_getparams(self, args) |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
692 object *self, *args; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
693 { |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
694 return doParams(args, ALgetparams, 1); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
695 } |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
696 |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
697 static object * |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
698 al_setparams(self, args) |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
699 object *self, *args; |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
700 { |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
701 return doParams(args, ALsetparams, 0); |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
702 } |
|
46a656123a69
Added queryparams, get/setparams.
Guido van Rossum <guido@python.org>
parents:
367
diff
changeset
|
703 |
|
973
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
704 static object * |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
705 al_getname(self, args) |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
706 object *self, *args; |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
707 { |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
708 long device, descriptor; |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
709 char *name; |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
710 if (!getargs(args, "(ll)", &device, &descriptor)) |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
711 return NULL; |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
712 name = ALgetname(device, descriptor); |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
713 if (name == NULL) { |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
714 err_setstr(ValueError, "al.getname: bad descriptor"); |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
715 return NULL; |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
716 } |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
717 return newstringobject(name); |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
718 } |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
719 |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
720 static object * |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
721 al_getdefault(self, args) |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
722 object *self, *args; |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
723 { |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
724 long device, descriptor, value; |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
725 if (!getargs(args, "(ll)", &device, &descriptor)) |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
726 return NULL; |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
727 value = ALgetdefault(device, descriptor); |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
728 return newlongobject(value); |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
729 } |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
730 |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
731 static object * |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
732 al_getminmax(self, args) |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
733 object *self, *args; |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
734 { |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
735 long device, descriptor, min, max; |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
736 if (!getargs(args, "(ll)", &device, &descriptor)) |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
737 return NULL; |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
738 min = -1; |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
739 max = -1; |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
740 ALgetminmax(device, descriptor, &min, &max); |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
741 return mkvalue("ll", min, max); |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
742 } |
|
30a290257c31
added getname, getdefault and getminmax functions
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
743 |
| 367 | 744 static struct methodlist al_methods[] = { |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
745 {"openport", (method)al_openport}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
746 {"newconfig", (method)al_newconfig}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
747 {"queryparams", (method)al_queryparams}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
748 {"getparams", (method)al_getparams}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
749 {"setparams", (method)al_setparams}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
750 {"getname", (method)al_getname}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
751 {"getdefault", (method)al_getdefault}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1442
diff
changeset
|
752 {"getminmax", (method)al_getminmax}, |
| 367 | 753 {NULL, NULL} /* sentinel */ |
| 754 }; | |
| 755 | |
| 756 void | |
| 757 inital() | |
| 758 { | |
| 759 initmodule("al", al_methods); | |
| 760 } | |
| 761 | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
762 static int |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
763 getconfigarg(o, conf) |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
764 object *o; |
| 367 | 765 ALconfig *conf; |
| 766 { | |
| 767 if (o == NULL || !is_configobject(o)) | |
| 768 return err_badarg (); | |
| 769 | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
770 *conf = ((configobject *) o) -> ob_config; |
| 367 | 771 |
| 772 return 1; | |
| 773 } | |
| 774 | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
775 static int |
| 367 | 776 getstrstrconfigarg(v, a, b, c) |
| 777 object *v; | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
778 char **a; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
779 char **b; |
| 367 | 780 ALconfig *c; |
| 781 { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
782 object *o; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
384
diff
changeset
|
783 return getargs(v, "(ssO)", a, b, &o) && getconfigarg(o, c); |
| 367 | 784 } |
