blob: a73e1bebc2a7341c338bbbca47d147dbf20e4c8c [file] [log] [blame]
Guido van Rossumd641d671997-04-03 17:06:32 +00001/***********************************************************
Guido van Rossum524b5881995-01-04 19:10:35 +00002Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
3The Netherlands.
Guido van Rossume3db8621991-09-09 23:33:34 +00004
5 All Rights Reserved
6
Guido van Rossumd266eb41996-10-25 14:44:06 +00007Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
Guido van Rossume3db8621991-09-09 23:33:34 +00009provided that the above copyright notice appear in all copies and that
Guido van Rossumd266eb41996-10-25 14:44:06 +000010both that copyright notice and this permission notice appear in
Guido van Rossume3db8621991-09-09 23:33:34 +000011supporting documentation, and that the names of Stichting Mathematisch
Guido van Rossumd266eb41996-10-25 14:44:06 +000012Centrum or CWI or Corporation for National Research Initiatives or
13CNRI not be used in advertising or publicity pertaining to
14distribution of the software without specific, written prior
15permission.
Guido van Rossume3db8621991-09-09 23:33:34 +000016
Guido van Rossumd266eb41996-10-25 14:44:06 +000017While CWI is the initial source for this software, a modified version
18is made available by the Corporation for National Research Initiatives
19(CNRI) at the Internet address ftp://ftp.python.org.
20
21STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
22REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
23MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
24CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
25DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
26PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
27TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28PERFORMANCE OF THIS SOFTWARE.
Guido van Rossume3db8621991-09-09 23:33:34 +000029
30******************************************************************/
31
Guido van Rossumd641d671997-04-03 17:06:32 +000032#define OLD_INTERFACE /* define for pre-Irix 6 interface */
Jack Jansene8a3c281993-02-10 14:10:56 +000033
Roger E. Massea2a8b271997-01-03 22:40:34 +000034#include "Python.h"
Guido van Rossumd641d671997-04-03 17:06:32 +000035#include "stringobject.h"
36#include <audio.h>
37#include <stdarg.h>
Guido van Rossume3db8621991-09-09 23:33:34 +000038
Guido van Rossumd641d671997-04-03 17:06:32 +000039#ifndef AL_NO_ELEM
40#ifndef OLD_INTERFACE
41#define OLD_INTERFACE
42#endif /* OLD_INTERFACE */
43#endif /* AL_NO_ELEM */
44
45static PyObject *ErrorObject;
46
47/* ----------------------------------------------------- */
48
49/* Declarations for objects of type port */
Guido van Rossume3db8621991-09-09 23:33:34 +000050
51typedef struct {
Roger E. Massea2a8b271997-01-03 22:40:34 +000052 PyObject_HEAD
Guido van Rossumd641d671997-04-03 17:06:32 +000053 /* XXXX Add your own stuff here */
54 ALport port;
55} alpobject;
Guido van Rossume3db8621991-09-09 23:33:34 +000056
Guido van Rossumd641d671997-04-03 17:06:32 +000057staticforward PyTypeObject Alptype;
Guido van Rossume3db8621991-09-09 23:33:34 +000058
Guido van Rossume3db8621991-09-09 23:33:34 +000059
Guido van Rossumd641d671997-04-03 17:06:32 +000060
61/* ---------------------------------------------------------------- */
62
63/* Declarations for objects of type config */
64
65typedef struct {
66 PyObject_HEAD
67 /* XXXX Add your own stuff here */
68 ALconfig config;
69} alcobject;
70
71staticforward PyTypeObject Alctype;
72
73
74static void
75ErrorHandler(long code, const char *fmt, ...)
76{
77 va_list args;
78 char buf[128];
79
80 va_start(args, fmt);
81 vsprintf(buf, fmt, args);
82 va_end(args);
83 PyErr_SetString(ErrorObject, buf);
84}
85
86#ifdef AL_NO_ELEM /* IRIX 6 */
Guido van Rossumfc58e581992-01-27 16:45:55 +000087
Roger E. Massea2a8b271997-01-03 22:40:34 +000088static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +000089PyLong_FromLongLong(long long v)
Guido van Rossume3db8621991-09-09 23:33:34 +000090{
Guido van Rossumd641d671997-04-03 17:06:32 +000091 /* XXXX Somewhat complicated way to convert a long long to a PyLong */
92 PyObject *l = NULL, *lhi, *llo;
93 int is_negative = 0;
94 static PyObject *i32; /* 32 as a python long */
Guido van Rossume3db8621991-09-09 23:33:34 +000095
Guido van Rossumd641d671997-04-03 17:06:32 +000096 if (v < 0) {
97 is_negative = 1;
98 v = -v;
99 }
100 lhi = PyLong_FromUnsignedLong((unsigned long) ((unsigned long long) v >> 32));
101 llo = PyLong_FromUnsignedLong((unsigned long) (v & 0xFFFFFFFFLL));
102 if (i32 == NULL)
103 i32 = PyLong_FromLong(32L); /* don't decref */
104 if (PyErr_Occurred())
105 goto error;
106 if ((l = PyNumber_Lshift(lhi, i32)) == NULL)
107 goto error;
108 Py_DECREF(lhi);
109 lhi = l;
110 if ((l = PyNumber_Or(lhi, llo)) == NULL)
111 goto error;
112 Py_DECREF(lhi);
113 Py_DECREF(llo);
114 if (is_negative) {
115 if ((lhi = PyNumber_Negative(l)) == NULL)
116 goto error;
117 Py_DECREF(l);
118 l = lhi;
119 }
120 return l;
Guido van Rossume3db8621991-09-09 23:33:34 +0000121
Guido van Rossumd641d671997-04-03 17:06:32 +0000122 error:
123 Py_XDECREF(lhi);
124 Py_XDECREF(llo);
125 Py_XDECREF(l);
126 return NULL;
127}
Guido van Rossume3db8621991-09-09 23:33:34 +0000128
Guido van Rossumd641d671997-04-03 17:06:32 +0000129static long long
130PyLong_AsLongLong(PyObject *v)
131{
132 /* XXXX Somewhat complicated way to convert a PyLong to a long long */
133 static PyObject *i2_32; /* 2**32 as a python long */
134 PyObject *lhi, *llo;
135 long long ihi;
136 unsigned long long ilo;
137
138 if (!PyLong_Check(v)) {
139 PyErr_BadInternalCall();
140 return -1;
141 }
142 if (i2_32 == NULL)
143 i2_32 = PyLong_FromLongLong(0x100000000LL); /* don't decref */
144 if ((v = PyNumber_Divmod(v, i2_32)) == NULL)
145 return -1;
146 lhi = PyTuple_GetItem(v, 0);
147 llo = PyTuple_GetItem(v, 1);
148 ihi = PyLong_AsLong(lhi);
149 ilo = PyLong_AsUnsignedLong(llo);
150 Py_DECREF(v);
151 return ihi * 0x100000000LL + ilo;
152}
153
154static PyObject *
155param2python(int resource, int param, ALvalue value, ALparamInfo *pinfo)
156{
157 ALparamInfo info;
158 PyObject *v;
159
160 if (pinfo == NULL) {
161 pinfo = &info;
162 if (alGetParamInfo(resource, param, &info) < 0)
163 return NULL;
164 }
165 switch (pinfo->elementType) {
166 case AL_PTR_ELEM:
167 /* XXXX don't know how to handle this */
168 case AL_NO_ELEM:
169 Py_INCREF(Py_None);
170 return Py_None;
171 case AL_INT32_ELEM:
172 case AL_RESOURCE_ELEM:
173 case AL_ENUM_ELEM:
174 return PyInt_FromLong((long) value.i);
175 case AL_INT64_ELEM:
176 return PyLong_FromLongLong(value.ll);
177 case AL_FIXED_ELEM:
178 return PyFloat_FromDouble(alFixedToDouble(value.ll));
179 case AL_CHAR_ELEM:
180 if (value.ptr == NULL) {
181 Py_INCREF(Py_None);
182 return Py_None;
183 }
184 return PyString_FromString((char *) value.ptr);
185 default:
186 PyErr_SetString(ErrorObject, "unknown element type");
187 return NULL;
188 }
189}
190
191static int
192python2elem(PyObject *item, void *ptr, int elementType)
193{
194 switch (elementType) {
195 case AL_INT32_ELEM:
196 case AL_RESOURCE_ELEM:
197 case AL_ENUM_ELEM:
198 if (!PyInt_Check(item)) {
199 PyErr_BadArgument();
200 return -1;
201 }
202 *((int *) ptr) = PyInt_AsLong(item);
203 break;
204 case AL_INT64_ELEM:
205 if (PyInt_Check(item))
206 *((long long *) ptr) = PyInt_AsLong(item);
207 else if (PyLong_Check(item))
208 *((long long *) ptr) = PyLong_AsLongLong(item);
209 else {
210 PyErr_BadArgument();
211 return -1;
212 }
213 break;
214 case AL_FIXED_ELEM:
215 if (PyInt_Check(item))
216 *((long long *) ptr) = alDoubleToFixed((double) PyInt_AsLong(item));
217 else if (PyFloat_Check(item))
218 *((long long *) ptr) = alDoubleToFixed(PyFloat_AsDouble(item));
219 else {
220 PyErr_BadArgument();
221 return -1;
222 }
223 break;
224 default:
225 PyErr_SetString(ErrorObject, "unknown element type");
226 return -1;
227 }
228 return 0;
229}
230
231static int
232python2param(int resource, ALpv *param, PyObject *value, ALparamInfo *pinfo)
233{
234 ALparamInfo info;
235 int i, stepsize;
236 PyObject *item;
237
238 if (pinfo == NULL) {
239 pinfo = &info;
240 if (alGetParamInfo(resource, param->param, &info) < 0)
241 return -1;
242 }
243 switch (pinfo->valueType) {
244 case AL_STRING_VAL:
245 if (pinfo->elementType != AL_CHAR_ELEM) {
246 PyErr_SetString(ErrorObject, "unknown element type");
247 return -1;
248 }
249 if (!PyString_Check(value)) {
250 PyErr_BadArgument();
251 return -1;
252 }
253 param->value.ptr = PyString_AS_STRING(value);
254 param->sizeIn = PyString_GET_SIZE(value)+1; /*account for NUL*/
255 break;
256 case AL_SET_VAL:
257 case AL_VECTOR_VAL:
258 if (!PyList_Check(value) && !PyTuple_Check(value)) {
259 PyErr_BadArgument();
260 return -1;
261 }
262 switch (pinfo->elementType) {
263 case AL_INT32_ELEM:
264 case AL_RESOURCE_ELEM:
265 case AL_ENUM_ELEM:
266 param->sizeIn = PySequence_Length(value);
267 param->value.ptr = PyMem_NEW(int, param->sizeIn);
268 stepsize = sizeof(int);
269 break;
270 case AL_INT64_ELEM:
271 case AL_FIXED_ELEM:
272 param->sizeIn = PySequence_Length(value);
273 param->value.ptr = PyMem_NEW(long long, param->sizeIn);
274 stepsize = sizeof(long long);
275 break;
276 }
277 for (i = 0; i < param->sizeIn; i++) {
278 item = PySequence_GetItem(value, i);
279 if (python2elem(item, (void *) ((char *) param->value.ptr + i*stepsize), pinfo->elementType) < 0) {
280 PyMem_DEL(param->value.ptr);
281 return -1;
282 }
283 }
284 break;
285 case AL_SCALAR_VAL:
286 switch (pinfo->elementType) {
287 case AL_INT32_ELEM:
288 case AL_RESOURCE_ELEM:
289 case AL_ENUM_ELEM:
290 return python2elem(value, (void *) &param->value.i,
291 pinfo->elementType);
292 break;
293 case AL_INT64_ELEM:
294 case AL_FIXED_ELEM:
295 return python2elem(value, (void *) &param->value.ll,
296 pinfo->elementType);
297 break;
298 default:
299 PyErr_SetString(ErrorObject, "unknown element type");
300 return -1;
301 }
302 }
303 return 0;
304}
305
306static int
307python2params(int resource1, int resource2, PyObject *list, ALpv **pvsp, ALparamInfo **pinfop)
308{
309 PyObject *item;
310 ALpv *pvs;
311 ALparamInfo *pinfo;
312 int npvs, i;
313
314 npvs = PyList_Size(list);
315 pvs = PyMem_NEW(ALpv, npvs);
316 pinfo = PyMem_NEW(ALparamInfo, npvs);
317 for (i = 0; i < npvs; i++) {
318 item = PyList_GetItem(list, i);
319 if (!PyArg_ParseTuple(item, "iO", &pvs[i].param, &item))
320 goto error;
321 if (alGetParamInfo(resource1, pvs[i].param, &pinfo[i]) < 0 &&
322 alGetParamInfo(resource2, pvs[i].param, &pinfo[i]) < 0)
323 goto error;
324 if (python2param(resource1, &pvs[i], item, &pinfo[i]) < 0)
325 goto error;
326 }
327
328 *pvsp = pvs;
329 *pinfop = pinfo;
330 return npvs;
331
332 error:
333 /* XXXX we should clean up everything */
334 if (pvs)
335 PyMem_DEL(pvs);
336 if (pinfo)
337 PyMem_DEL(pinfo);
338 return -1;
339}
340
341/* -------------------------------------------------------- */
342
343
344static PyObject *
345SetConfig(self, args, func)
346 alcobject *self;
347 PyObject *args;
348 int (*func)(ALconfig, int);
349{
350 int par;
351
352 if (!PyArg_ParseTuple(args, "i", &par))
353 return NULL;
354
355 if ((*func)(self->config, par) == -1)
356 return NULL;
357
358 Py_INCREF(Py_None);
Roger E. Massea2a8b271997-01-03 22:40:34 +0000359 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +0000360}
361
Roger E. Massea2a8b271997-01-03 22:40:34 +0000362static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000363GetConfig(self, args, func)
364 alcobject *self;
365 PyObject *args;
366 int (*func)(ALconfig);
367{
368 int par;
369
370 if (!PyArg_ParseTuple(args, ""))
371 return NULL;
372
373 if ((par = (*func)(self->config)) == -1)
374 return NULL;
375
376 return PyInt_FromLong((long) par);
377}
378
379static char alc_SetWidth__doc__[] =
380"alSetWidth: set the wordsize for integer audio data."
381;
382
383static PyObject *
384alc_SetWidth(self, args)
385 alcobject *self;
386 PyObject *args;
387{
388 return SetConfig(self, args, alSetWidth);
389}
390
391
392static char alc_GetWidth__doc__[] =
393"alGetWidth: get the wordsize for integer audio data."
394;
395
396static PyObject *
397alc_GetWidth(self, args)
398 alcobject *self;
399 PyObject *args;
400{
401 return GetConfig(self, args, alGetWidth);
402}
403
404
405static char alc_SetSampFmt__doc__[] =
406"alSetSampFmt: set the sample format setting in an audio ALconfig structure."
407;
408
409static PyObject *
410alc_SetSampFmt(self, args)
411 alcobject *self;
412 PyObject *args;
413{
414 return SetConfig(self, args, alSetSampFmt);
415}
416
417
418static char alc_GetSampFmt__doc__[] =
419"alGetSampFmt: get the sample format setting in an audio ALconfig structure."
420;
421
422static PyObject *
423alc_GetSampFmt(self, args)
424 alcobject *self;
425 PyObject *args;
426{
427 return GetConfig(self, args, alGetSampFmt);
428}
429
430
431static char alc_SetChannels__doc__[] =
432"alSetChannels: set the channel settings in an audio ALconfig."
433;
434
435static PyObject *
436alc_SetChannels(self, args)
437 alcobject *self;
438 PyObject *args;
439{
440 return SetConfig(self, args, alSetChannels);
441}
442
443
444static char alc_GetChannels__doc__[] =
445"alGetChannels: get the channel settings in an audio ALconfig."
446;
447
448static PyObject *
449alc_GetChannels(self, args)
450 alcobject *self;
451 PyObject *args;
452{
453 return GetConfig(self, args, alGetChannels);
454}
455
456
457static char alc_SetFloatMax__doc__[] =
458"alSetFloatMax: set the maximum value of floating point sample data."
459;
460
461static PyObject *
462alc_SetFloatMax(self, args)
463 alcobject *self;
464 PyObject *args;
465{
466 double maximum_value;
467
468 if (!PyArg_ParseTuple(args, "d", &maximum_value))
469 return NULL;
470 if (alSetFloatMax(self->config, maximum_value) < 0)
471 return NULL;
472 Py_INCREF(Py_None);
473 return Py_None;
474}
475
476
477static char alc_GetFloatMax__doc__[] =
478"alGetFloatMax: get the maximum value of floating point sample data."
479;
480
481static PyObject *
482alc_GetFloatMax(self, args)
483 alcobject *self;
484 PyObject *args;
485{
486 double maximum_value;
487
488 if (!PyArg_ParseTuple(args, ""))
489 return NULL;
490 if ((maximum_value = alGetFloatMax(self->config)) == 0)
491 return NULL;
492 return PyFloat_FromDouble(maximum_value);
493}
494
495
496static char alc_SetDevice__doc__[] =
497"alSetDevice: set the device setting in an audio ALconfig structure."
498;
499
500static PyObject *
501alc_SetDevice(self, args)
502 alcobject *self;
503 PyObject *args;
504{
505 return SetConfig(self, args, alSetDevice);
506}
507
508
509static char alc_GetDevice__doc__[] =
510"alGetDevice: get the device setting in an audio ALconfig structure."
511;
512
513static PyObject *
514alc_GetDevice(self, args)
515 alcobject *self;
516 PyObject *args;
517{
518 return GetConfig(self, args, alGetDevice);
519}
520
521
522static char alc_SetQueueSize__doc__[] =
523"alSetQueueSize: set audio port buffer size."
524;
525
526static PyObject *
527alc_SetQueueSize(self, args)
528 alcobject *self;
529 PyObject *args;
530{
531 return SetConfig(self, args, alSetQueueSize);
532}
533
534
535static char alc_GetQueueSize__doc__[] =
536"alGetQueueSize: get audio port buffer size."
537;
538
539static PyObject *
540alc_GetQueueSize(self, args)
541 alcobject *self;
542 PyObject *args;
543{
544 return GetConfig(self, args, alGetQueueSize);
545}
546
547#endif /* AL_NO_ELEM */
548
549static PyObject *
550setconfig(self, args, func)
551 alcobject *self;
552 PyObject *args;
553 int (*func)(ALconfig, long);
554{
555 long par;
556
557 if (!PyArg_ParseTuple(args, "l", &par))
558 return NULL;
559
560 if ((*func)(self->config, par) == -1)
561 return NULL;
562
563 Py_INCREF(Py_None);
564 return Py_None;
565}
566
567static PyObject *
568getconfig(self, args, func)
569 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000570 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000571 long (*func)(ALconfig);
572{
573 long par;
574
Guido van Rossumd641d671997-04-03 17:06:32 +0000575 if (!PyArg_ParseTuple(args, ""))
576 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000577
Guido van Rossumd641d671997-04-03 17:06:32 +0000578 if ((par = (*func)(self->config)) == -1)
579 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000580
Guido van Rossumd641d671997-04-03 17:06:32 +0000581 return PyInt_FromLong((long) par);
Guido van Rossume3db8621991-09-09 23:33:34 +0000582}
583
Roger E. Massea2a8b271997-01-03 22:40:34 +0000584static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000585alc_setqueuesize (self, args)
586 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000587 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000588{
Guido van Rossumd641d671997-04-03 17:06:32 +0000589 return setconfig(self, args, ALsetqueuesize);
Guido van Rossume3db8621991-09-09 23:33:34 +0000590}
591
Roger E. Massea2a8b271997-01-03 22:40:34 +0000592static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000593alc_getqueuesize (self, args)
594 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000595 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000596{
Guido van Rossumd641d671997-04-03 17:06:32 +0000597 return getconfig(self, args, ALgetqueuesize);
Guido van Rossume3db8621991-09-09 23:33:34 +0000598}
599
Roger E. Massea2a8b271997-01-03 22:40:34 +0000600static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000601alc_setwidth (self, args)
602 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000603 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000604{
Guido van Rossumd641d671997-04-03 17:06:32 +0000605 return setconfig(self, args, ALsetwidth);
Guido van Rossume3db8621991-09-09 23:33:34 +0000606}
607
Roger E. Massea2a8b271997-01-03 22:40:34 +0000608static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000609alc_getwidth (self, args)
610 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000611 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000612{
Guido van Rossumd641d671997-04-03 17:06:32 +0000613 return getconfig(self, args, ALgetwidth);
Guido van Rossume3db8621991-09-09 23:33:34 +0000614}
615
Roger E. Massea2a8b271997-01-03 22:40:34 +0000616static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000617alc_getchannels (self, args)
618 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000619 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000620{
Guido van Rossumd641d671997-04-03 17:06:32 +0000621 return getconfig(self, args, ALgetchannels);
Guido van Rossume3db8621991-09-09 23:33:34 +0000622}
623
Roger E. Massea2a8b271997-01-03 22:40:34 +0000624static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000625alc_setchannels (self, args)
626 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000627 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000628{
Guido van Rossumd641d671997-04-03 17:06:32 +0000629 return setconfig(self, args, ALsetchannels);
Guido van Rossume3db8621991-09-09 23:33:34 +0000630}
631
Jack Jansene8a3c281993-02-10 14:10:56 +0000632#ifdef AL_405
633
Roger E. Massea2a8b271997-01-03 22:40:34 +0000634static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000635alc_getsampfmt (self, args)
636 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000637 PyObject *args;
Jack Jansene8a3c281993-02-10 14:10:56 +0000638{
Guido van Rossumd641d671997-04-03 17:06:32 +0000639 return getconfig(self, args, ALgetsampfmt);
Jack Jansene8a3c281993-02-10 14:10:56 +0000640}
641
Roger E. Massea2a8b271997-01-03 22:40:34 +0000642static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000643alc_setsampfmt (self, args)
644 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000645 PyObject *args;
Jack Jansene8a3c281993-02-10 14:10:56 +0000646{
Guido van Rossumd641d671997-04-03 17:06:32 +0000647 return setconfig(self, args, ALsetsampfmt);
Jack Jansene8a3c281993-02-10 14:10:56 +0000648}
649
Roger E. Massea2a8b271997-01-03 22:40:34 +0000650static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000651alc_getfloatmax(self, args)
652 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000653 PyObject *args;
Jack Jansene8a3c281993-02-10 14:10:56 +0000654{
655 double arg;
656
Guido van Rossumd641d671997-04-03 17:06:32 +0000657 if (!PyArg_ParseTuple(args, ""))
658 return 0;
659 if ((arg = ALgetfloatmax(self->config)) == 0)
660 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000661 return PyFloat_FromDouble(arg);
Jack Jansene8a3c281993-02-10 14:10:56 +0000662}
663
Roger E. Massea2a8b271997-01-03 22:40:34 +0000664static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000665alc_setfloatmax(self, args)
666 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000667 PyObject *args;
Jack Jansene8a3c281993-02-10 14:10:56 +0000668{
669 double arg;
670
Guido van Rossumd641d671997-04-03 17:06:32 +0000671 if (!PyArg_ParseTuple(args, "d", &arg))
672 return 0;
673 if (ALsetfloatmax(self->config, arg) == -1)
674 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000675 Py_INCREF(Py_None);
676 return Py_None;
Jack Jansene8a3c281993-02-10 14:10:56 +0000677}
678#endif /* AL_405 */
679
Guido van Rossumd641d671997-04-03 17:06:32 +0000680static struct PyMethodDef alc_methods[] = {
681#ifdef AL_NO_ELEM /* IRIX 6 */
682 {"SetWidth", (PyCFunction)alc_SetWidth, METH_VARARGS, alc_SetWidth__doc__},
683 {"GetWidth", (PyCFunction)alc_GetWidth, METH_VARARGS, alc_GetWidth__doc__},
684 {"SetSampFmt", (PyCFunction)alc_SetSampFmt, METH_VARARGS, alc_SetSampFmt__doc__},
685 {"GetSampFmt", (PyCFunction)alc_GetSampFmt, METH_VARARGS, alc_GetSampFmt__doc__},
686 {"SetChannels", (PyCFunction)alc_SetChannels, METH_VARARGS, alc_SetChannels__doc__},
687 {"GetChannels", (PyCFunction)alc_GetChannels, METH_VARARGS, alc_GetChannels__doc__},
688 {"SetFloatMax", (PyCFunction)alc_SetFloatMax, METH_VARARGS, alc_SetFloatMax__doc__},
689 {"GetFloatMax", (PyCFunction)alc_GetFloatMax, METH_VARARGS, alc_GetFloatMax__doc__},
690 {"SetDevice", (PyCFunction)alc_SetDevice, METH_VARARGS, alc_SetDevice__doc__},
691 {"GetDevice", (PyCFunction)alc_GetDevice, METH_VARARGS, alc_GetDevice__doc__},
692 {"SetQueueSize", (PyCFunction)alc_SetQueueSize, METH_VARARGS, alc_SetQueueSize__doc__},
693 {"GetQueueSize", (PyCFunction)alc_GetQueueSize, METH_VARARGS, alc_GetQueueSize__doc__},
694#endif /* AL_NO_ELEM */
695 {"getqueuesize", (PyCFunction)alc_getqueuesize, METH_VARARGS},
696 {"setqueuesize", (PyCFunction)alc_setqueuesize, METH_VARARGS},
697 {"getwidth", (PyCFunction)alc_getwidth, METH_VARARGS},
698 {"setwidth", (PyCFunction)alc_setwidth, METH_VARARGS},
699 {"getchannels", (PyCFunction)alc_getchannels, METH_VARARGS},
700 {"setchannels", (PyCFunction)alc_setchannels, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +0000701#ifdef AL_405
Guido van Rossumd641d671997-04-03 17:06:32 +0000702 {"getsampfmt", (PyCFunction)alc_getsampfmt, METH_VARARGS},
703 {"setsampfmt", (PyCFunction)alc_setsampfmt, METH_VARARGS},
704 {"getfloatmax", (PyCFunction)alc_getfloatmax, METH_VARARGS},
705 {"setfloatmax", (PyCFunction)alc_setfloatmax, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +0000706#endif /* AL_405 */
Guido van Rossumd641d671997-04-03 17:06:32 +0000707
708 {NULL, NULL} /* sentinel */
Guido van Rossume3db8621991-09-09 23:33:34 +0000709};
710
Guido van Rossumd641d671997-04-03 17:06:32 +0000711/* ---------- */
712
713
714static PyObject *
715newalcobject(ALconfig config)
Guido van Rossume3db8621991-09-09 23:33:34 +0000716{
Guido van Rossumd641d671997-04-03 17:06:32 +0000717 alcobject *self;
718
719 self = PyObject_NEW(alcobject, &Alctype);
720 if (self == NULL)
721 return NULL;
722 /* XXXX Add your own initializers here */
723 self->config = config;
724 return (PyObject *) self;
725}
726
727
728static void
729alc_dealloc(self)
730 alcobject *self;
731{
732 /* XXXX Add your own cleanup code here */
733#ifdef AL_NO_ELEM /* IRIX 6 */
734 (void) alFreeConfig(self->config); /* ignore errors */
735#else
736 (void) ALfreeconfig(self->config); /* ignore errors */
737#endif
Roger E. Massea2a8b271997-01-03 22:40:34 +0000738 PyMem_DEL(self);
Guido van Rossume3db8621991-09-09 23:33:34 +0000739}
740
Roger E. Massea2a8b271997-01-03 22:40:34 +0000741static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000742alc_getattr(self, name)
743 alcobject *self;
Guido van Rossume3db8621991-09-09 23:33:34 +0000744 char *name;
745{
Guido van Rossumd641d671997-04-03 17:06:32 +0000746 /* XXXX Add your own getattr code here */
747 return Py_FindMethod(alc_methods, (PyObject *)self, name);
Guido van Rossume3db8621991-09-09 23:33:34 +0000748}
749
Guido van Rossumd641d671997-04-03 17:06:32 +0000750static char Alctype__doc__[] =
751""
752;
753
754static PyTypeObject Alctype = {
Roger E. Massea2a8b271997-01-03 22:40:34 +0000755 PyObject_HEAD_INIT(&PyType_Type)
Guido van Rossumd641d671997-04-03 17:06:32 +0000756 0, /*ob_size*/
757 "config", /*tp_name*/
758 sizeof(alcobject), /*tp_basicsize*/
759 0, /*tp_itemsize*/
Guido van Rossume3db8621991-09-09 23:33:34 +0000760 /* methods */
Guido van Rossumd641d671997-04-03 17:06:32 +0000761 (destructor)alc_dealloc, /*tp_dealloc*/
762 (printfunc)0, /*tp_print*/
763 (getattrfunc)alc_getattr, /*tp_getattr*/
764 (setattrfunc)0, /*tp_setattr*/
765 (cmpfunc)0, /*tp_compare*/
766 (reprfunc)0, /*tp_repr*/
767 0, /*tp_as_number*/
768 0, /*tp_as_sequence*/
769 0, /*tp_as_mapping*/
770 (hashfunc)0, /*tp_hash*/
771 (ternaryfunc)0, /*tp_call*/
772 (reprfunc)0, /*tp_str*/
773
774 /* Space for future expansion */
775 0L,0L,0L,0L,
776 Alctype__doc__ /* Documentation string */
Guido van Rossume3db8621991-09-09 23:33:34 +0000777};
778
Guido van Rossumd641d671997-04-03 17:06:32 +0000779/* End of code for config objects */
780/* ---------------------------------------------------------------- */
Guido van Rossume3db8621991-09-09 23:33:34 +0000781
Guido van Rossumd641d671997-04-03 17:06:32 +0000782#ifdef AL_NO_ELEM /* IRIX 6 */
Guido van Rossume3db8621991-09-09 23:33:34 +0000783
Guido van Rossumd641d671997-04-03 17:06:32 +0000784static char alp_SetConfig__doc__[] =
785"alSetConfig: set the ALconfig of an audio ALport."
786;
Guido van Rossume3db8621991-09-09 23:33:34 +0000787
Roger E. Massea2a8b271997-01-03 22:40:34 +0000788static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000789alp_SetConfig(self, args)
790 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000791 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000792{
Guido van Rossumd641d671997-04-03 17:06:32 +0000793 alcobject *config;
794 if (!PyArg_ParseTuple(args, "O!", &Alctype, &config))
795 return NULL;
796 if (alSetConfig(self->port, config->config) < 0)
797 return NULL;
798 Py_INCREF(Py_None);
Roger E. Massea2a8b271997-01-03 22:40:34 +0000799 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +0000800}
801
Guido van Rossumd641d671997-04-03 17:06:32 +0000802
803static char alp_GetConfig__doc__[] =
804"alGetConfig: get the ALconfig of an audio ALport."
805;
806
Roger E. Massea2a8b271997-01-03 22:40:34 +0000807static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000808alp_GetConfig(self, args)
809 alpobject *self;
810 PyObject *args;
811{
812 ALconfig config;
813 if (!PyArg_ParseTuple(args, ""))
814 return NULL;
815 if ((config = alGetConfig(self->port)) == NULL)
816 return NULL;
817 return newalcobject(config);
818}
819
820
821static char alp_GetResource__doc__[] =
822"alGetResource: get the resource associated with an audio port."
823;
824
825static PyObject *
826alp_GetResource(self, args)
827 alpobject *self;
828 PyObject *args;
829{
830 int resource;
831
832 if (!PyArg_ParseTuple(args, ""))
833 return NULL;
834 if ((resource = alGetResource(self->port)) == 0)
835 return NULL;
836 return PyInt_FromLong((long) resource);
837}
838
839
840static char alp_GetFD__doc__[] =
841"alGetFD: get the file descriptor for an audio port."
842;
843
844static PyObject *
845alp_GetFD(self, args)
846 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000847 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000848{
849 int fd;
850
Guido van Rossumd641d671997-04-03 17:06:32 +0000851 if (!PyArg_ParseTuple(args, ""))
852 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000853
Guido van Rossumd641d671997-04-03 17:06:32 +0000854 if ((fd = alGetFD(self->port)) < 0)
855 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000856
Guido van Rossumd641d671997-04-03 17:06:32 +0000857 return PyInt_FromLong((long) fd);
858}
859
860
861static char alp_GetFilled__doc__[] =
862"alGetFilled: return the number of filled sample frames in an audio port."
863;
864
865static PyObject *
866alp_GetFilled(self, args)
867 alpobject *self;
868 PyObject *args;
869{
870 int filled;
871
872 if (!PyArg_ParseTuple(args, ""))
873 return NULL;
874 if ((filled = alGetFilled(self->port)) < 0)
875 return NULL;
876 return PyInt_FromLong((long) filled);
877}
878
879
880static char alp_GetFillable__doc__[] =
881"alGetFillable: report the number of unfilled sample frames in an audio port."
882;
883
884static PyObject *
885alp_GetFillable(self, args)
886 alpobject *self;
887 PyObject *args;
888{
889 int fillable;
890
891 if (!PyArg_ParseTuple(args, ""))
892 return NULL;
893 if ((fillable = alGetFillable(self->port)) < 0)
894 return NULL;
895 return PyInt_FromLong((long) fillable);
896}
897
898
899static char alp_ReadFrames__doc__[] =
900"alReadFrames: read sample frames from an audio port."
901;
902
903static PyObject *
904alp_ReadFrames(self, args)
905 alpobject *self;
906 PyObject *args;
907{
908 void *samples;
909 int framecount;
910 PyObject *v;
911 int size;
912 int ch;
913 ALconfig c;
914
915 if (!PyArg_ParseTuple(args, "i", framecount))
916 return NULL;
917 if (framecount < 0) {
918 PyErr_SetString(ErrorObject, "negative framecount");
919 return NULL;
920 }
921 c = alGetConfig(self->port);
922 switch (alGetSampFmt(c)) {
923 case AL_SAMPFMT_TWOSCOMP:
924 switch (alGetWidth(c)) {
925 case AL_SAMPLE_8:
926 size = 1;
927 break;
928 case AL_SAMPLE_16:
929 size = 2;
930 break;
931 case AL_SAMPLE_24:
932 size = 4;
933 break;
934 default:
935 PyErr_SetString(ErrorObject, "can't determine width");
936 alFreeConfig(c);
937 return NULL;
938 }
939 break;
940 case AL_SAMPFMT_FLOAT:
941 size = 4;
942 break;
943 case AL_SAMPFMT_DOUBLE:
944 size = 8;
945 break;
946 default:
947 PyErr_SetString(ErrorObject, "can't determine format");
948 alFreeConfig(c);
949 return NULL;
950 }
951 ch = alGetChannels(c);
952 alFreeConfig(c);
953 if (ch < 0) {
954 PyErr_SetString(ErrorObject, "can't determine # of channels");
955 return NULL;
956 }
957 size *= ch;
958 v = PyString_FromStringAndSize((char *) NULL, size * framecount);
959 if (v == NULL)
960 return NULL;
961
962 Py_BEGIN_ALLOW_THREADS
963 alReadFrames(self->port, (void *) PyString_AS_STRING(v), framecount);
964 Py_END_ALLOW_THREADS
965
966 return v;
967}
968
969
970static char alp_DiscardFrames__doc__[] =
971"alDiscardFrames: discard audio from an audio port."
972;
973
974static PyObject *
975alp_DiscardFrames(self, args)
976 alpobject *self;
977 PyObject *args;
978{
979 int framecount;
980
981 if (!PyArg_ParseTuple(args, "i", &framecount))
982 return NULL;
983
984 Py_BEGIN_ALLOW_THREADS
985 framecount = alDiscardFrames(self->port, framecount);
986 Py_END_ALLOW_THREADS
987
988 if (framecount < 0)
989 return NULL;
990
991 return PyInt_FromLong((long) framecount);
992}
993
994
995static char alp_ZeroFrames__doc__[] =
996"alZeroFrames: write zero-valued sample frames to an audio port."
997;
998
999static PyObject *
1000alp_ZeroFrames(self, args)
1001 alpobject *self;
1002 PyObject *args;
1003{
1004 int framecount;
1005
1006 if (!PyArg_ParseTuple(args, "i", &framecount))
1007 return NULL;
1008
1009 if (framecount < 0) {
1010 PyErr_SetString(ErrorObject, "negative framecount");
1011 return NULL;
1012 }
1013
1014 Py_BEGIN_ALLOW_THREADS
1015 alZeroFrames(self->port, framecount);
1016 Py_END_ALLOW_THREADS
1017
1018 Py_INCREF(Py_None);
1019 return Py_None;
1020}
1021
1022
1023static char alp_SetFillPoint__doc__[] =
1024"alSetFillPoint: set low- or high-water mark for an audio port."
1025;
1026
1027static PyObject *
1028alp_SetFillPoint(self, args)
1029 alpobject *self;
1030 PyObject *args;
1031{
1032 int fillpoint;
1033
1034 if (!PyArg_ParseTuple(args, "i", &fillpoint))
1035 return NULL;
1036
1037 if (alSetFillPoint(self->port, fillpoint) < 0)
1038 return NULL;
1039
1040 Py_INCREF(Py_None);
1041 return Py_None;
1042}
1043
1044
1045static char alp_GetFillPoint__doc__[] =
1046"alGetFillPoint: get low- or high-water mark for an audio port."
1047;
1048
1049static PyObject *
1050alp_GetFillPoint(self, args)
1051 alpobject *self;
1052 PyObject *args;
1053{
1054 int fillpoint;
1055
1056 if (!PyArg_ParseTuple(args, ""))
1057 return NULL;
1058
1059 if ((fillpoint = alGetFillPoint(self->port)) < 0)
1060 return NULL;
1061
1062 return PyInt_FromLong((long) fillpoint);
1063}
1064
1065
1066static char alp_GetFrameNumber__doc__[] =
1067"alGetFrameNumber: get the absolute sample frame number associated with a port."
1068;
1069
1070static PyObject *
1071alp_GetFrameNumber(self, args)
1072 alpobject *self;
1073 PyObject *args;
1074{
1075 stamp_t fnum;
1076
1077 if (!PyArg_ParseTuple(args, ""))
1078 return NULL;
1079
1080 if (alGetFrameNumber(self->port, &fnum) < 0)
1081 return NULL;
1082
1083 return PyLong_FromLongLong((long long) fnum);
1084}
1085
1086
1087static char alp_GetFrameTime__doc__[] =
1088"alGetFrameTime: get the time at which a sample frame came in or will go out."
1089;
1090
1091static PyObject *
1092alp_GetFrameTime(self, args)
1093 alpobject *self;
1094 PyObject *args;
1095{
1096 stamp_t fnum, time;
1097 PyObject *ret, *v0, *v1;
1098
1099 if (!PyArg_ParseTuple(args, ""))
1100 return NULL;
1101 if (alGetFrameTime(self->port, &fnum, &time) < 0)
1102 return NULL;
1103 v0 = PyLong_FromLongLong((long long) fnum);
1104 v1 = PyLong_FromLongLong((long long) time);
1105 if (PyErr_Occurred()) {
1106 Py_XDECREF(v0);
1107 Py_XDECREF(v1);
1108 return NULL;
1109 }
1110 ret = Py_BuildValue("(OO)", v0, v1);
1111 Py_DECREF(v0);
1112 Py_DECREF(v1);
1113 return ret;
1114}
1115
1116
1117static char alp_WriteFrames__doc__[] =
1118"alWriteFrames: write sample frames to an audio port."
1119;
1120
1121static PyObject *
1122alp_WriteFrames(self, args)
1123 alpobject *self;
1124 PyObject *args;
1125{
1126 char *samples;
1127 int length;
1128 int size, ch;
1129 ALconfig c;
1130
1131 if (!PyArg_ParseTuple(args, "s#", &samples, &length))
1132 return NULL;
1133 c = alGetConfig(self->port);
1134 switch (alGetSampFmt(c)) {
1135 case AL_SAMPFMT_TWOSCOMP:
1136 switch (alGetWidth(c)) {
1137 case AL_SAMPLE_8:
1138 size = 1;
1139 break;
1140 case AL_SAMPLE_16:
1141 size = 2;
1142 break;
1143 case AL_SAMPLE_24:
1144 size = 4;
1145 break;
1146 default:
1147 PyErr_SetString(ErrorObject, "can't determine width");
1148 alFreeConfig(c);
1149 return NULL;
1150 }
1151 break;
1152 case AL_SAMPFMT_FLOAT:
1153 size = 4;
1154 break;
1155 case AL_SAMPFMT_DOUBLE:
1156 size = 8;
1157 break;
1158 default:
1159 PyErr_SetString(ErrorObject, "can't determine format");
1160 alFreeConfig(c);
1161 return NULL;
1162 }
1163 ch = alGetChannels(c);
1164 alFreeConfig(c);
1165 if (ch < 0) {
1166 PyErr_SetString(ErrorObject, "can't determine # of channels");
1167 return NULL;
1168 }
1169 size *= ch;
1170 if (length % size != 0) {
1171 PyErr_SetString(ErrorObject,
1172 "buffer length not whole number of frames");
1173 return NULL;
1174 }
1175
1176 Py_BEGIN_ALLOW_THREADS
1177 alWriteFrames(self->port, (void *) samples, length / size);
1178 Py_END_ALLOW_THREADS
1179
1180 Py_INCREF(Py_None);
1181 return Py_None;
1182}
1183
1184
1185static char alp_ClosePort__doc__[] =
1186"alClosePort: close an audio port."
1187;
1188
1189static PyObject *
1190alp_ClosePort(self, args)
1191 alpobject *self;
1192 PyObject *args;
1193{
1194 if (!PyArg_ParseTuple(args, ""))
1195 return NULL;
1196 if (alClosePort(self->port) < 0)
1197 return NULL;
1198 self->port = NULL;
1199 Py_INCREF(Py_None);
1200 return Py_None;
1201}
1202
1203#endif /* AL_NO_ELEM */
1204
1205#ifdef OLD_INTERFACE
1206static PyObject *
1207alp_closeport(self, args)
1208 alpobject *self;
1209 PyObject *args;
1210{
1211 if (!PyArg_ParseTuple(args, ""))
1212 return NULL;
1213 if (ALcloseport(self->port) < 0)
1214 return NULL;
1215 self->port = NULL;
1216 Py_INCREF(Py_None);
1217 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +00001218}
1219
Roger E. Massea2a8b271997-01-03 22:40:34 +00001220static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001221alp_getfd (self, args)
1222 alpobject *self;
1223 PyObject *args;
1224{
1225 int fd;
1226
1227 if (!PyArg_ParseTuple(args, ""))
1228 return NULL;
1229 if ((fd = ALgetfd(self-> port)) == -1)
1230 return NULL;
1231 return PyInt_FromLong(fd);
1232}
1233
1234static PyObject *
1235alp_getfilled(self, args)
1236 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001237 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001238{
1239 long count;
1240
Guido van Rossumd641d671997-04-03 17:06:32 +00001241 if (!PyArg_ParseTuple(args, ""))
1242 return NULL;
1243 if ((count = ALgetfilled(self-> port)) == -1)
1244 return NULL;
1245 return PyInt_FromLong(count);
Guido van Rossume3db8621991-09-09 23:33:34 +00001246}
1247
Roger E. Massea2a8b271997-01-03 22:40:34 +00001248static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001249alp_getfillable(self, args)
1250 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001251 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001252{
1253 long count;
1254
Guido van Rossumd641d671997-04-03 17:06:32 +00001255 if (!PyArg_ParseTuple(args, ""))
1256 return NULL;
1257 if ((count = ALgetfillable(self-> port)) == -1)
1258 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001259 return PyInt_FromLong (count);
Guido van Rossume3db8621991-09-09 23:33:34 +00001260}
1261
Roger E. Massea2a8b271997-01-03 22:40:34 +00001262static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001263alp_readsamps(self, args)
1264 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001265 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001266{
1267 long count;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001268 PyObject *v;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001269 ALconfig c;
Guido van Rossume3db8621991-09-09 23:33:34 +00001270 int width;
Guido van Rossumd641d671997-04-03 17:06:32 +00001271 int ret;
Guido van Rossume3db8621991-09-09 23:33:34 +00001272
Guido van Rossumd641d671997-04-03 17:06:32 +00001273 if (!PyArg_ParseTuple(args, "l", &count))
1274 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001275
Guido van Rossumd641d671997-04-03 17:06:32 +00001276 if (count <= 0) {
1277 PyErr_SetString(ErrorObject, "al.readsamps : arg <= 0");
Guido van Rossume3db8621991-09-09 23:33:34 +00001278 return NULL;
1279 }
1280
Guido van Rossumd641d671997-04-03 17:06:32 +00001281 c = ALgetconfig(self->port);
Jack Jansene8a3c281993-02-10 14:10:56 +00001282#ifdef AL_405
1283 width = ALgetsampfmt(c);
Guido van Rossumd641d671997-04-03 17:06:32 +00001284 if (width == AL_SAMPFMT_FLOAT)
1285 width = sizeof(float);
1286 else if (width == AL_SAMPFMT_DOUBLE)
1287 width = sizeof(double);
Jack Jansene8a3c281993-02-10 14:10:56 +00001288 else
Guido van Rossumd641d671997-04-03 17:06:32 +00001289 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001290#else
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001291 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001292#endif /* AL_405 */
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001293 ALfreeconfig(c);
Guido van Rossumd641d671997-04-03 17:06:32 +00001294 v = PyString_FromStringAndSize((char *)NULL, width * count);
1295 if (v == NULL)
1296 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001297
Roger E. Massea2a8b271997-01-03 22:40:34 +00001298 Py_BEGIN_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001299 ret = ALreadsamps(self->port, (void *) PyString_AsString(v), count);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001300 Py_END_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001301 if (ret == -1) {
1302 Py_DECREF(v);
1303 return NULL;
1304 }
Guido van Rossume3db8621991-09-09 23:33:34 +00001305
1306 return (v);
1307}
1308
Roger E. Massea2a8b271997-01-03 22:40:34 +00001309static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001310alp_writesamps(self, args)
1311 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001312 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001313{
Guido van Rossumfc58e581992-01-27 16:45:55 +00001314 char *buf;
1315 int size, width;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001316 ALconfig c;
Guido van Rossumd641d671997-04-03 17:06:32 +00001317 int ret;
Guido van Rossume3db8621991-09-09 23:33:34 +00001318
Guido van Rossumd641d671997-04-03 17:06:32 +00001319 if (!PyArg_ParseTuple(args, "s#", &buf, &size))
1320 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001321
Guido van Rossumd641d671997-04-03 17:06:32 +00001322 c = ALgetconfig(self->port);
Jack Jansene8a3c281993-02-10 14:10:56 +00001323#ifdef AL_405
1324 width = ALgetsampfmt(c);
Guido van Rossumd641d671997-04-03 17:06:32 +00001325 if (width == AL_SAMPFMT_FLOAT)
1326 width = sizeof(float);
1327 else if (width == AL_SAMPFMT_DOUBLE)
1328 width = sizeof(double);
Jack Jansene8a3c281993-02-10 14:10:56 +00001329 else
Guido van Rossumd641d671997-04-03 17:06:32 +00001330 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001331#else
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001332 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001333#endif /* AL_405 */
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001334 ALfreeconfig(c);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001335 Py_BEGIN_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001336 ret = ALwritesamps (self->port, (void *) buf, (long) size / width);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001337 Py_END_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001338 if (ret == -1)
1339 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001340
Guido van Rossumd641d671997-04-03 17:06:32 +00001341 Py_INCREF(Py_None);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001342 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +00001343}
1344
Roger E. Massea2a8b271997-01-03 22:40:34 +00001345static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001346alp_getfillpoint(self, args)
1347 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001348 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001349{
1350 long count;
1351
Guido van Rossumd641d671997-04-03 17:06:32 +00001352 if (!PyArg_ParseTuple(args, ""))
1353 return NULL;
1354 if ((count = ALgetfillpoint(self->port)) == -1)
1355 return NULL;
1356 return PyInt_FromLong(count);
Guido van Rossume3db8621991-09-09 23:33:34 +00001357}
1358
Roger E. Massea2a8b271997-01-03 22:40:34 +00001359static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001360alp_setfillpoint (self, args)
1361 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001362 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001363{
1364 long count;
1365
Guido van Rossumd641d671997-04-03 17:06:32 +00001366 if (!PyArg_ParseTuple(args, "l", &count))
1367 return NULL;
1368 if (ALsetfillpoint(self->port, count) == -1)
1369 return NULL;
1370 Py_INCREF(Py_None);
1371 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +00001372}
1373
Roger E. Massea2a8b271997-01-03 22:40:34 +00001374static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001375alp_setconfig(self, args)
1376 alpobject *self;
1377 PyObject *args;
1378{
1379 alcobject *config;
1380
1381 if (!PyArg_ParseTuple(args, "O!", &Alctype, &config))
1382 return NULL;
1383 if (ALsetconfig(self->port, config->config) == -1)
1384 return NULL;
1385 Py_INCREF(Py_None);
1386 return Py_None;
1387}
1388
1389static PyObject *
1390alp_getconfig(self, args)
1391 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001392 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001393{
1394 ALconfig config;
1395
Guido van Rossumd641d671997-04-03 17:06:32 +00001396 if (!PyArg_ParseTuple(args, ""))
1397 return NULL;
1398 config = ALgetconfig(self->port);
1399 if (config == NULL)
1400 return NULL;
1401 return newalcobject(config);
Guido van Rossume3db8621991-09-09 23:33:34 +00001402}
1403
Jack Jansene8a3c281993-02-10 14:10:56 +00001404#ifdef AL_405
Roger E. Massea2a8b271997-01-03 22:40:34 +00001405static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001406alp_getstatus(self, args)
1407 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001408 PyObject *args;
Jack Jansene8a3c281993-02-10 14:10:56 +00001409{
Roger E. Massea2a8b271997-01-03 22:40:34 +00001410 PyObject *list, *v;
Jack Jansene8a3c281993-02-10 14:10:56 +00001411 long *PVbuffer;
1412 long length;
1413 int i;
1414
Guido van Rossumd641d671997-04-03 17:06:32 +00001415 if (!PyArg_Parse(args, "O!", &PyList_Type, &list))
Jack Jansene8a3c281993-02-10 14:10:56 +00001416 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001417 length = PyList_Size(list);
1418 PVbuffer = PyMem_NEW(long, length);
Jack Jansene8a3c281993-02-10 14:10:56 +00001419 if (PVbuffer == NULL)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001420 return PyErr_NoMemory();
Jack Jansene8a3c281993-02-10 14:10:56 +00001421 for (i = 0; i < length; i++) {
Roger E. Massea2a8b271997-01-03 22:40:34 +00001422 v = PyList_GetItem(list, i);
1423 if (!PyInt_Check(v)) {
1424 PyMem_DEL(PVbuffer);
1425 PyErr_BadArgument();
Jack Jansene8a3c281993-02-10 14:10:56 +00001426 return NULL;
1427 }
Roger E. Massea2a8b271997-01-03 22:40:34 +00001428 PVbuffer[i] = PyInt_AsLong(v);
Jack Jansene8a3c281993-02-10 14:10:56 +00001429 }
1430
Guido van Rossumd641d671997-04-03 17:06:32 +00001431 if (ALgetstatus(self->port, PVbuffer, length) == -1)
1432 return NULL;
Jack Jansene8a3c281993-02-10 14:10:56 +00001433
1434 for (i = 0; i < length; i++)
Guido van Rossumd641d671997-04-03 17:06:32 +00001435 PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i]));
Jack Jansene8a3c281993-02-10 14:10:56 +00001436
Roger E. Massea2a8b271997-01-03 22:40:34 +00001437 PyMem_DEL(PVbuffer);
Jack Jansene8a3c281993-02-10 14:10:56 +00001438
Roger E. Massea2a8b271997-01-03 22:40:34 +00001439 Py_INCREF(Py_None);
1440 return Py_None;
Jack Jansene8a3c281993-02-10 14:10:56 +00001441}
1442#endif /* AL_405 */
1443
Guido van Rossumd641d671997-04-03 17:06:32 +00001444#endif /* OLD_INTERFACE */
1445
1446static struct PyMethodDef alp_methods[] = {
1447#ifdef AL_NO_ELEM /* IRIX 6 */
1448 {"SetConfig", (PyCFunction)alp_SetConfig, METH_VARARGS, alp_SetConfig__doc__},
1449 {"GetConfig", (PyCFunction)alp_GetConfig, METH_VARARGS, alp_GetConfig__doc__},
1450 {"GetResource", (PyCFunction)alp_GetResource, METH_VARARGS, alp_GetResource__doc__},
1451 {"GetFD", (PyCFunction)alp_GetFD, METH_VARARGS, alp_GetFD__doc__},
1452 {"GetFilled", (PyCFunction)alp_GetFilled, METH_VARARGS, alp_GetFilled__doc__},
1453 {"GetFillable", (PyCFunction)alp_GetFillable, METH_VARARGS, alp_GetFillable__doc__},
1454 {"ReadFrames", (PyCFunction)alp_ReadFrames, METH_VARARGS, alp_ReadFrames__doc__},
1455 {"DiscardFrames", (PyCFunction)alp_DiscardFrames, METH_VARARGS, alp_DiscardFrames__doc__},
1456 {"ZeroFrames", (PyCFunction)alp_ZeroFrames, METH_VARARGS, alp_ZeroFrames__doc__},
1457 {"SetFillPoint", (PyCFunction)alp_SetFillPoint, METH_VARARGS, alp_SetFillPoint__doc__},
1458 {"GetFillPoint", (PyCFunction)alp_GetFillPoint, METH_VARARGS, alp_GetFillPoint__doc__},
1459 {"GetFrameNumber", (PyCFunction)alp_GetFrameNumber, METH_VARARGS, alp_GetFrameNumber__doc__},
1460 {"GetFrameTime", (PyCFunction)alp_GetFrameTime, METH_VARARGS, alp_GetFrameTime__doc__},
1461 {"WriteFrames", (PyCFunction)alp_WriteFrames, METH_VARARGS, alp_WriteFrames__doc__},
1462 {"ClosePort", (PyCFunction)alp_ClosePort, METH_VARARGS, alp_ClosePort__doc__},
1463#endif /* AL_NO_ELEM */
1464#ifdef OLD_INTERFACE
1465 {"closeport", (PyCFunction)alp_closeport, METH_VARARGS},
1466 {"getfd", (PyCFunction)alp_getfd, METH_VARARGS},
1467 {"fileno", (PyCFunction)alp_getfd, METH_VARARGS},
1468 {"getfilled", (PyCFunction)alp_getfilled, METH_VARARGS},
1469 {"getfillable", (PyCFunction)alp_getfillable, METH_VARARGS},
1470 {"readsamps", (PyCFunction)alp_readsamps, METH_VARARGS},
1471 {"writesamps", (PyCFunction)alp_writesamps, METH_VARARGS},
1472 {"setfillpoint", (PyCFunction)alp_setfillpoint, METH_VARARGS},
1473 {"getfillpoint", (PyCFunction)alp_getfillpoint, METH_VARARGS},
1474 {"setconfig", (PyCFunction)alp_setconfig, METH_VARARGS},
1475 {"getconfig", (PyCFunction)alp_getconfig, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +00001476#ifdef AL_405
Guido van Rossumd641d671997-04-03 17:06:32 +00001477 {"getstatus", (PyCFunction)alp_getstatus, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +00001478#endif /* AL_405 */
Guido van Rossumd641d671997-04-03 17:06:32 +00001479#endif /* OLD_INTERFACE */
1480
1481 {NULL, NULL} /* sentinel */
Guido van Rossume3db8621991-09-09 23:33:34 +00001482};
1483
Guido van Rossumd641d671997-04-03 17:06:32 +00001484/* ---------- */
1485
1486
1487static PyObject *
1488newalpobject(ALport port)
1489{
1490 alpobject *self;
1491
1492 self = PyObject_NEW(alpobject, &Alptype);
1493 if (self == NULL)
1494 return NULL;
1495 /* XXXX Add your own initializers here */
1496 self->port = port;
1497 return (PyObject *) self;
1498}
1499
1500
Guido van Rossume3db8621991-09-09 23:33:34 +00001501static void
Guido van Rossumd641d671997-04-03 17:06:32 +00001502alp_dealloc(self)
1503 alpobject *self;
Guido van Rossume3db8621991-09-09 23:33:34 +00001504{
Guido van Rossumd641d671997-04-03 17:06:32 +00001505 /* XXXX Add your own cleanup code here */
1506 if (self->port) {
1507#ifdef AL_NO_ELEM /* IRIX 6 */
1508 alClosePort(self->port);
1509#else
1510 ALcloseport(self->port);
1511#endif
1512 }
1513 PyMem_DEL(self);
Guido van Rossume3db8621991-09-09 23:33:34 +00001514}
1515
Roger E. Massea2a8b271997-01-03 22:40:34 +00001516static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001517alp_getattr(self, name)
1518 alpobject *self;
Guido van Rossume3db8621991-09-09 23:33:34 +00001519 char *name;
1520{
Guido van Rossumd641d671997-04-03 17:06:32 +00001521 /* XXXX Add your own getattr code here */
1522 if (self->port == NULL) {
1523 PyErr_SetString(ErrorObject, "port already closed");
1524 return NULL;
1525 }
1526 return Py_FindMethod(alp_methods, (PyObject *)self, name);
Guido van Rossume3db8621991-09-09 23:33:34 +00001527}
1528
Guido van Rossumd641d671997-04-03 17:06:32 +00001529static char Alptype__doc__[] =
1530""
1531;
1532
1533static PyTypeObject Alptype = {
Roger E. Massea2a8b271997-01-03 22:40:34 +00001534 PyObject_HEAD_INIT(&PyType_Type)
Guido van Rossumd641d671997-04-03 17:06:32 +00001535 0, /*ob_size*/
Guido van Rossume3db8621991-09-09 23:33:34 +00001536 "port", /*tp_name*/
Guido van Rossumd641d671997-04-03 17:06:32 +00001537 sizeof(alpobject), /*tp_basicsize*/
1538 0, /*tp_itemsize*/
Guido van Rossume3db8621991-09-09 23:33:34 +00001539 /* methods */
Guido van Rossumd641d671997-04-03 17:06:32 +00001540 (destructor)alp_dealloc, /*tp_dealloc*/
1541 (printfunc)0, /*tp_print*/
1542 (getattrfunc)alp_getattr, /*tp_getattr*/
1543 (setattrfunc)0, /*tp_setattr*/
1544 (cmpfunc)0, /*tp_compare*/
1545 (reprfunc)0, /*tp_repr*/
1546 0, /*tp_as_number*/
1547 0, /*tp_as_sequence*/
1548 0, /*tp_as_mapping*/
1549 (hashfunc)0, /*tp_hash*/
1550 (ternaryfunc)0, /*tp_call*/
1551 (reprfunc)0, /*tp_str*/
1552
1553 /* Space for future expansion */
1554 0L,0L,0L,0L,
1555 Alptype__doc__ /* Documentation string */
Guido van Rossume3db8621991-09-09 23:33:34 +00001556};
1557
Guido van Rossumd641d671997-04-03 17:06:32 +00001558/* End of code for port objects */
1559/* -------------------------------------------------------- */
1560
1561
1562#ifdef AL_NO_ELEM /* IRIX 6 */
1563
1564static char al_NewConfig__doc__[] =
1565"alNewConfig: create and initialize an audio ALconfig structure."
1566;
1567
Roger E. Massea2a8b271997-01-03 22:40:34 +00001568static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001569al_NewConfig(self, args)
1570 PyObject *self; /* Not used */
1571 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001572{
Guido van Rossumd641d671997-04-03 17:06:32 +00001573 ALconfig config;
1574
1575 if (!PyArg_ParseTuple(args, ""))
Guido van Rossume3db8621991-09-09 23:33:34 +00001576 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001577 if ((config = alNewConfig()) == NULL)
1578 return NULL;
1579 return newalcobject(config);
Guido van Rossume3db8621991-09-09 23:33:34 +00001580}
1581
Guido van Rossumd641d671997-04-03 17:06:32 +00001582static char al_OpenPort__doc__[] =
1583"alOpenPort: open an audio port."
1584;
Guido van Rossume3db8621991-09-09 23:33:34 +00001585
Roger E. Massea2a8b271997-01-03 22:40:34 +00001586static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001587al_OpenPort(self, args)
1588 PyObject *self; /* Not used */
1589 PyObject *args;
1590{
1591 ALport port;
1592 char *name, *dir;
1593 alcobject *config = NULL;
1594
1595 if (!PyArg_ParseTuple(args, "ss|O!", &name, &dir, &Alctype, &config))
1596 return NULL;
1597 if ((port = alOpenPort(name, dir, config ? config->config : NULL)) == NULL)
1598 return NULL;
1599 return newalpobject(port);
1600}
1601
1602static char al_Connect__doc__[] =
1603"alConnect: connect two audio I/O resources."
1604;
1605
1606static PyObject *
1607al_Connect(self, args)
1608 PyObject *self; /* Not used */
1609 PyObject *args;
1610{
1611 int source, dest, nprops = 0, id, i;
1612 ALpv *props = NULL;
1613 ALparamInfo *propinfo = NULL;
1614 PyObject *propobj = NULL;
1615
1616 if (!PyArg_ParseTuple(args, "ii|O!", &source, &dest, &propobj))
1617 return NULL;
1618 if (propobj != NULL) {
1619 nprops = python2params(source, dest, propobj, &props, &propinfo);
1620 if (nprops < 0)
1621 return NULL;
1622 }
1623
1624 id = alConnect(source, dest, props, nprops);
1625
1626 if (props) {
1627 for (i = 0; i < nprops; i++) {
1628 switch (propinfo[i].valueType) {
1629 case AL_SET_VAL:
1630 case AL_VECTOR_VAL:
1631 PyMem_DEL(props[i].value.ptr);
1632 break;
1633 }
1634 }
1635 PyMem_DEL(props);
1636 PyMem_DEL(propinfo);
1637 }
1638
1639 if (id < 0)
1640 return NULL;
1641 return PyInt_FromLong((long) id);
1642}
1643
1644static char al_Disconnect__doc__[] =
1645"alDisconnect: delete a connection between two audio I/O resources."
1646;
1647
1648static PyObject *
1649al_Disconnect(self, args)
1650 PyObject *self; /* Not used */
1651 PyObject *args;
1652{
1653 int res;
1654
1655 if (!PyArg_ParseTuple(args, "i", &res))
1656 return NULL;
1657 if (alDisconnect(res) < 0)
1658 return NULL;
1659 Py_INCREF(Py_None);
1660 return Py_None;
1661}
1662
1663static char al_GetParams__doc__[] =
1664"alGetParams: get the values of audio resource parameters."
1665;
1666
1667static PyObject *
1668al_GetParams(self, args)
1669 PyObject *self; /* Not used */
1670 PyObject *args;
1671{
1672 int resource;
1673 PyObject *pvslist, *item = NULL, *v = NULL;
1674 ALpv *pvs;
1675 int i, j, npvs;
1676 ALparamInfo *pinfo;
1677
1678 if (!PyArg_ParseTuple(args, "iO!", &resource, &PyList_Type, &pvslist))
1679 return NULL;
1680 npvs = PyList_Size(pvslist);
1681 pvs = PyMem_NEW(ALpv, npvs);
1682 pinfo = PyMem_NEW(ALparamInfo, npvs);
1683 for (i = 0; i < npvs; i++) {
1684 item = PyList_GetItem(pvslist, i);
1685 if (!PyInt_Check(item)) {
1686 item = NULL;
1687 PyErr_SetString(ErrorObject, "list of integers expected");
1688 goto error;
1689 }
1690 pvs[i].param = (int) PyInt_AsLong(item);
1691 item = NULL; /* not needed anymore */
1692 if (alGetParamInfo(resource, pvs[i].param, &pinfo[i]) < 0)
1693 goto error;
1694 switch (pinfo[i].valueType) {
1695 case AL_NO_VAL:
1696 break;
1697 case AL_MATRIX_VAL:
1698 pinfo[i].maxElems *= pinfo[i].maxElems2;
1699 /* fall through */
1700 case AL_STRING_VAL:
1701 case AL_SET_VAL:
1702 case AL_VECTOR_VAL:
1703 switch (pinfo[i].elementType) {
1704 case AL_INT32_ELEM:
1705 case AL_RESOURCE_ELEM:
1706 case AL_ENUM_ELEM:
1707 pvs[i].value.ptr = PyMem_NEW(int, pinfo[i].maxElems);
1708 pvs[i].sizeIn = pinfo[i].maxElems;
1709 break;
1710 case AL_INT64_ELEM:
1711 case AL_FIXED_ELEM:
1712 pvs[i].value.ptr = PyMem_NEW(long long, pinfo[i].maxElems);
1713 pvs[i].sizeIn = pinfo[i].maxElems;
1714 break;
1715 case AL_CHAR_ELEM:
1716 pvs[i].value.ptr = PyMem_NEW(char, 32);
1717 pvs[i].sizeIn = 32;
1718 break;
1719 case AL_NO_ELEM:
1720 case AL_PTR_ELEM:
1721 default:
1722 PyErr_SetString(ErrorObject, "internal error");
1723 goto error;
1724 }
1725 break;
1726 case AL_SCALAR_VAL:
1727 break;
1728 default:
1729 PyErr_SetString(ErrorObject, "internal error");
1730 goto error;
1731 }
1732 if (pinfo[i].valueType == AL_MATRIX_VAL) {
1733 pinfo[i].maxElems /= pinfo[i].maxElems2;
1734 pvs[i].sizeIn /= pinfo[i].maxElems2;
1735 pvs[i].size2In = pinfo[i].maxElems2;
1736 }
1737 }
1738 if (alGetParams(resource, pvs, npvs) < 0)
1739 goto error;
1740 v = PyList_New(npvs);
1741 for (i = 0; i < npvs; i++) {
1742 if (pvs[i].sizeOut < 0) {
1743 char buf[32];
1744 sprintf(buf, "problem with param %d", i);
1745 PyErr_SetString(ErrorObject, buf);
1746 goto error;
1747 }
1748 switch (pinfo[i].valueType) {
1749 case AL_NO_VAL:
1750 item = Py_None;
1751 Py_INCREF(item);
1752 break;
1753 case AL_STRING_VAL:
1754 item = PyString_FromString(pvs[i].value.ptr);
1755 PyMem_DEL(pvs[i].value.ptr);
1756 break;
1757 case AL_MATRIX_VAL:
1758 /* XXXX this is not right */
1759 pvs[i].sizeOut *= pvs[i].size2Out;
1760 /* fall through */
1761 case AL_SET_VAL:
1762 case AL_VECTOR_VAL:
1763 item = PyList_New(pvs[i].sizeOut);
1764 for (j = 0; j < pvs[i].sizeOut; j++) {
1765 switch (pinfo[i].elementType) {
1766 case AL_INT32_ELEM:
1767 case AL_RESOURCE_ELEM:
1768 case AL_ENUM_ELEM:
1769 PyList_SetItem(item, j, PyInt_FromLong((long) ((int *) pvs[i].value.ptr)[j]));
1770 break;
1771 case AL_INT64_ELEM:
1772 PyList_SetItem(item, j, PyLong_FromLongLong(((long long *) pvs[i].value.ptr)[j]));
1773 break;
1774 case AL_FIXED_ELEM:
1775 PyList_SetItem(item, j, PyFloat_FromDouble(alFixedToDouble(((long long *) pvs[i].value.ptr)[j])));
1776 break;
1777 default:
1778 PyErr_SetString(ErrorObject, "internal error");
1779 goto error;
1780 }
1781 }
1782 PyMem_DEL(pvs[i].value.ptr);
1783 break;
1784 case AL_SCALAR_VAL:
1785 item = param2python(resource, pvs[i].param, pvs[i].value, &pinfo[i]);
1786 break;
1787 }
1788 if (PyErr_Occurred() ||
1789 PyList_SetItem(v, i, Py_BuildValue("(iO)", pvs[i].param,
1790 item)) < 0 ||
1791 PyErr_Occurred())
1792 goto error;
1793 Py_DECREF(item);
1794 }
1795 PyMem_DEL(pvs);
1796 PyMem_DEL(pinfo);
1797 return v;
1798
1799 error:
1800 Py_XDECREF(v);
1801 Py_XDECREF(item);
1802 if (pvs)
1803 PyMem_DEL(pvs);
1804 if (pinfo)
1805 PyMem_DEL(pinfo);
1806 return NULL;
1807}
1808
1809static char al_SetParams__doc__[] =
1810"alSetParams: set the values of audio resource parameters."
1811;
1812
1813static PyObject *
1814al_SetParams(self, args)
1815 PyObject *self; /* Not used */
1816 PyObject *args;
1817{
1818 int resource;
1819 PyObject *pvslist, *item;
1820 ALpv *pvs;
1821 ALparamInfo *pinfo;
1822 int npvs, i;
1823
1824 if (!PyArg_ParseTuple(args, "iO!", &resource, &PyList_Type, &pvslist))
1825 return NULL;
1826 npvs = python2params(resource, -1, pvslist, &pvs, &pinfo);
1827 if (npvs < 0)
1828 return NULL;
1829
1830 if (alSetParams(resource, pvs, npvs) < 0)
1831 goto error;
1832
1833 /* cleanup */
1834 for (i = 0; i < npvs; i++) {
1835 switch (pinfo[i].valueType) {
1836 case AL_SET_VAL:
1837 case AL_VECTOR_VAL:
1838 PyMem_DEL(pvs[i].value.ptr);
1839 break;
1840 }
1841 }
1842 PyMem_DEL(pvs);
1843 PyMem_DEL(pinfo);
1844
1845 Py_INCREF(Py_None);
1846 return Py_None;
1847
1848 error:
1849 /* XXXX we should clean up everything */
1850 if (pvs)
1851 PyMem_DEL(pvs);
1852 if (pinfo)
1853 PyMem_DEL(pinfo);
1854 return NULL;
1855}
1856
1857static char al_QueryValues__doc__[] =
1858"alQueryValues: get the set of possible values for a parameter."
1859;
1860
1861static PyObject *
1862al_QueryValues(self, args)
1863 PyObject *self; /* Not used */
1864 PyObject *args;
1865{
1866 int resource, param;
1867 ALvalue *return_set = NULL;
1868 int setsize = 32, qualsize = 0, nvals, i;
1869 ALpv *quals = NULL;
1870 ALparamInfo pinfo;
1871 ALparamInfo *qualinfo = NULL;
1872 PyObject *qualobj = NULL;
1873 PyObject *res = NULL, *item;
1874
1875 if (!PyArg_ParseTuple(args, "ii|O!", &resource, &param,
1876 &PyList_Type, &qualobj))
1877 return NULL;
1878 if (qualobj != NULL) {
1879 qualsize = python2params(resource, param, qualobj, &quals, &qualinfo);
1880 if (qualsize < 0)
1881 return NULL;
1882 }
1883 setsize = 32;
1884 return_set = PyMem_NEW(ALvalue, setsize);
1885 if (return_set == NULL) {
1886 PyErr_NoMemory();
1887 goto cleanup;
1888 }
1889
1890 retry:
1891 nvals = alQueryValues(resource, param, return_set, setsize, quals, qualsize);
1892 if (nvals < 0)
1893 goto cleanup;
1894 if (nvals > setsize) {
1895 setsize = nvals;
1896 PyMem_RESIZE(return_set, ALvalue, setsize);
1897 if (return_set == NULL) {
1898 PyErr_NoMemory();
1899 goto cleanup;
1900 }
1901 goto retry;
1902 }
1903
1904 if (alGetParamInfo(resource, param, &pinfo) < 0)
1905 goto cleanup;
1906
1907 res = PyList_New(nvals);
1908 if (res == NULL)
1909 goto cleanup;
1910 for (i = 0; i < nvals; i++) {
1911 item = param2python(resource, param, return_set[i], &pinfo);
1912 if (item == NULL ||
1913 PyList_SetItem(res, i, item) < 0) {
1914 Py_DECREF(res);
1915 res = NULL;
1916 goto cleanup;
1917 }
1918 }
1919
1920 cleanup:
1921 if (return_set)
1922 PyMem_DEL(return_set);
1923 if (quals) {
1924 for (i = 0; i < qualsize; i++) {
1925 switch (qualinfo[i].valueType) {
1926 case AL_SET_VAL:
1927 case AL_VECTOR_VAL:
1928 PyMem_DEL(quals[i].value.ptr);
1929 break;
1930 }
1931 }
1932 PyMem_DEL(quals);
1933 PyMem_DEL(qualinfo);
1934 }
1935
1936 return res;
1937}
1938
1939static char al_GetParamInfo__doc__[] =
1940"alGetParamInfo: get information about a parameter on a particular audio resource."
1941;
1942
1943static PyObject *
1944al_GetParamInfo(self, args)
1945 PyObject *self; /* Not used */
1946 PyObject *args;
1947{
1948 int res, param;
1949 ALparamInfo pinfo;
1950 PyObject *v, *item;;
1951
1952 if (!PyArg_ParseTuple(args, "ii", &res, &param))
1953 return NULL;
1954 if (alGetParamInfo(res, param, &pinfo) < 0)
1955 return NULL;
1956 v = PyDict_New();
1957
1958 item = PyInt_FromLong((long) pinfo.resource);
1959 PyDict_SetItemString(v, "resource", item);
1960 Py_DECREF(item);
1961
1962 item = PyInt_FromLong((long) pinfo.param);
1963 PyDict_SetItemString(v, "param", item);
1964 Py_DECREF(item);
1965
1966 item = PyInt_FromLong((long) pinfo.valueType);
1967 PyDict_SetItemString(v, "valueType", item);
1968 Py_DECREF(item);
1969
1970 if (pinfo.valueType != AL_NO_VAL && pinfo.valueType != AL_SCALAR_VAL) {
1971 /* multiple values */
1972 item = PyInt_FromLong((long) pinfo.maxElems);
1973 PyDict_SetItemString(v, "maxElems", item);
1974 Py_DECREF(item);
1975
1976 if (pinfo.valueType == AL_MATRIX_VAL) {
1977 /* 2 dimensional */
1978 item = PyInt_FromLong((long) pinfo.maxElems2);
1979 PyDict_SetItemString(v, "maxElems2", item);
1980 Py_DECREF(item);
1981 }
1982 }
1983
1984 item = PyInt_FromLong((long) pinfo.elementType);
1985 PyDict_SetItemString(v, "elementType", item);
1986 Py_DECREF(item);
1987
1988 item = PyString_FromString(pinfo.name);
1989 PyDict_SetItemString(v, "name", item);
1990 Py_DECREF(item);
1991
1992 item = param2python(res, param, pinfo.initial, &pinfo);
1993 PyDict_SetItemString(v, "initial", item);
1994 Py_DECREF(item);
1995
1996 if (pinfo.elementType != AL_ENUM_ELEM &&
1997 pinfo.elementType != AL_RESOURCE_ELEM &&
1998 pinfo.elementType != AL_CHAR_ELEM) {
1999 /* range param */
2000 item = param2python(res, param, pinfo.min, &pinfo);
2001 PyDict_SetItemString(v, "min", item);
2002 Py_DECREF(item);
2003
2004 item = param2python(res, param, pinfo.max, &pinfo);
2005 PyDict_SetItemString(v, "max", item);
2006 Py_DECREF(item);
2007
2008 item = param2python(res, param, pinfo.minDelta, &pinfo);
2009 PyDict_SetItemString(v, "minDelta", item);
2010 Py_DECREF(item);
2011
2012 item = param2python(res, param, pinfo.maxDelta, &pinfo);
2013 PyDict_SetItemString(v, "maxDelta", item);
2014 Py_DECREF(item);
2015
2016 item = PyInt_FromLong((long) pinfo.specialVals);
2017 PyDict_SetItemString(v, "specialVals", item);
2018 Py_DECREF(item);
2019 }
2020
2021 return v;
2022}
2023
2024static char al_GetResourceByName__doc__[] =
2025"alGetResourceByName: find an audio resource by name."
2026;
2027
2028static PyObject *
2029al_GetResourceByName(self, args)
2030 PyObject *self; /* Not used */
2031 PyObject *args;
2032{
2033 int res, start_res, type;
2034 char *name;
2035
2036 if (!PyArg_ParseTuple(args, "isi", &start_res, &name, &type))
2037 return NULL;
2038 if ((res = alGetResourceByName(start_res, name, type)) == 0)
2039 return NULL;
2040 return PyInt_FromLong((long) res);
2041}
2042
2043static char al_IsSubtype__doc__[] =
2044"alIsSubtype: indicate if one resource type is a subtype of another."
2045;
2046
2047static PyObject *
2048al_IsSubtype(self, args)
2049 PyObject *self; /* Not used */
2050 PyObject *args;
2051{
2052 int type, subtype;
2053
2054 if (!PyArg_ParseTuple(args, "ii", &type, &subtype))
2055 return NULL;
2056 return PyInt_FromLong((long) alIsSubtype(type, subtype));
2057}
2058
2059static char al_SetErrorHandler__doc__[] =
2060""
2061;
2062
2063static PyObject *
2064al_SetErrorHandler(self, args)
2065 PyObject *self; /* Not used */
2066 PyObject *args;
2067{
2068
2069 if (!PyArg_ParseTuple(args, ""))
2070 return NULL;
2071 Py_INCREF(Py_None);
2072 return Py_None;
2073}
2074
2075#endif /* AL_NO_ELEM */
2076
2077#ifdef OLD_INTERFACE
2078
2079static PyObject *
2080al_openport(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002081 PyObject *self, *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00002082{
Guido van Rossumfc58e581992-01-27 16:45:55 +00002083 char *name, *dir;
Guido van Rossume3db8621991-09-09 23:33:34 +00002084 ALport port;
Guido van Rossumd641d671997-04-03 17:06:32 +00002085 alcobject *config = NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00002086
Guido van Rossumd641d671997-04-03 17:06:32 +00002087 if (!PyArg_ParseTuple(args, "ss|O!", &name, &dir, &Alctype, &config))
Guido van Rossumc0aab891991-10-20 20:10:46 +00002088 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00002089 if ((port = ALopenport(name, dir, config ? config->config : NULL)) == NULL)
Guido van Rossume3db8621991-09-09 23:33:34 +00002090 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00002091 return newalpobject(port);
Guido van Rossume3db8621991-09-09 23:33:34 +00002092}
2093
Roger E. Massea2a8b271997-01-03 22:40:34 +00002094static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00002095al_newconfig(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002096 PyObject *self, *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00002097{
2098 ALconfig config;
2099
Guido van Rossumd641d671997-04-03 17:06:32 +00002100 if (!PyArg_ParseTuple(args, ""))
Guido van Rossumc0aab891991-10-20 20:10:46 +00002101 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00002102 if ((config = ALnewconfig ()) == NULL)
2103 return NULL;
2104 return newalcobject(config);
Guido van Rossume3db8621991-09-09 23:33:34 +00002105}
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002106
Roger E. Massea2a8b271997-01-03 22:40:34 +00002107static PyObject *
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002108al_queryparams(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002109 PyObject *self, *args;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002110{
2111 long device;
2112 long length;
2113 long *PVbuffer;
2114 long PVdummy[2];
Guido van Rossumd641d671997-04-03 17:06:32 +00002115 PyObject *v = NULL;
2116 int i;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002117
Guido van Rossumd641d671997-04-03 17:06:32 +00002118 if (!PyArg_ParseTuple(args, "l", &device))
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002119 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00002120 if ((length = ALqueryparams(device, PVdummy, 2L)) == -1)
2121 return NULL;
2122 if ((PVbuffer = PyMem_NEW(long, length)) == NULL)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002123 return PyErr_NoMemory();
Guido van Rossumd641d671997-04-03 17:06:32 +00002124 if (ALqueryparams(device, PVbuffer, length) >= 0 &&
2125 (v = PyList_New((int)length)) != NULL) {
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002126 for (i = 0; i < length; i++)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002127 PyList_SetItem(v, i, PyInt_FromLong(PVbuffer[i]));
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002128 }
Roger E. Massea2a8b271997-01-03 22:40:34 +00002129 PyMem_DEL(PVbuffer);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002130 return v;
2131}
2132
Roger E. Massea2a8b271997-01-03 22:40:34 +00002133static PyObject *
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002134doParams(args, func, modified)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002135 PyObject *args;
Guido van Rossumd641d671997-04-03 17:06:32 +00002136 int (*func)(long, long *, long);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002137 int modified;
2138{
2139 long device;
Roger E. Massea2a8b271997-01-03 22:40:34 +00002140 PyObject *list, *v;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002141 long *PVbuffer;
2142 long length;
2143 int i;
Guido van Rossume3db8621991-09-09 23:33:34 +00002144
Guido van Rossumd641d671997-04-03 17:06:32 +00002145 if (!PyArg_ParseTuple(args, "lO!", &device, &PyList_Type, &list))
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002146 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00002147 length = PyList_Size(list);
2148 PVbuffer = PyMem_NEW(long, length);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002149 if (PVbuffer == NULL)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002150 return PyErr_NoMemory();
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002151 for (i = 0; i < length; i++) {
Roger E. Massea2a8b271997-01-03 22:40:34 +00002152 v = PyList_GetItem(list, i);
2153 if (!PyInt_Check(v)) {
2154 PyMem_DEL(PVbuffer);
2155 PyErr_BadArgument();
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002156 return NULL;
2157 }
Roger E. Massea2a8b271997-01-03 22:40:34 +00002158 PVbuffer[i] = PyInt_AsLong(v);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002159 }
2160
Guido van Rossumd641d671997-04-03 17:06:32 +00002161 if ((*func)(device, PVbuffer, length) == -1) {
2162 PyMem_DEL(PVbuffer);
2163 return NULL;
2164 }
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002165
2166 if (modified) {
2167 for (i = 0; i < length; i++)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002168 PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i]));
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002169 }
2170
Roger E. Massea2a8b271997-01-03 22:40:34 +00002171 PyMem_DEL(PVbuffer);
Guido van Rossumc0aab891991-10-20 20:10:46 +00002172
Roger E. Massea2a8b271997-01-03 22:40:34 +00002173 Py_INCREF(Py_None);
2174 return Py_None;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002175}
2176
Roger E. Massea2a8b271997-01-03 22:40:34 +00002177static PyObject *
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002178al_getparams(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002179 PyObject *self, *args;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002180{
2181 return doParams(args, ALgetparams, 1);
2182}
2183
Roger E. Massea2a8b271997-01-03 22:40:34 +00002184static PyObject *
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002185al_setparams(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002186 PyObject *self, *args;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002187{
2188 return doParams(args, ALsetparams, 0);
2189}
2190
Roger E. Massea2a8b271997-01-03 22:40:34 +00002191static PyObject *
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002192al_getname(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002193 PyObject *self, *args;
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002194{
2195 long device, descriptor;
2196 char *name;
Guido van Rossumd641d671997-04-03 17:06:32 +00002197
2198 if (!PyArg_ParseTuple(args, "ll", &device, &descriptor))
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002199 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00002200 if ((name = ALgetname(device, descriptor)) == NULL)
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002201 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00002202 return PyString_FromString(name);
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002203}
2204
Roger E. Massea2a8b271997-01-03 22:40:34 +00002205static PyObject *
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002206al_getdefault(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002207 PyObject *self, *args;
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002208{
2209 long device, descriptor, value;
Guido van Rossumd641d671997-04-03 17:06:32 +00002210
2211 if (!PyArg_ParseTuple(args, "ll", &device, &descriptor))
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002212 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00002213 if ((value = ALgetdefault(device, descriptor)) == -1)
2214 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00002215 return PyLong_FromLong(value);
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002216}
2217
Roger E. Massea2a8b271997-01-03 22:40:34 +00002218static PyObject *
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002219al_getminmax(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002220 PyObject *self, *args;
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002221{
2222 long device, descriptor, min, max;
Guido van Rossumd641d671997-04-03 17:06:32 +00002223
2224 if (!PyArg_ParseTuple(args, "ll", &device, &descriptor))
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002225 return NULL;
2226 min = -1;
2227 max = -1;
Guido van Rossumd641d671997-04-03 17:06:32 +00002228 if (ALgetminmax(device, descriptor, &min, &max) == -1)
2229 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00002230 return Py_BuildValue("ll", min, max);
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002231}
2232
Guido van Rossumd641d671997-04-03 17:06:32 +00002233#endif /* OLD_INTERFACE */
2234
2235/* List of methods defined in the module */
2236
2237static struct PyMethodDef al_methods[] = {
2238#ifdef AL_NO_ELEM /* IRIX 6 */
2239 {"NewConfig", (PyCFunction)al_NewConfig, METH_VARARGS, al_NewConfig__doc__},
2240 {"OpenPort", (PyCFunction)al_OpenPort, METH_VARARGS, al_OpenPort__doc__},
2241 {"Connect", (PyCFunction)al_Connect, METH_VARARGS, al_Connect__doc__},
2242 {"Disconnect", (PyCFunction)al_Disconnect, METH_VARARGS, al_Disconnect__doc__},
2243 {"GetParams", (PyCFunction)al_GetParams, METH_VARARGS, al_GetParams__doc__},
2244 {"SetParams", (PyCFunction)al_SetParams, METH_VARARGS, al_SetParams__doc__},
2245 {"QueryValues", (PyCFunction)al_QueryValues, METH_VARARGS, al_QueryValues__doc__},
2246 {"GetParamInfo", (PyCFunction)al_GetParamInfo, METH_VARARGS, al_GetParamInfo__doc__},
2247 {"GetResourceByName", (PyCFunction)al_GetResourceByName, METH_VARARGS, al_GetResourceByName__doc__},
2248 {"IsSubtype", (PyCFunction)al_IsSubtype, METH_VARARGS, al_IsSubtype__doc__},
2249#if 0
2250 /* this one not supported */
2251 {"SetErrorHandler", (PyCFunction)al_SetErrorHandler, METH_VARARGS, al_SetErrorHandler__doc__},
2252#endif
2253#endif /* AL_NO_ELEM */
2254#ifdef OLD_INTERFACE
2255 {"openport", (PyCFunction)al_openport, METH_VARARGS},
2256 {"newconfig", (PyCFunction)al_newconfig, METH_VARARGS},
2257 {"queryparams", (PyCFunction)al_queryparams, METH_VARARGS},
2258 {"getparams", (PyCFunction)al_getparams, METH_VARARGS},
2259 {"setparams", (PyCFunction)al_setparams, METH_VARARGS},
2260 {"getname", (PyCFunction)al_getname, METH_VARARGS},
2261 {"getdefault", (PyCFunction)al_getdefault, METH_VARARGS},
2262 {"getminmax", (PyCFunction)al_getminmax, METH_VARARGS},
2263#endif /* OLD_INTERFACE */
2264
2265 {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
Guido van Rossume3db8621991-09-09 23:33:34 +00002266};
2267
Guido van Rossumd641d671997-04-03 17:06:32 +00002268
2269/* Initialization function for the module (*must* be called inital) */
2270
2271static char al_module_documentation[] =
2272""
2273;
2274
Guido van Rossume3db8621991-09-09 23:33:34 +00002275void
2276inital()
2277{
Guido van Rossumd641d671997-04-03 17:06:32 +00002278 PyObject *m, *d, *x;
Guido van Rossume3db8621991-09-09 23:33:34 +00002279
Guido van Rossumd641d671997-04-03 17:06:32 +00002280 /* Create the module and add the functions */
2281 m = Py_InitModule4("al", al_methods,
2282 al_module_documentation,
2283 (PyObject*)NULL,PYTHON_API_VERSION);
2284
2285 /* Add some symbolic constants to the module */
2286 d = PyModule_GetDict(m);
2287 ErrorObject = PyString_FromString("al.error");
2288 PyDict_SetItemString(d, "error", ErrorObject);
2289
2290 /* XXXX Add constants here */
2291#ifdef AL_4CHANNEL
2292 x = PyInt_FromLong((long) AL_4CHANNEL);
2293 if (x == NULL || PyDict_SetItemString(d, "FOURCHANNEL", x) < 0)
2294 goto error;
2295 Py_DECREF(x);
2296#endif
2297#ifdef AL_ADAT_IF_TYPE
2298 x = PyInt_FromLong((long) AL_ADAT_IF_TYPE);
2299 if (x == NULL || PyDict_SetItemString(d, "ADAT_IF_TYPE", x) < 0)
2300 goto error;
2301 Py_DECREF(x);
2302#endif
2303#ifdef AL_ADAT_MCLK_TYPE
2304 x = PyInt_FromLong((long) AL_ADAT_MCLK_TYPE);
2305 if (x == NULL || PyDict_SetItemString(d, "ADAT_MCLK_TYPE", x) < 0)
2306 goto error;
2307 Py_DECREF(x);
2308#endif
2309#ifdef AL_AES_IF_TYPE
2310 x = PyInt_FromLong((long) AL_AES_IF_TYPE);
2311 if (x == NULL || PyDict_SetItemString(d, "AES_IF_TYPE", x) < 0)
2312 goto error;
2313 Py_DECREF(x);
2314#endif
2315#ifdef AL_AES_MCLK_TYPE
2316 x = PyInt_FromLong((long) AL_AES_MCLK_TYPE);
2317 if (x == NULL || PyDict_SetItemString(d, "AES_MCLK_TYPE", x) < 0)
2318 goto error;
2319 Py_DECREF(x);
2320#endif
2321#ifdef AL_ANALOG_IF_TYPE
2322 x = PyInt_FromLong((long) AL_ANALOG_IF_TYPE);
2323 if (x == NULL || PyDict_SetItemString(d, "ANALOG_IF_TYPE", x) < 0)
2324 goto error;
2325 Py_DECREF(x);
2326#endif
2327#ifdef AL_ASSOCIATE
2328 x = PyInt_FromLong((long) AL_ASSOCIATE);
2329 if (x == NULL || PyDict_SetItemString(d, "ASSOCIATE", x) < 0)
2330 goto error;
2331 Py_DECREF(x);
2332#endif
2333#ifdef AL_BAD_BUFFER_NULL
2334 x = PyInt_FromLong((long) AL_BAD_BUFFER_NULL);
2335 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFER_NULL", x) < 0)
2336 goto error;
2337 Py_DECREF(x);
2338#endif
2339#ifdef AL_BAD_BUFFERLENGTH
2340 x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH);
2341 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH", x) < 0)
2342 goto error;
2343 Py_DECREF(x);
2344#endif
2345#ifdef AL_BAD_BUFFERLENGTH_NEG
2346 x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH_NEG);
2347 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_NEG", x) < 0)
2348 goto error;
2349 Py_DECREF(x);
2350#endif
2351#ifdef AL_BAD_BUFFERLENGTH_ODD
2352 x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH_ODD);
2353 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_ODD", x) < 0)
2354 goto error;
2355 Py_DECREF(x);
2356#endif
2357#ifdef AL_BAD_CHANNELS
2358 x = PyInt_FromLong((long) AL_BAD_CHANNELS);
2359 if (x == NULL || PyDict_SetItemString(d, "BAD_CHANNELS", x) < 0)
2360 goto error;
2361 Py_DECREF(x);
2362#endif
2363#ifdef AL_BAD_CONFIG
2364 x = PyInt_FromLong((long) AL_BAD_CONFIG);
2365 if (x == NULL || PyDict_SetItemString(d, "BAD_CONFIG", x) < 0)
2366 goto error;
2367 Py_DECREF(x);
2368#endif
2369#ifdef AL_BAD_COUNT_NEG
2370 x = PyInt_FromLong((long) AL_BAD_COUNT_NEG);
2371 if (x == NULL || PyDict_SetItemString(d, "BAD_COUNT_NEG", x) < 0)
2372 goto error;
2373 Py_DECREF(x);
2374#endif
2375#ifdef AL_BAD_DEVICE
2376 x = PyInt_FromLong((long) AL_BAD_DEVICE);
2377 if (x == NULL || PyDict_SetItemString(d, "BAD_DEVICE", x) < 0)
2378 goto error;
2379 Py_DECREF(x);
2380#endif
2381#ifdef AL_BAD_DEVICE_ACCESS
2382 x = PyInt_FromLong((long) AL_BAD_DEVICE_ACCESS);
2383 if (x == NULL || PyDict_SetItemString(d, "BAD_DEVICE_ACCESS", x) < 0)
2384 goto error;
2385 Py_DECREF(x);
2386#endif
2387#ifdef AL_BAD_DIRECTION
2388 x = PyInt_FromLong((long) AL_BAD_DIRECTION);
2389 if (x == NULL || PyDict_SetItemString(d, "BAD_DIRECTION", x) < 0)
2390 goto error;
2391 Py_DECREF(x);
2392#endif
2393#ifdef AL_BAD_FILLPOINT
2394 x = PyInt_FromLong((long) AL_BAD_FILLPOINT);
2395 if (x == NULL || PyDict_SetItemString(d, "BAD_FILLPOINT", x) < 0)
2396 goto error;
2397 Py_DECREF(x);
2398#endif
2399#ifdef AL_BAD_FLOATMAX
2400 x = PyInt_FromLong((long) AL_BAD_FLOATMAX);
2401 if (x == NULL || PyDict_SetItemString(d, "BAD_FLOATMAX", x) < 0)
2402 goto error;
2403 Py_DECREF(x);
2404#endif
2405#ifdef AL_BAD_ILLEGAL_STATE
2406 x = PyInt_FromLong((long) AL_BAD_ILLEGAL_STATE);
2407 if (x == NULL || PyDict_SetItemString(d, "BAD_ILLEGAL_STATE", x) < 0)
2408 goto error;
2409 Py_DECREF(x);
2410#endif
2411#ifdef AL_BAD_NO_PORTS
2412 x = PyInt_FromLong((long) AL_BAD_NO_PORTS);
2413 if (x == NULL || PyDict_SetItemString(d, "BAD_NO_PORTS", x) < 0)
2414 goto error;
2415 Py_DECREF(x);
2416#endif
2417#ifdef AL_BAD_NOT_FOUND
2418 x = PyInt_FromLong((long) AL_BAD_NOT_FOUND);
2419 if (x == NULL || PyDict_SetItemString(d, "BAD_NOT_FOUND", x) < 0)
2420 goto error;
2421 Py_DECREF(x);
2422#endif
2423#ifdef AL_BAD_NOT_IMPLEMENTED
2424 x = PyInt_FromLong((long) AL_BAD_NOT_IMPLEMENTED);
2425 if (x == NULL || PyDict_SetItemString(d, "BAD_NOT_IMPLEMENTED", x) < 0)
2426 goto error;
2427 Py_DECREF(x);
2428#endif
2429#ifdef AL_BAD_OUT_OF_MEM
2430 x = PyInt_FromLong((long) AL_BAD_OUT_OF_MEM);
2431 if (x == NULL || PyDict_SetItemString(d, "BAD_OUT_OF_MEM", x) < 0)
2432 goto error;
2433 Py_DECREF(x);
2434#endif
2435#ifdef AL_BAD_PARAM
2436 x = PyInt_FromLong((long) AL_BAD_PARAM);
2437 if (x == NULL || PyDict_SetItemString(d, "BAD_PARAM", x) < 0)
2438 goto error;
2439 Py_DECREF(x);
2440#endif
2441#ifdef AL_BAD_PERMISSIONS
2442 x = PyInt_FromLong((long) AL_BAD_PERMISSIONS);
2443 if (x == NULL || PyDict_SetItemString(d, "BAD_PERMISSIONS", x) < 0)
2444 goto error;
2445 Py_DECREF(x);
2446#endif
2447#ifdef AL_BAD_PORT
2448 x = PyInt_FromLong((long) AL_BAD_PORT);
2449 if (x == NULL || PyDict_SetItemString(d, "BAD_PORT", x) < 0)
2450 goto error;
2451 Py_DECREF(x);
2452#endif
2453#ifdef AL_BAD_PORTSTYLE
2454 x = PyInt_FromLong((long) AL_BAD_PORTSTYLE);
2455 if (x == NULL || PyDict_SetItemString(d, "BAD_PORTSTYLE", x) < 0)
2456 goto error;
2457 Py_DECREF(x);
2458#endif
2459#ifdef AL_BAD_PVBUFFER
2460 x = PyInt_FromLong((long) AL_BAD_PVBUFFER);
2461 if (x == NULL || PyDict_SetItemString(d, "BAD_PVBUFFER", x) < 0)
2462 goto error;
2463 Py_DECREF(x);
2464#endif
2465#ifdef AL_BAD_QSIZE
2466 x = PyInt_FromLong((long) AL_BAD_QSIZE);
2467 if (x == NULL || PyDict_SetItemString(d, "BAD_QSIZE", x) < 0)
2468 goto error;
2469 Py_DECREF(x);
2470#endif
2471#ifdef AL_BAD_RATE
2472 x = PyInt_FromLong((long) AL_BAD_RATE);
2473 if (x == NULL || PyDict_SetItemString(d, "BAD_RATE", x) < 0)
2474 goto error;
2475 Py_DECREF(x);
2476#endif
2477#ifdef AL_BAD_RESOURCE
2478 x = PyInt_FromLong((long) AL_BAD_RESOURCE);
2479 if (x == NULL || PyDict_SetItemString(d, "BAD_RESOURCE", x) < 0)
2480 goto error;
2481 Py_DECREF(x);
2482#endif
2483#ifdef AL_BAD_SAMPFMT
2484 x = PyInt_FromLong((long) AL_BAD_SAMPFMT);
2485 if (x == NULL || PyDict_SetItemString(d, "BAD_SAMPFMT", x) < 0)
2486 goto error;
2487 Py_DECREF(x);
2488#endif
2489#ifdef AL_BAD_TRANSFER_SIZE
2490 x = PyInt_FromLong((long) AL_BAD_TRANSFER_SIZE);
2491 if (x == NULL || PyDict_SetItemString(d, "BAD_TRANSFER_SIZE", x) < 0)
2492 goto error;
2493 Py_DECREF(x);
2494#endif
2495#ifdef AL_BAD_WIDTH
2496 x = PyInt_FromLong((long) AL_BAD_WIDTH);
2497 if (x == NULL || PyDict_SetItemString(d, "BAD_WIDTH", x) < 0)
2498 goto error;
2499 Py_DECREF(x);
2500#endif
2501#ifdef AL_CHANNEL_MODE
2502 x = PyInt_FromLong((long) AL_CHANNEL_MODE);
2503 if (x == NULL || PyDict_SetItemString(d, "CHANNEL_MODE", x) < 0)
2504 goto error;
2505 Py_DECREF(x);
2506#endif
2507#ifdef AL_CHANNELS
2508 x = PyInt_FromLong((long) AL_CHANNELS);
2509 if (x == NULL || PyDict_SetItemString(d, "CHANNELS", x) < 0)
2510 goto error;
2511 Py_DECREF(x);
2512#endif
2513#ifdef AL_CHAR_ELEM
2514 x = PyInt_FromLong((long) AL_CHAR_ELEM);
2515 if (x == NULL || PyDict_SetItemString(d, "CHAR_ELEM", x) < 0)
2516 goto error;
2517 Py_DECREF(x);
2518#endif
2519#ifdef AL_CLOCK_GEN
2520 x = PyInt_FromLong((long) AL_CLOCK_GEN);
2521 if (x == NULL || PyDict_SetItemString(d, "CLOCK_GEN", x) < 0)
2522 goto error;
2523 Py_DECREF(x);
2524#endif
2525#ifdef AL_CLOCKGEN_TYPE
2526 x = PyInt_FromLong((long) AL_CLOCKGEN_TYPE);
2527 if (x == NULL || PyDict_SetItemString(d, "CLOCKGEN_TYPE", x) < 0)
2528 goto error;
2529 Py_DECREF(x);
2530#endif
2531#ifdef AL_CONNECT
2532 x = PyInt_FromLong((long) AL_CONNECT);
2533 if (x == NULL || PyDict_SetItemString(d, "CONNECT", x) < 0)
2534 goto error;
2535 Py_DECREF(x);
2536#endif
2537#ifdef AL_CONNECTION_TYPE
2538 x = PyInt_FromLong((long) AL_CONNECTION_TYPE);
2539 if (x == NULL || PyDict_SetItemString(d, "CONNECTION_TYPE", x) < 0)
2540 goto error;
2541 Py_DECREF(x);
2542#endif
2543#ifdef AL_CONNECTIONS
2544 x = PyInt_FromLong((long) AL_CONNECTIONS);
2545 if (x == NULL || PyDict_SetItemString(d, "CONNECTIONS", x) < 0)
2546 goto error;
2547 Py_DECREF(x);
2548#endif
2549#ifdef AL_CRYSTAL_MCLK_TYPE
2550 x = PyInt_FromLong((long) AL_CRYSTAL_MCLK_TYPE);
2551 if (x == NULL || PyDict_SetItemString(d, "CRYSTAL_MCLK_TYPE", x) < 0)
2552 goto error;
2553 Py_DECREF(x);
2554#endif
2555#ifdef AL_DEFAULT_DEVICE
2556 x = PyInt_FromLong((long) AL_DEFAULT_DEVICE);
2557 if (x == NULL || PyDict_SetItemString(d, "DEFAULT_DEVICE", x) < 0)
2558 goto error;
2559 Py_DECREF(x);
2560#endif
2561#ifdef AL_DEFAULT_INPUT
2562 x = PyInt_FromLong((long) AL_DEFAULT_INPUT);
2563 if (x == NULL || PyDict_SetItemString(d, "DEFAULT_INPUT", x) < 0)
2564 goto error;
2565 Py_DECREF(x);
2566#endif
2567#ifdef AL_DEFAULT_OUTPUT
2568 x = PyInt_FromLong((long) AL_DEFAULT_OUTPUT);
2569 if (x == NULL || PyDict_SetItemString(d, "DEFAULT_OUTPUT", x) < 0)
2570 goto error;
2571 Py_DECREF(x);
2572#endif
2573#ifdef AL_DEST
2574 x = PyInt_FromLong((long) AL_DEST);
2575 if (x == NULL || PyDict_SetItemString(d, "DEST", x) < 0)
2576 goto error;
2577 Py_DECREF(x);
2578#endif
2579#ifdef AL_DEVICE_TYPE
2580 x = PyInt_FromLong((long) AL_DEVICE_TYPE);
2581 if (x == NULL || PyDict_SetItemString(d, "DEVICE_TYPE", x) < 0)
2582 goto error;
2583 Py_DECREF(x);
2584#endif
2585#ifdef AL_DEVICES
2586 x = PyInt_FromLong((long) AL_DEVICES);
2587 if (x == NULL || PyDict_SetItemString(d, "DEVICES", x) < 0)
2588 goto error;
2589 Py_DECREF(x);
2590#endif
2591#ifdef AL_DIGITAL_IF_TYPE
2592 x = PyInt_FromLong((long) AL_DIGITAL_IF_TYPE);
2593 if (x == NULL || PyDict_SetItemString(d, "DIGITAL_IF_TYPE", x) < 0)
2594 goto error;
2595 Py_DECREF(x);
2596#endif
2597#ifdef AL_DIGITAL_INPUT_RATE
2598 x = PyInt_FromLong((long) AL_DIGITAL_INPUT_RATE);
2599 if (x == NULL || PyDict_SetItemString(d, "DIGITAL_INPUT_RATE", x) < 0)
2600 goto error;
2601 Py_DECREF(x);
2602#endif
2603#ifdef AL_DISCONNECT
2604 x = PyInt_FromLong((long) AL_DISCONNECT);
2605 if (x == NULL || PyDict_SetItemString(d, "DISCONNECT", x) < 0)
2606 goto error;
2607 Py_DECREF(x);
2608#endif
2609#ifdef AL_ENUM_ELEM
2610 x = PyInt_FromLong((long) AL_ENUM_ELEM);
2611 if (x == NULL || PyDict_SetItemString(d, "ENUM_ELEM", x) < 0)
2612 goto error;
2613 Py_DECREF(x);
2614#endif
2615#ifdef AL_ENUM_VALUE
2616 x = PyInt_FromLong((long) AL_ENUM_VALUE);
2617 if (x == NULL || PyDict_SetItemString(d, "ENUM_VALUE", x) < 0)
2618 goto error;
2619 Py_DECREF(x);
2620#endif
2621#ifdef AL_ERROR_INPUT_OVERFLOW
2622 x = PyInt_FromLong((long) AL_ERROR_INPUT_OVERFLOW);
2623 if (x == NULL || PyDict_SetItemString(d, "ERROR_INPUT_OVERFLOW", x) < 0)
2624 goto error;
2625 Py_DECREF(x);
2626#endif
2627#ifdef AL_ERROR_LENGTH
2628 x = PyInt_FromLong((long) AL_ERROR_LENGTH);
2629 if (x == NULL || PyDict_SetItemString(d, "ERROR_LENGTH", x) < 0)
2630 goto error;
2631 Py_DECREF(x);
2632#endif
2633#ifdef AL_ERROR_LOCATION_LSP
2634 x = PyInt_FromLong((long) AL_ERROR_LOCATION_LSP);
2635 if (x == NULL || PyDict_SetItemString(d, "ERROR_LOCATION_LSP", x) < 0)
2636 goto error;
2637 Py_DECREF(x);
2638#endif
2639#ifdef AL_ERROR_LOCATION_MSP
2640 x = PyInt_FromLong((long) AL_ERROR_LOCATION_MSP);
2641 if (x == NULL || PyDict_SetItemString(d, "ERROR_LOCATION_MSP", x) < 0)
2642 goto error;
2643 Py_DECREF(x);
2644#endif
2645#ifdef AL_ERROR_NUMBER
2646 x = PyInt_FromLong((long) AL_ERROR_NUMBER);
2647 if (x == NULL || PyDict_SetItemString(d, "ERROR_NUMBER", x) < 0)
2648 goto error;
2649 Py_DECREF(x);
2650#endif
2651#ifdef AL_ERROR_OUTPUT_UNDERFLOW
2652 x = PyInt_FromLong((long) AL_ERROR_OUTPUT_UNDERFLOW);
2653 if (x == NULL || PyDict_SetItemString(d, "ERROR_OUTPUT_UNDERFLOW", x) < 0)
2654 goto error;
2655 Py_DECREF(x);
2656#endif
2657#ifdef AL_ERROR_TYPE
2658 x = PyInt_FromLong((long) AL_ERROR_TYPE);
2659 if (x == NULL || PyDict_SetItemString(d, "ERROR_TYPE", x) < 0)
2660 goto error;
2661 Py_DECREF(x);
2662#endif
2663#ifdef AL_FIXED_ELEM
2664 x = PyInt_FromLong((long) AL_FIXED_ELEM);
2665 if (x == NULL || PyDict_SetItemString(d, "FIXED_ELEM", x) < 0)
2666 goto error;
2667 Py_DECREF(x);
2668#endif
2669#ifdef AL_FIXED_MCLK_TYPE
2670 x = PyInt_FromLong((long) AL_FIXED_MCLK_TYPE);
2671 if (x == NULL || PyDict_SetItemString(d, "FIXED_MCLK_TYPE", x) < 0)
2672 goto error;
2673 Py_DECREF(x);
2674#endif
2675#ifdef AL_GAIN
2676 x = PyInt_FromLong((long) AL_GAIN);
2677 if (x == NULL || PyDict_SetItemString(d, "GAIN", x) < 0)
2678 goto error;
2679 Py_DECREF(x);
2680#endif
2681#ifdef AL_GAIN_REF
2682 x = PyInt_FromLong((long) AL_GAIN_REF);
2683 if (x == NULL || PyDict_SetItemString(d, "GAIN_REF", x) < 0)
2684 goto error;
2685 Py_DECREF(x);
2686#endif
2687#ifdef AL_HRB_TYPE
2688 x = PyInt_FromLong((long) AL_HRB_TYPE);
2689 if (x == NULL || PyDict_SetItemString(d, "HRB_TYPE", x) < 0)
2690 goto error;
2691 Py_DECREF(x);
2692#endif
2693#ifdef AL_INPUT_COUNT
2694 x = PyInt_FromLong((long) AL_INPUT_COUNT);
2695 if (x == NULL || PyDict_SetItemString(d, "INPUT_COUNT", x) < 0)
2696 goto error;
2697 Py_DECREF(x);
2698#endif
2699#ifdef AL_INPUT_DEVICE_TYPE
2700 x = PyInt_FromLong((long) AL_INPUT_DEVICE_TYPE);
2701 if (x == NULL || PyDict_SetItemString(d, "INPUT_DEVICE_TYPE", x) < 0)
2702 goto error;
2703 Py_DECREF(x);
2704#endif
2705#ifdef AL_INPUT_DIGITAL
2706 x = PyInt_FromLong((long) AL_INPUT_DIGITAL);
2707 if (x == NULL || PyDict_SetItemString(d, "INPUT_DIGITAL", x) < 0)
2708 goto error;
2709 Py_DECREF(x);
2710#endif
2711#ifdef AL_INPUT_HRB_TYPE
2712 x = PyInt_FromLong((long) AL_INPUT_HRB_TYPE);
2713 if (x == NULL || PyDict_SetItemString(d, "INPUT_HRB_TYPE", x) < 0)
2714 goto error;
2715 Py_DECREF(x);
2716#endif
2717#ifdef AL_INPUT_LINE
2718 x = PyInt_FromLong((long) AL_INPUT_LINE);
2719 if (x == NULL || PyDict_SetItemString(d, "INPUT_LINE", x) < 0)
2720 goto error;
2721 Py_DECREF(x);
2722#endif
2723#ifdef AL_INPUT_MIC
2724 x = PyInt_FromLong((long) AL_INPUT_MIC);
2725 if (x == NULL || PyDict_SetItemString(d, "INPUT_MIC", x) < 0)
2726 goto error;
2727 Py_DECREF(x);
2728#endif
2729#ifdef AL_INPUT_PORT_TYPE
2730 x = PyInt_FromLong((long) AL_INPUT_PORT_TYPE);
2731 if (x == NULL || PyDict_SetItemString(d, "INPUT_PORT_TYPE", x) < 0)
2732 goto error;
2733 Py_DECREF(x);
2734#endif
2735#ifdef AL_INPUT_RATE
2736 x = PyInt_FromLong((long) AL_INPUT_RATE);
2737 if (x == NULL || PyDict_SetItemString(d, "INPUT_RATE", x) < 0)
2738 goto error;
2739 Py_DECREF(x);
2740#endif
2741#ifdef AL_INPUT_SOURCE
2742 x = PyInt_FromLong((long) AL_INPUT_SOURCE);
2743 if (x == NULL || PyDict_SetItemString(d, "INPUT_SOURCE", x) < 0)
2744 goto error;
2745 Py_DECREF(x);
2746#endif
2747#ifdef AL_INT32_ELEM
2748 x = PyInt_FromLong((long) AL_INT32_ELEM);
2749 if (x == NULL || PyDict_SetItemString(d, "INT32_ELEM", x) < 0)
2750 goto error;
2751 Py_DECREF(x);
2752#endif
2753#ifdef AL_INT64_ELEM
2754 x = PyInt_FromLong((long) AL_INT64_ELEM);
2755 if (x == NULL || PyDict_SetItemString(d, "INT64_ELEM", x) < 0)
2756 goto error;
2757 Py_DECREF(x);
2758#endif
2759#ifdef AL_INTERFACE
2760 x = PyInt_FromLong((long) AL_INTERFACE);
2761 if (x == NULL || PyDict_SetItemString(d, "INTERFACE", x) < 0)
2762 goto error;
2763 Py_DECREF(x);
2764#endif
2765#ifdef AL_INTERFACE_TYPE
2766 x = PyInt_FromLong((long) AL_INTERFACE_TYPE);
2767 if (x == NULL || PyDict_SetItemString(d, "INTERFACE_TYPE", x) < 0)
2768 goto error;
2769 Py_DECREF(x);
2770#endif
2771#ifdef AL_INVALID_PARAM
2772 x = PyInt_FromLong((long) AL_INVALID_PARAM);
2773 if (x == NULL || PyDict_SetItemString(d, "INVALID_PARAM", x) < 0)
2774 goto error;
2775 Py_DECREF(x);
2776#endif
2777#ifdef AL_INVALID_VALUE
2778 x = PyInt_FromLong((long) AL_INVALID_VALUE);
2779 if (x == NULL || PyDict_SetItemString(d, "INVALID_VALUE", x) < 0)
2780 goto error;
2781 Py_DECREF(x);
2782#endif
2783#ifdef AL_JITTER
2784 x = PyInt_FromLong((long) AL_JITTER);
2785 if (x == NULL || PyDict_SetItemString(d, "JITTER", x) < 0)
2786 goto error;
2787 Py_DECREF(x);
2788#endif
2789#ifdef AL_LABEL
2790 x = PyInt_FromLong((long) AL_LABEL);
2791 if (x == NULL || PyDict_SetItemString(d, "LABEL", x) < 0)
2792 goto error;
2793 Py_DECREF(x);
2794#endif
2795#ifdef AL_LEFT_INPUT_ATTEN
2796 x = PyInt_FromLong((long) AL_LEFT_INPUT_ATTEN);
2797 if (x == NULL || PyDict_SetItemString(d, "LEFT_INPUT_ATTEN", x) < 0)
2798 goto error;
2799 Py_DECREF(x);
2800#endif
2801#ifdef AL_LEFT_MONITOR_ATTEN
2802 x = PyInt_FromLong((long) AL_LEFT_MONITOR_ATTEN);
2803 if (x == NULL || PyDict_SetItemString(d, "LEFT_MONITOR_ATTEN", x) < 0)
2804 goto error;
2805 Py_DECREF(x);
2806#endif
2807#ifdef AL_LEFT_SPEAKER_GAIN
2808 x = PyInt_FromLong((long) AL_LEFT_SPEAKER_GAIN);
2809 if (x == NULL || PyDict_SetItemString(d, "LEFT_SPEAKER_GAIN", x) < 0)
2810 goto error;
2811 Py_DECREF(x);
2812#endif
2813#ifdef AL_LEFT1_INPUT_ATTEN
2814 x = PyInt_FromLong((long) AL_LEFT1_INPUT_ATTEN);
2815 if (x == NULL || PyDict_SetItemString(d, "LEFT1_INPUT_ATTEN", x) < 0)
2816 goto error;
2817 Py_DECREF(x);
2818#endif
2819#ifdef AL_LEFT2_INPUT_ATTEN
2820 x = PyInt_FromLong((long) AL_LEFT2_INPUT_ATTEN);
2821 if (x == NULL || PyDict_SetItemString(d, "LEFT2_INPUT_ATTEN", x) < 0)
2822 goto error;
2823 Py_DECREF(x);
2824#endif
2825#ifdef AL_LINE_IF_TYPE
2826 x = PyInt_FromLong((long) AL_LINE_IF_TYPE);
2827 if (x == NULL || PyDict_SetItemString(d, "LINE_IF_TYPE", x) < 0)
2828 goto error;
2829 Py_DECREF(x);
2830#endif
2831#ifdef AL_MASTER_CLOCK
2832 x = PyInt_FromLong((long) AL_MASTER_CLOCK);
2833 if (x == NULL || PyDict_SetItemString(d, "MASTER_CLOCK", x) < 0)
2834 goto error;
2835 Py_DECREF(x);
2836#endif
2837#ifdef AL_MATRIX_VAL
2838 x = PyInt_FromLong((long) AL_MATRIX_VAL);
2839 if (x == NULL || PyDict_SetItemString(d, "MATRIX_VAL", x) < 0)
2840 goto error;
2841 Py_DECREF(x);
2842#endif
2843#ifdef AL_MAX_ERROR
2844 x = PyInt_FromLong((long) AL_MAX_ERROR);
2845 if (x == NULL || PyDict_SetItemString(d, "MAX_ERROR", x) < 0)
2846 goto error;
2847 Py_DECREF(x);
2848#endif
2849#ifdef AL_MAX_EVENT_PARAM
2850 x = PyInt_FromLong((long) AL_MAX_EVENT_PARAM);
2851 if (x == NULL || PyDict_SetItemString(d, "MAX_EVENT_PARAM", x) < 0)
2852 goto error;
2853 Py_DECREF(x);
2854#endif
2855#ifdef AL_MAX_PBUFSIZE
2856 x = PyInt_FromLong((long) AL_MAX_PBUFSIZE);
2857 if (x == NULL || PyDict_SetItemString(d, "MAX_PBUFSIZE", x) < 0)
2858 goto error;
2859 Py_DECREF(x);
2860#endif
2861#ifdef AL_MAX_PORTS
2862 x = PyInt_FromLong((long) AL_MAX_PORTS);
2863 if (x == NULL || PyDict_SetItemString(d, "MAX_PORTS", x) < 0)
2864 goto error;
2865 Py_DECREF(x);
2866#endif
2867#ifdef AL_MAX_RESOURCE_ID
2868 x = PyInt_FromLong((long) AL_MAX_RESOURCE_ID);
2869 if (x == NULL || PyDict_SetItemString(d, "MAX_RESOURCE_ID", x) < 0)
2870 goto error;
2871 Py_DECREF(x);
2872#endif
2873#ifdef AL_MAX_SETSIZE
2874 x = PyInt_FromLong((long) AL_MAX_SETSIZE);
2875 if (x == NULL || PyDict_SetItemString(d, "MAX_SETSIZE", x) < 0)
2876 goto error;
2877 Py_DECREF(x);
2878#endif
2879#ifdef AL_MAX_STRLEN
2880 x = PyInt_FromLong((long) AL_MAX_STRLEN);
2881 if (x == NULL || PyDict_SetItemString(d, "MAX_STRLEN", x) < 0)
2882 goto error;
2883 Py_DECREF(x);
2884#endif
2885#ifdef AL_MCLK_TYPE
2886 x = PyInt_FromLong((long) AL_MCLK_TYPE);
2887 if (x == NULL || PyDict_SetItemString(d, "MCLK_TYPE", x) < 0)
2888 goto error;
2889 Py_DECREF(x);
2890#endif
2891#ifdef AL_MIC_IF_TYPE
2892 x = PyInt_FromLong((long) AL_MIC_IF_TYPE);
2893 if (x == NULL || PyDict_SetItemString(d, "MIC_IF_TYPE", x) < 0)
2894 goto error;
2895 Py_DECREF(x);
2896#endif
2897#ifdef AL_MONITOR_CTL
2898 x = PyInt_FromLong((long) AL_MONITOR_CTL);
2899 if (x == NULL || PyDict_SetItemString(d, "MONITOR_CTL", x) < 0)
2900 goto error;
2901 Py_DECREF(x);
2902#endif
2903#ifdef AL_MONITOR_OFF
2904 x = PyInt_FromLong((long) AL_MONITOR_OFF);
2905 if (x == NULL || PyDict_SetItemString(d, "MONITOR_OFF", x) < 0)
2906 goto error;
2907 Py_DECREF(x);
2908#endif
2909#ifdef AL_MONITOR_ON
2910 x = PyInt_FromLong((long) AL_MONITOR_ON);
2911 if (x == NULL || PyDict_SetItemString(d, "MONITOR_ON", x) < 0)
2912 goto error;
2913 Py_DECREF(x);
2914#endif
2915#ifdef AL_MONO
2916 x = PyInt_FromLong((long) AL_MONO);
2917 if (x == NULL || PyDict_SetItemString(d, "MONO", x) < 0)
2918 goto error;
2919 Py_DECREF(x);
2920#endif
2921#ifdef AL_MUTE
2922 x = PyInt_FromLong((long) AL_MUTE);
2923 if (x == NULL || PyDict_SetItemString(d, "MUTE", x) < 0)
2924 goto error;
2925 Py_DECREF(x);
2926#endif
2927#ifdef AL_NAME
2928 x = PyInt_FromLong((long) AL_NAME);
2929 if (x == NULL || PyDict_SetItemString(d, "NAME", x) < 0)
2930 goto error;
2931 Py_DECREF(x);
2932#endif
2933#ifdef AL_NEG_INFINITY
2934 x = PyInt_FromLong((long) AL_NEG_INFINITY);
2935 if (x == NULL || PyDict_SetItemString(d, "NEG_INFINITY", x) < 0)
2936 goto error;
2937 Py_DECREF(x);
2938#endif
2939#ifdef AL_NEG_INFINITY_BIT
2940 x = PyInt_FromLong((long) AL_NEG_INFINITY_BIT);
2941 if (x == NULL || PyDict_SetItemString(d, "NEG_INFINITY_BIT", x) < 0)
2942 goto error;
2943 Py_DECREF(x);
2944#endif
2945#ifdef AL_NO_CHANGE
2946 x = PyInt_FromLong((long) AL_NO_CHANGE);
2947 if (x == NULL || PyDict_SetItemString(d, "NO_CHANGE", x) < 0)
2948 goto error;
2949 Py_DECREF(x);
2950#endif
2951#ifdef AL_NO_CHANGE_BIT
2952 x = PyInt_FromLong((long) AL_NO_CHANGE_BIT);
2953 if (x == NULL || PyDict_SetItemString(d, "NO_CHANGE_BIT", x) < 0)
2954 goto error;
2955 Py_DECREF(x);
2956#endif
2957#ifdef AL_NO_ELEM
2958 x = PyInt_FromLong((long) AL_NO_ELEM);
2959 if (x == NULL || PyDict_SetItemString(d, "NO_ELEM", x) < 0)
2960 goto error;
2961 Py_DECREF(x);
2962#endif
2963#ifdef AL_NO_ERRORS
2964 x = PyInt_FromLong((long) AL_NO_ERRORS);
2965 if (x == NULL || PyDict_SetItemString(d, "NO_ERRORS", x) < 0)
2966 goto error;
2967 Py_DECREF(x);
2968#endif
2969#ifdef AL_NO_OP
2970 x = PyInt_FromLong((long) AL_NO_OP);
2971 if (x == NULL || PyDict_SetItemString(d, "NO_OP", x) < 0)
2972 goto error;
2973 Py_DECREF(x);
2974#endif
2975#ifdef AL_NO_VAL
2976 x = PyInt_FromLong((long) AL_NO_VAL);
2977 if (x == NULL || PyDict_SetItemString(d, "NO_VAL", x) < 0)
2978 goto error;
2979 Py_DECREF(x);
2980#endif
2981#ifdef AL_NULL_RESOURCE
2982 x = PyInt_FromLong((long) AL_NULL_RESOURCE);
2983 if (x == NULL || PyDict_SetItemString(d, "NULL_RESOURCE", x) < 0)
2984 goto error;
2985 Py_DECREF(x);
2986#endif
2987#ifdef AL_OUTPUT_COUNT
2988 x = PyInt_FromLong((long) AL_OUTPUT_COUNT);
2989 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_COUNT", x) < 0)
2990 goto error;
2991 Py_DECREF(x);
2992#endif
2993#ifdef AL_OUTPUT_DEVICE_TYPE
2994 x = PyInt_FromLong((long) AL_OUTPUT_DEVICE_TYPE);
2995 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_DEVICE_TYPE", x) < 0)
2996 goto error;
2997 Py_DECREF(x);
2998#endif
2999#ifdef AL_OUTPUT_HRB_TYPE
3000 x = PyInt_FromLong((long) AL_OUTPUT_HRB_TYPE);
3001 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_HRB_TYPE", x) < 0)
3002 goto error;
3003 Py_DECREF(x);
3004#endif
3005#ifdef AL_OUTPUT_PORT_TYPE
3006 x = PyInt_FromLong((long) AL_OUTPUT_PORT_TYPE);
3007 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_PORT_TYPE", x) < 0)
3008 goto error;
3009 Py_DECREF(x);
3010#endif
3011#ifdef AL_OUTPUT_RATE
3012 x = PyInt_FromLong((long) AL_OUTPUT_RATE);
3013 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_RATE", x) < 0)
3014 goto error;
3015 Py_DECREF(x);
3016#endif
3017#ifdef AL_PARAM_BIT
3018 x = PyInt_FromLong((long) AL_PARAM_BIT);
3019 if (x == NULL || PyDict_SetItemString(d, "PARAM_BIT", x) < 0)
3020 goto error;
3021 Py_DECREF(x);
3022#endif
3023#ifdef AL_PARAMS
3024 x = PyInt_FromLong((long) AL_PARAMS);
3025 if (x == NULL || PyDict_SetItemString(d, "PARAMS", x) < 0)
3026 goto error;
3027 Py_DECREF(x);
3028#endif
3029#ifdef AL_PORT_COUNT
3030 x = PyInt_FromLong((long) AL_PORT_COUNT);
3031 if (x == NULL || PyDict_SetItemString(d, "PORT_COUNT", x) < 0)
3032 goto error;
3033 Py_DECREF(x);
3034#endif
3035#ifdef AL_PORT_TYPE
3036 x = PyInt_FromLong((long) AL_PORT_TYPE);
3037 if (x == NULL || PyDict_SetItemString(d, "PORT_TYPE", x) < 0)
3038 goto error;
3039 Py_DECREF(x);
3040#endif
3041#ifdef AL_PORTS
3042 x = PyInt_FromLong((long) AL_PORTS);
3043 if (x == NULL || PyDict_SetItemString(d, "PORTS", x) < 0)
3044 goto error;
3045 Py_DECREF(x);
3046#endif
3047#ifdef AL_PORTSTYLE_DIRECT
3048 x = PyInt_FromLong((long) AL_PORTSTYLE_DIRECT);
3049 if (x == NULL || PyDict_SetItemString(d, "PORTSTYLE_DIRECT", x) < 0)
3050 goto error;
3051 Py_DECREF(x);
3052#endif
3053#ifdef AL_PORTSTYLE_SERIAL
3054 x = PyInt_FromLong((long) AL_PORTSTYLE_SERIAL);
3055 if (x == NULL || PyDict_SetItemString(d, "PORTSTYLE_SERIAL", x) < 0)
3056 goto error;
3057 Py_DECREF(x);
3058#endif
3059#ifdef AL_PRINT_ERRORS
3060 x = PyInt_FromLong((long) AL_PRINT_ERRORS);
3061 if (x == NULL || PyDict_SetItemString(d, "PRINT_ERRORS", x) < 0)
3062 goto error;
3063 Py_DECREF(x);
3064#endif
3065#ifdef AL_PTR_ELEM
3066 x = PyInt_FromLong((long) AL_PTR_ELEM);
3067 if (x == NULL || PyDict_SetItemString(d, "PTR_ELEM", x) < 0)
3068 goto error;
3069 Py_DECREF(x);
3070#endif
3071#ifdef AL_RANGE_VALUE
3072 x = PyInt_FromLong((long) AL_RANGE_VALUE);
3073 if (x == NULL || PyDict_SetItemString(d, "RANGE_VALUE", x) < 0)
3074 goto error;
3075 Py_DECREF(x);
3076#endif
3077#ifdef AL_RATE
3078 x = PyInt_FromLong((long) AL_RATE);
3079 if (x == NULL || PyDict_SetItemString(d, "RATE", x) < 0)
3080 goto error;
3081 Py_DECREF(x);
3082#endif
3083#ifdef AL_RATE_11025
3084 x = PyInt_FromLong((long) AL_RATE_11025);
3085 if (x == NULL || PyDict_SetItemString(d, "RATE_11025", x) < 0)
3086 goto error;
3087 Py_DECREF(x);
3088#endif
3089#ifdef AL_RATE_16000
3090 x = PyInt_FromLong((long) AL_RATE_16000);
3091 if (x == NULL || PyDict_SetItemString(d, "RATE_16000", x) < 0)
3092 goto error;
3093 Py_DECREF(x);
3094#endif
3095#ifdef AL_RATE_22050
3096 x = PyInt_FromLong((long) AL_RATE_22050);
3097 if (x == NULL || PyDict_SetItemString(d, "RATE_22050", x) < 0)
3098 goto error;
3099 Py_DECREF(x);
3100#endif
3101#ifdef AL_RATE_32000
3102 x = PyInt_FromLong((long) AL_RATE_32000);
3103 if (x == NULL || PyDict_SetItemString(d, "RATE_32000", x) < 0)
3104 goto error;
3105 Py_DECREF(x);
3106#endif
3107#ifdef AL_RATE_44100
3108 x = PyInt_FromLong((long) AL_RATE_44100);
3109 if (x == NULL || PyDict_SetItemString(d, "RATE_44100", x) < 0)
3110 goto error;
3111 Py_DECREF(x);
3112#endif
3113#ifdef AL_RATE_48000
3114 x = PyInt_FromLong((long) AL_RATE_48000);
3115 if (x == NULL || PyDict_SetItemString(d, "RATE_48000", x) < 0)
3116 goto error;
3117 Py_DECREF(x);
3118#endif
3119#ifdef AL_RATE_8000
3120 x = PyInt_FromLong((long) AL_RATE_8000);
3121 if (x == NULL || PyDict_SetItemString(d, "RATE_8000", x) < 0)
3122 goto error;
3123 Py_DECREF(x);
3124#endif
3125#ifdef AL_RATE_AES_1
3126 x = PyInt_FromLong((long) AL_RATE_AES_1);
3127 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_1", x) < 0)
3128 goto error;
3129 Py_DECREF(x);
3130#endif
3131#ifdef AL_RATE_AES_1s
3132 x = PyInt_FromLong((long) AL_RATE_AES_1s);
3133 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_1s", x) < 0)
3134 goto error;
3135 Py_DECREF(x);
3136#endif
3137#ifdef AL_RATE_AES_2
3138 x = PyInt_FromLong((long) AL_RATE_AES_2);
3139 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_2", x) < 0)
3140 goto error;
3141 Py_DECREF(x);
3142#endif
3143#ifdef AL_RATE_AES_3
3144 x = PyInt_FromLong((long) AL_RATE_AES_3);
3145 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_3", x) < 0)
3146 goto error;
3147 Py_DECREF(x);
3148#endif
3149#ifdef AL_RATE_AES_4
3150 x = PyInt_FromLong((long) AL_RATE_AES_4);
3151 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_4", x) < 0)
3152 goto error;
3153 Py_DECREF(x);
3154#endif
3155#ifdef AL_RATE_AES_6
3156 x = PyInt_FromLong((long) AL_RATE_AES_6);
3157 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_6", x) < 0)
3158 goto error;
3159 Py_DECREF(x);
3160#endif
3161#ifdef AL_RATE_FRACTION_D
3162 x = PyInt_FromLong((long) AL_RATE_FRACTION_D);
3163 if (x == NULL || PyDict_SetItemString(d, "RATE_FRACTION_D", x) < 0)
3164 goto error;
3165 Py_DECREF(x);
3166#endif
3167#ifdef AL_RATE_FRACTION_N
3168 x = PyInt_FromLong((long) AL_RATE_FRACTION_N);
3169 if (x == NULL || PyDict_SetItemString(d, "RATE_FRACTION_N", x) < 0)
3170 goto error;
3171 Py_DECREF(x);
3172#endif
3173#ifdef AL_RATE_INPUTRATE
3174 x = PyInt_FromLong((long) AL_RATE_INPUTRATE);
3175 if (x == NULL || PyDict_SetItemString(d, "RATE_INPUTRATE", x) < 0)
3176 goto error;
3177 Py_DECREF(x);
3178#endif
3179#ifdef AL_RATE_NO_DIGITAL_INPUT
3180 x = PyInt_FromLong((long) AL_RATE_NO_DIGITAL_INPUT);
3181 if (x == NULL || PyDict_SetItemString(d, "RATE_NO_DIGITAL_INPUT", x) < 0)
3182 goto error;
3183 Py_DECREF(x);
3184#endif
3185#ifdef AL_RATE_UNACQUIRED
3186 x = PyInt_FromLong((long) AL_RATE_UNACQUIRED);
3187 if (x == NULL || PyDict_SetItemString(d, "RATE_UNACQUIRED", x) < 0)
3188 goto error;
3189 Py_DECREF(x);
3190#endif
3191#ifdef AL_RATE_UNDEFINED
3192 x = PyInt_FromLong((long) AL_RATE_UNDEFINED);
3193 if (x == NULL || PyDict_SetItemString(d, "RATE_UNDEFINED", x) < 0)
3194 goto error;
3195 Py_DECREF(x);
3196#endif
3197#ifdef AL_REF_0DBV
3198 x = PyInt_FromLong((long) AL_REF_0DBV);
3199 if (x == NULL || PyDict_SetItemString(d, "REF_0DBV", x) < 0)
3200 goto error;
3201 Py_DECREF(x);
3202#endif
3203#ifdef AL_REF_NONE
3204 x = PyInt_FromLong((long) AL_REF_NONE);
3205 if (x == NULL || PyDict_SetItemString(d, "REF_NONE", x) < 0)
3206 goto error;
3207 Py_DECREF(x);
3208#endif
3209#ifdef AL_RESERVED1_TYPE
3210 x = PyInt_FromLong((long) AL_RESERVED1_TYPE);
3211 if (x == NULL || PyDict_SetItemString(d, "RESERVED1_TYPE", x) < 0)
3212 goto error;
3213 Py_DECREF(x);
3214#endif
3215#ifdef AL_RESERVED2_TYPE
3216 x = PyInt_FromLong((long) AL_RESERVED2_TYPE);
3217 if (x == NULL || PyDict_SetItemString(d, "RESERVED2_TYPE", x) < 0)
3218 goto error;
3219 Py_DECREF(x);
3220#endif
3221#ifdef AL_RESERVED3_TYPE
3222 x = PyInt_FromLong((long) AL_RESERVED3_TYPE);
3223 if (x == NULL || PyDict_SetItemString(d, "RESERVED3_TYPE", x) < 0)
3224 goto error;
3225 Py_DECREF(x);
3226#endif
3227#ifdef AL_RESERVED4_TYPE
3228 x = PyInt_FromLong((long) AL_RESERVED4_TYPE);
3229 if (x == NULL || PyDict_SetItemString(d, "RESERVED4_TYPE", x) < 0)
3230 goto error;
3231 Py_DECREF(x);
3232#endif
3233#ifdef AL_RESOURCE
3234 x = PyInt_FromLong((long) AL_RESOURCE);
3235 if (x == NULL || PyDict_SetItemString(d, "RESOURCE", x) < 0)
3236 goto error;
3237 Py_DECREF(x);
3238#endif
3239#ifdef AL_RESOURCE_ELEM
3240 x = PyInt_FromLong((long) AL_RESOURCE_ELEM);
3241 if (x == NULL || PyDict_SetItemString(d, "RESOURCE_ELEM", x) < 0)
3242 goto error;
3243 Py_DECREF(x);
3244#endif
3245#ifdef AL_RESOURCE_TYPE
3246 x = PyInt_FromLong((long) AL_RESOURCE_TYPE);
3247 if (x == NULL || PyDict_SetItemString(d, "RESOURCE_TYPE", x) < 0)
3248 goto error;
3249 Py_DECREF(x);
3250#endif
3251#ifdef AL_RIGHT_INPUT_ATTEN
3252 x = PyInt_FromLong((long) AL_RIGHT_INPUT_ATTEN);
3253 if (x == NULL || PyDict_SetItemString(d, "RIGHT_INPUT_ATTEN", x) < 0)
3254 goto error;
3255 Py_DECREF(x);
3256#endif
3257#ifdef AL_RIGHT_MONITOR_ATTEN
3258 x = PyInt_FromLong((long) AL_RIGHT_MONITOR_ATTEN);
3259 if (x == NULL || PyDict_SetItemString(d, "RIGHT_MONITOR_ATTEN", x) < 0)
3260 goto error;
3261 Py_DECREF(x);
3262#endif
3263#ifdef AL_RIGHT_SPEAKER_GAIN
3264 x = PyInt_FromLong((long) AL_RIGHT_SPEAKER_GAIN);
3265 if (x == NULL || PyDict_SetItemString(d, "RIGHT_SPEAKER_GAIN", x) < 0)
3266 goto error;
3267 Py_DECREF(x);
3268#endif
3269#ifdef AL_RIGHT1_INPUT_ATTEN
3270 x = PyInt_FromLong((long) AL_RIGHT1_INPUT_ATTEN);
3271 if (x == NULL || PyDict_SetItemString(d, "RIGHT1_INPUT_ATTEN", x) < 0)
3272 goto error;
3273 Py_DECREF(x);
3274#endif
3275#ifdef AL_RIGHT2_INPUT_ATTEN
3276 x = PyInt_FromLong((long) AL_RIGHT2_INPUT_ATTEN);
3277 if (x == NULL || PyDict_SetItemString(d, "RIGHT2_INPUT_ATTEN", x) < 0)
3278 goto error;
3279 Py_DECREF(x);
3280#endif
3281#ifdef AL_SAMPFMT_DOUBLE
3282 x = PyInt_FromLong((long) AL_SAMPFMT_DOUBLE);
3283 if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_DOUBLE", x) < 0)
3284 goto error;
3285 Py_DECREF(x);
3286#endif
3287#ifdef AL_SAMPFMT_FLOAT
3288 x = PyInt_FromLong((long) AL_SAMPFMT_FLOAT);
3289 if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_FLOAT", x) < 0)
3290 goto error;
3291 Py_DECREF(x);
3292#endif
3293#ifdef AL_SAMPFMT_TWOSCOMP
3294 x = PyInt_FromLong((long) AL_SAMPFMT_TWOSCOMP);
3295 if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_TWOSCOMP", x) < 0)
3296 goto error;
3297 Py_DECREF(x);
3298#endif
3299#ifdef AL_SAMPLE_16
3300 x = PyInt_FromLong((long) AL_SAMPLE_16);
3301 if (x == NULL || PyDict_SetItemString(d, "SAMPLE_16", x) < 0)
3302 goto error;
3303 Py_DECREF(x);
3304#endif
3305#ifdef AL_SAMPLE_24
3306 x = PyInt_FromLong((long) AL_SAMPLE_24);
3307 if (x == NULL || PyDict_SetItemString(d, "SAMPLE_24", x) < 0)
3308 goto error;
3309 Py_DECREF(x);
3310#endif
3311#ifdef AL_SAMPLE_8
3312 x = PyInt_FromLong((long) AL_SAMPLE_8);
3313 if (x == NULL || PyDict_SetItemString(d, "SAMPLE_8", x) < 0)
3314 goto error;
3315 Py_DECREF(x);
3316#endif
3317#ifdef AL_SCALAR_VAL
3318 x = PyInt_FromLong((long) AL_SCALAR_VAL);
3319 if (x == NULL || PyDict_SetItemString(d, "SCALAR_VAL", x) < 0)
3320 goto error;
3321 Py_DECREF(x);
3322#endif
3323#ifdef AL_SET_VAL
3324 x = PyInt_FromLong((long) AL_SET_VAL);
3325 if (x == NULL || PyDict_SetItemString(d, "SET_VAL", x) < 0)
3326 goto error;
3327 Py_DECREF(x);
3328#endif
3329#ifdef AL_SHORT_NAME
3330 x = PyInt_FromLong((long) AL_SHORT_NAME);
3331 if (x == NULL || PyDict_SetItemString(d, "SHORT_NAME", x) < 0)
3332 goto error;
3333 Py_DECREF(x);
3334#endif
3335#ifdef AL_SOURCE
3336 x = PyInt_FromLong((long) AL_SOURCE);
3337 if (x == NULL || PyDict_SetItemString(d, "SOURCE", x) < 0)
3338 goto error;
3339 Py_DECREF(x);
3340#endif
3341#ifdef AL_SPEAKER_IF_TYPE
3342 x = PyInt_FromLong((long) AL_SPEAKER_IF_TYPE);
3343 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_IF_TYPE", x) < 0)
3344 goto error;
3345 Py_DECREF(x);
3346#endif
3347#ifdef AL_SPEAKER_MUTE_CTL
3348 x = PyInt_FromLong((long) AL_SPEAKER_MUTE_CTL);
3349 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_CTL", x) < 0)
3350 goto error;
3351 Py_DECREF(x);
3352#endif
3353#ifdef AL_SPEAKER_MUTE_OFF
3354 x = PyInt_FromLong((long) AL_SPEAKER_MUTE_OFF);
3355 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_OFF", x) < 0)
3356 goto error;
3357 Py_DECREF(x);
3358#endif
3359#ifdef AL_SPEAKER_MUTE_ON
3360 x = PyInt_FromLong((long) AL_SPEAKER_MUTE_ON);
3361 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_ON", x) < 0)
3362 goto error;
3363 Py_DECREF(x);
3364#endif
3365#ifdef AL_SPEAKER_PLUS_LINE_IF_TYPE
3366 x = PyInt_FromLong((long) AL_SPEAKER_PLUS_LINE_IF_TYPE);
3367 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_PLUS_LINE_IF_TYPE", x) < 0)
3368 goto error;
3369 Py_DECREF(x);
3370#endif
3371#ifdef AL_STEREO
3372 x = PyInt_FromLong((long) AL_STEREO);
3373 if (x == NULL || PyDict_SetItemString(d, "STEREO", x) < 0)
3374 goto error;
3375 Py_DECREF(x);
3376#endif
3377#ifdef AL_STRING_VAL
3378 x = PyInt_FromLong((long) AL_STRING_VAL);
3379 if (x == NULL || PyDict_SetItemString(d, "STRING_VAL", x) < 0)
3380 goto error;
3381 Py_DECREF(x);
3382#endif
3383#ifdef AL_SUBSYSTEM
3384 x = PyInt_FromLong((long) AL_SUBSYSTEM);
3385 if (x == NULL || PyDict_SetItemString(d, "SUBSYSTEM", x) < 0)
3386 goto error;
3387 Py_DECREF(x);
3388#endif
3389#ifdef AL_SUBSYSTEM_TYPE
3390 x = PyInt_FromLong((long) AL_SUBSYSTEM_TYPE);
3391 if (x == NULL || PyDict_SetItemString(d, "SUBSYSTEM_TYPE", x) < 0)
3392 goto error;
3393 Py_DECREF(x);
3394#endif
3395#ifdef AL_SYNC_INPUT_TO_AES
3396 x = PyInt_FromLong((long) AL_SYNC_INPUT_TO_AES);
3397 if (x == NULL || PyDict_SetItemString(d, "SYNC_INPUT_TO_AES", x) < 0)
3398 goto error;
3399 Py_DECREF(x);
3400#endif
3401#ifdef AL_SYNC_OUTPUT_TO_AES
3402 x = PyInt_FromLong((long) AL_SYNC_OUTPUT_TO_AES);
3403 if (x == NULL || PyDict_SetItemString(d, "SYNC_OUTPUT_TO_AES", x) < 0)
3404 goto error;
3405 Py_DECREF(x);
3406#endif
3407#ifdef AL_SYSTEM
3408 x = PyInt_FromLong((long) AL_SYSTEM);
3409 if (x == NULL || PyDict_SetItemString(d, "SYSTEM", x) < 0)
3410 goto error;
3411 Py_DECREF(x);
3412#endif
3413#ifdef AL_SYSTEM_TYPE
3414 x = PyInt_FromLong((long) AL_SYSTEM_TYPE);
3415 if (x == NULL || PyDict_SetItemString(d, "SYSTEM_TYPE", x) < 0)
3416 goto error;
3417 Py_DECREF(x);
3418#endif
3419#ifdef AL_TEST_IF_TYPE
3420 x = PyInt_FromLong((long) AL_TEST_IF_TYPE);
3421 if (x == NULL || PyDict_SetItemString(d, "TEST_IF_TYPE", x) < 0)
3422 goto error;
3423 Py_DECREF(x);
3424#endif
3425#ifdef AL_TYPE
3426 x = PyInt_FromLong((long) AL_TYPE);
3427 if (x == NULL || PyDict_SetItemString(d, "TYPE", x) < 0)
3428 goto error;
3429 Py_DECREF(x);
3430#endif
3431#ifdef AL_TYPE_BIT
3432 x = PyInt_FromLong((long) AL_TYPE_BIT);
3433 if (x == NULL || PyDict_SetItemString(d, "TYPE_BIT", x) < 0)
3434 goto error;
3435 Py_DECREF(x);
3436#endif
3437#ifdef AL_UNUSED_COUNT
3438 x = PyInt_FromLong((long) AL_UNUSED_COUNT);
3439 if (x == NULL || PyDict_SetItemString(d, "UNUSED_COUNT", x) < 0)
3440 goto error;
3441 Py_DECREF(x);
3442#endif
3443#ifdef AL_UNUSED_PORTS
3444 x = PyInt_FromLong((long) AL_UNUSED_PORTS);
3445 if (x == NULL || PyDict_SetItemString(d, "UNUSED_PORTS", x) < 0)
3446 goto error;
3447 Py_DECREF(x);
3448#endif
3449#ifdef AL_VARIABLE_MCLK_TYPE
3450 x = PyInt_FromLong((long) AL_VARIABLE_MCLK_TYPE);
3451 if (x == NULL || PyDict_SetItemString(d, "VARIABLE_MCLK_TYPE", x) < 0)
3452 goto error;
3453 Py_DECREF(x);
3454#endif
3455#ifdef AL_VECTOR_VAL
3456 x = PyInt_FromLong((long) AL_VECTOR_VAL);
3457 if (x == NULL || PyDict_SetItemString(d, "VECTOR_VAL", x) < 0)
3458 goto error;
3459 Py_DECREF(x);
3460#endif
3461#ifdef AL_VIDEO_MCLK_TYPE
3462 x = PyInt_FromLong((long) AL_VIDEO_MCLK_TYPE);
3463 if (x == NULL || PyDict_SetItemString(d, "VIDEO_MCLK_TYPE", x) < 0)
3464 goto error;
3465 Py_DECREF(x);
3466#endif
3467#ifdef AL_WORDSIZE
3468 x = PyInt_FromLong((long) AL_WORDSIZE);
3469 if (x == NULL || PyDict_SetItemString(d, "WORDSIZE", x) < 0)
3470 goto error;
3471 Py_DECREF(x);
3472#endif
3473
3474#ifdef AL_NO_ELEM /* IRIX 6 */
3475 (void) alSetErrorHandler(ErrorHandler);
3476#endif /* AL_NO_ELEM */
3477#ifdef OLD_INTERFACE
3478 (void) ALseterrorhandler(ErrorHandler);
3479#endif /* OLD_INTERFACE */
Guido van Rossume3db8621991-09-09 23:33:34 +00003480
Guido van Rossumd641d671997-04-03 17:06:32 +00003481 /* Check for errors */
3482 if (PyErr_Occurred()) {
3483 error:
3484 Py_FatalError("can't initialize module al");
3485 }
Guido van Rossume3db8621991-09-09 23:33:34 +00003486}