blob: 453a41618d5227722e9014fba02ea5d7ab305ca9 [file] [log] [blame]
Guido van Rossumd641d671997-04-03 17:06:32 +00001/***********************************************************
Guido van Rossumfd71b9e2000-06-30 23:50:40 +00002Copyright (c) 2000, BeOpen.com.
3Copyright (c) 1995-2000, Corporation for National Research Initiatives.
4Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
5All rights reserved.
Guido van Rossume3db8621991-09-09 23:33:34 +00006
Guido van Rossumfd71b9e2000-06-30 23:50:40 +00007See the file "Misc/COPYRIGHT" for information on usage and
8redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
Guido van Rossume3db8621991-09-09 23:33:34 +00009******************************************************************/
10
Guido van Rossumd641d671997-04-03 17:06:32 +000011#define OLD_INTERFACE /* define for pre-Irix 6 interface */
Jack Jansene8a3c281993-02-10 14:10:56 +000012
Roger E. Massea2a8b271997-01-03 22:40:34 +000013#include "Python.h"
Guido van Rossumd641d671997-04-03 17:06:32 +000014#include "stringobject.h"
15#include <audio.h>
16#include <stdarg.h>
Guido van Rossume3db8621991-09-09 23:33:34 +000017
Guido van Rossumd641d671997-04-03 17:06:32 +000018#ifndef AL_NO_ELEM
19#ifndef OLD_INTERFACE
20#define OLD_INTERFACE
21#endif /* OLD_INTERFACE */
22#endif /* AL_NO_ELEM */
23
24static PyObject *ErrorObject;
25
26/* ----------------------------------------------------- */
27
28/* Declarations for objects of type port */
Guido van Rossume3db8621991-09-09 23:33:34 +000029
30typedef struct {
Roger E. Massea2a8b271997-01-03 22:40:34 +000031 PyObject_HEAD
Guido van Rossumd641d671997-04-03 17:06:32 +000032 /* XXXX Add your own stuff here */
33 ALport port;
34} alpobject;
Guido van Rossume3db8621991-09-09 23:33:34 +000035
Guido van Rossumd641d671997-04-03 17:06:32 +000036staticforward PyTypeObject Alptype;
Guido van Rossume3db8621991-09-09 23:33:34 +000037
Guido van Rossume3db8621991-09-09 23:33:34 +000038
Guido van Rossumd641d671997-04-03 17:06:32 +000039
40/* ---------------------------------------------------------------- */
41
42/* Declarations for objects of type config */
43
44typedef struct {
45 PyObject_HEAD
46 /* XXXX Add your own stuff here */
47 ALconfig config;
48} alcobject;
49
50staticforward PyTypeObject Alctype;
51
52
53static void
54ErrorHandler(long code, const char *fmt, ...)
55{
56 va_list args;
57 char buf[128];
58
59 va_start(args, fmt);
60 vsprintf(buf, fmt, args);
61 va_end(args);
62 PyErr_SetString(ErrorObject, buf);
63}
64
65#ifdef AL_NO_ELEM /* IRIX 6 */
Guido van Rossumfc58e581992-01-27 16:45:55 +000066
Roger E. Massea2a8b271997-01-03 22:40:34 +000067static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +000068param2python(int resource, int param, ALvalue value, ALparamInfo *pinfo)
69{
70 ALparamInfo info;
71 PyObject *v;
72
73 if (pinfo == NULL) {
74 pinfo = &info;
75 if (alGetParamInfo(resource, param, &info) < 0)
76 return NULL;
77 }
78 switch (pinfo->elementType) {
79 case AL_PTR_ELEM:
80 /* XXXX don't know how to handle this */
81 case AL_NO_ELEM:
82 Py_INCREF(Py_None);
83 return Py_None;
84 case AL_INT32_ELEM:
85 case AL_RESOURCE_ELEM:
86 case AL_ENUM_ELEM:
87 return PyInt_FromLong((long) value.i);
88 case AL_INT64_ELEM:
89 return PyLong_FromLongLong(value.ll);
90 case AL_FIXED_ELEM:
91 return PyFloat_FromDouble(alFixedToDouble(value.ll));
92 case AL_CHAR_ELEM:
93 if (value.ptr == NULL) {
94 Py_INCREF(Py_None);
95 return Py_None;
96 }
97 return PyString_FromString((char *) value.ptr);
98 default:
99 PyErr_SetString(ErrorObject, "unknown element type");
100 return NULL;
101 }
102}
103
104static int
105python2elem(PyObject *item, void *ptr, int elementType)
106{
107 switch (elementType) {
108 case AL_INT32_ELEM:
109 case AL_RESOURCE_ELEM:
110 case AL_ENUM_ELEM:
111 if (!PyInt_Check(item)) {
112 PyErr_BadArgument();
113 return -1;
114 }
115 *((int *) ptr) = PyInt_AsLong(item);
116 break;
117 case AL_INT64_ELEM:
118 if (PyInt_Check(item))
119 *((long long *) ptr) = PyInt_AsLong(item);
120 else if (PyLong_Check(item))
121 *((long long *) ptr) = PyLong_AsLongLong(item);
122 else {
123 PyErr_BadArgument();
124 return -1;
125 }
126 break;
127 case AL_FIXED_ELEM:
128 if (PyInt_Check(item))
129 *((long long *) ptr) = alDoubleToFixed((double) PyInt_AsLong(item));
130 else if (PyFloat_Check(item))
131 *((long long *) ptr) = alDoubleToFixed(PyFloat_AsDouble(item));
132 else {
133 PyErr_BadArgument();
134 return -1;
135 }
136 break;
137 default:
138 PyErr_SetString(ErrorObject, "unknown element type");
139 return -1;
140 }
141 return 0;
142}
143
144static int
145python2param(int resource, ALpv *param, PyObject *value, ALparamInfo *pinfo)
146{
147 ALparamInfo info;
148 int i, stepsize;
149 PyObject *item;
150
151 if (pinfo == NULL) {
152 pinfo = &info;
153 if (alGetParamInfo(resource, param->param, &info) < 0)
154 return -1;
155 }
156 switch (pinfo->valueType) {
157 case AL_STRING_VAL:
158 if (pinfo->elementType != AL_CHAR_ELEM) {
159 PyErr_SetString(ErrorObject, "unknown element type");
160 return -1;
161 }
162 if (!PyString_Check(value)) {
163 PyErr_BadArgument();
164 return -1;
165 }
166 param->value.ptr = PyString_AS_STRING(value);
167 param->sizeIn = PyString_GET_SIZE(value)+1; /*account for NUL*/
168 break;
169 case AL_SET_VAL:
170 case AL_VECTOR_VAL:
171 if (!PyList_Check(value) && !PyTuple_Check(value)) {
172 PyErr_BadArgument();
173 return -1;
174 }
175 switch (pinfo->elementType) {
176 case AL_INT32_ELEM:
177 case AL_RESOURCE_ELEM:
178 case AL_ENUM_ELEM:
179 param->sizeIn = PySequence_Length(value);
180 param->value.ptr = PyMem_NEW(int, param->sizeIn);
181 stepsize = sizeof(int);
182 break;
183 case AL_INT64_ELEM:
184 case AL_FIXED_ELEM:
185 param->sizeIn = PySequence_Length(value);
186 param->value.ptr = PyMem_NEW(long long, param->sizeIn);
187 stepsize = sizeof(long long);
188 break;
189 }
190 for (i = 0; i < param->sizeIn; i++) {
191 item = PySequence_GetItem(value, i);
192 if (python2elem(item, (void *) ((char *) param->value.ptr + i*stepsize), pinfo->elementType) < 0) {
193 PyMem_DEL(param->value.ptr);
194 return -1;
195 }
196 }
197 break;
198 case AL_SCALAR_VAL:
199 switch (pinfo->elementType) {
200 case AL_INT32_ELEM:
201 case AL_RESOURCE_ELEM:
202 case AL_ENUM_ELEM:
203 return python2elem(value, (void *) &param->value.i,
204 pinfo->elementType);
Guido van Rossumd641d671997-04-03 17:06:32 +0000205 case AL_INT64_ELEM:
206 case AL_FIXED_ELEM:
207 return python2elem(value, (void *) &param->value.ll,
208 pinfo->elementType);
Guido van Rossumd641d671997-04-03 17:06:32 +0000209 default:
210 PyErr_SetString(ErrorObject, "unknown element type");
211 return -1;
212 }
213 }
214 return 0;
215}
216
217static int
218python2params(int resource1, int resource2, PyObject *list, ALpv **pvsp, ALparamInfo **pinfop)
219{
220 PyObject *item;
221 ALpv *pvs;
222 ALparamInfo *pinfo;
223 int npvs, i;
224
225 npvs = PyList_Size(list);
226 pvs = PyMem_NEW(ALpv, npvs);
227 pinfo = PyMem_NEW(ALparamInfo, npvs);
228 for (i = 0; i < npvs; i++) {
229 item = PyList_GetItem(list, i);
230 if (!PyArg_ParseTuple(item, "iO", &pvs[i].param, &item))
231 goto error;
232 if (alGetParamInfo(resource1, pvs[i].param, &pinfo[i]) < 0 &&
233 alGetParamInfo(resource2, pvs[i].param, &pinfo[i]) < 0)
234 goto error;
235 if (python2param(resource1, &pvs[i], item, &pinfo[i]) < 0)
236 goto error;
237 }
238
239 *pvsp = pvs;
240 *pinfop = pinfo;
241 return npvs;
242
243 error:
244 /* XXXX we should clean up everything */
245 if (pvs)
246 PyMem_DEL(pvs);
247 if (pinfo)
248 PyMem_DEL(pinfo);
249 return -1;
250}
251
252/* -------------------------------------------------------- */
253
254
255static PyObject *
256SetConfig(self, args, func)
257 alcobject *self;
258 PyObject *args;
259 int (*func)(ALconfig, int);
260{
261 int par;
262
Guido van Rossum43713e52000-02-29 13:59:29 +0000263 if (!PyArg_ParseTuple(args, "i:SetConfig", &par))
Guido van Rossumd641d671997-04-03 17:06:32 +0000264 return NULL;
265
266 if ((*func)(self->config, par) == -1)
267 return NULL;
268
269 Py_INCREF(Py_None);
Roger E. Massea2a8b271997-01-03 22:40:34 +0000270 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +0000271}
272
Roger E. Massea2a8b271997-01-03 22:40:34 +0000273static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000274GetConfig(self, args, func)
275 alcobject *self;
276 PyObject *args;
277 int (*func)(ALconfig);
278{
279 int par;
280
Guido van Rossum43713e52000-02-29 13:59:29 +0000281 if (!PyArg_ParseTuple(args, ":GetConfig"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000282 return NULL;
283
284 if ((par = (*func)(self->config)) == -1)
285 return NULL;
286
287 return PyInt_FromLong((long) par);
288}
289
290static char alc_SetWidth__doc__[] =
291"alSetWidth: set the wordsize for integer audio data."
292;
293
294static PyObject *
295alc_SetWidth(self, args)
296 alcobject *self;
297 PyObject *args;
298{
299 return SetConfig(self, args, alSetWidth);
300}
301
302
303static char alc_GetWidth__doc__[] =
304"alGetWidth: get the wordsize for integer audio data."
305;
306
307static PyObject *
308alc_GetWidth(self, args)
309 alcobject *self;
310 PyObject *args;
311{
312 return GetConfig(self, args, alGetWidth);
313}
314
315
316static char alc_SetSampFmt__doc__[] =
317"alSetSampFmt: set the sample format setting in an audio ALconfig structure."
318;
319
320static PyObject *
321alc_SetSampFmt(self, args)
322 alcobject *self;
323 PyObject *args;
324{
325 return SetConfig(self, args, alSetSampFmt);
326}
327
328
329static char alc_GetSampFmt__doc__[] =
330"alGetSampFmt: get the sample format setting in an audio ALconfig structure."
331;
332
333static PyObject *
334alc_GetSampFmt(self, args)
335 alcobject *self;
336 PyObject *args;
337{
338 return GetConfig(self, args, alGetSampFmt);
339}
340
341
342static char alc_SetChannels__doc__[] =
343"alSetChannels: set the channel settings in an audio ALconfig."
344;
345
346static PyObject *
347alc_SetChannels(self, args)
348 alcobject *self;
349 PyObject *args;
350{
351 return SetConfig(self, args, alSetChannels);
352}
353
354
355static char alc_GetChannels__doc__[] =
356"alGetChannels: get the channel settings in an audio ALconfig."
357;
358
359static PyObject *
360alc_GetChannels(self, args)
361 alcobject *self;
362 PyObject *args;
363{
364 return GetConfig(self, args, alGetChannels);
365}
366
367
368static char alc_SetFloatMax__doc__[] =
369"alSetFloatMax: set the maximum value of floating point sample data."
370;
371
372static PyObject *
373alc_SetFloatMax(self, args)
374 alcobject *self;
375 PyObject *args;
376{
377 double maximum_value;
378
Guido van Rossum43713e52000-02-29 13:59:29 +0000379 if (!PyArg_ParseTuple(args, "d:SetFloatMax", &maximum_value))
Guido van Rossumd641d671997-04-03 17:06:32 +0000380 return NULL;
381 if (alSetFloatMax(self->config, maximum_value) < 0)
382 return NULL;
383 Py_INCREF(Py_None);
384 return Py_None;
385}
386
387
388static char alc_GetFloatMax__doc__[] =
389"alGetFloatMax: get the maximum value of floating point sample data."
390;
391
392static PyObject *
393alc_GetFloatMax(self, args)
394 alcobject *self;
395 PyObject *args;
396{
397 double maximum_value;
398
Guido van Rossum43713e52000-02-29 13:59:29 +0000399 if (!PyArg_ParseTuple(args, ":GetFloatMax"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000400 return NULL;
401 if ((maximum_value = alGetFloatMax(self->config)) == 0)
402 return NULL;
403 return PyFloat_FromDouble(maximum_value);
404}
405
406
407static char alc_SetDevice__doc__[] =
408"alSetDevice: set the device setting in an audio ALconfig structure."
409;
410
411static PyObject *
412alc_SetDevice(self, args)
413 alcobject *self;
414 PyObject *args;
415{
416 return SetConfig(self, args, alSetDevice);
417}
418
419
420static char alc_GetDevice__doc__[] =
421"alGetDevice: get the device setting in an audio ALconfig structure."
422;
423
424static PyObject *
425alc_GetDevice(self, args)
426 alcobject *self;
427 PyObject *args;
428{
429 return GetConfig(self, args, alGetDevice);
430}
431
432
433static char alc_SetQueueSize__doc__[] =
434"alSetQueueSize: set audio port buffer size."
435;
436
437static PyObject *
438alc_SetQueueSize(self, args)
439 alcobject *self;
440 PyObject *args;
441{
442 return SetConfig(self, args, alSetQueueSize);
443}
444
445
446static char alc_GetQueueSize__doc__[] =
447"alGetQueueSize: get audio port buffer size."
448;
449
450static PyObject *
451alc_GetQueueSize(self, args)
452 alcobject *self;
453 PyObject *args;
454{
455 return GetConfig(self, args, alGetQueueSize);
456}
457
458#endif /* AL_NO_ELEM */
459
460static PyObject *
461setconfig(self, args, func)
462 alcobject *self;
463 PyObject *args;
464 int (*func)(ALconfig, long);
465{
466 long par;
467
Guido van Rossum43713e52000-02-29 13:59:29 +0000468 if (!PyArg_ParseTuple(args, "l:SetConfig", &par))
Guido van Rossumd641d671997-04-03 17:06:32 +0000469 return NULL;
470
471 if ((*func)(self->config, par) == -1)
472 return NULL;
473
474 Py_INCREF(Py_None);
475 return Py_None;
476}
477
478static PyObject *
479getconfig(self, args, func)
480 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000481 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000482 long (*func)(ALconfig);
483{
484 long par;
485
Guido van Rossum43713e52000-02-29 13:59:29 +0000486 if (!PyArg_ParseTuple(args, ":GetConfig"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000487 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000488
Guido van Rossumd641d671997-04-03 17:06:32 +0000489 if ((par = (*func)(self->config)) == -1)
490 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000491
Guido van Rossumd641d671997-04-03 17:06:32 +0000492 return PyInt_FromLong((long) par);
Guido van Rossume3db8621991-09-09 23:33:34 +0000493}
494
Roger E. Massea2a8b271997-01-03 22:40:34 +0000495static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000496alc_setqueuesize (self, args)
497 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000498 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000499{
Guido van Rossumd641d671997-04-03 17:06:32 +0000500 return setconfig(self, args, ALsetqueuesize);
Guido van Rossume3db8621991-09-09 23:33:34 +0000501}
502
Roger E. Massea2a8b271997-01-03 22:40:34 +0000503static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000504alc_getqueuesize (self, args)
505 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000506 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000507{
Guido van Rossumd641d671997-04-03 17:06:32 +0000508 return getconfig(self, args, ALgetqueuesize);
Guido van Rossume3db8621991-09-09 23:33:34 +0000509}
510
Roger E. Massea2a8b271997-01-03 22:40:34 +0000511static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000512alc_setwidth (self, args)
513 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000514 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000515{
Guido van Rossumd641d671997-04-03 17:06:32 +0000516 return setconfig(self, args, ALsetwidth);
Guido van Rossume3db8621991-09-09 23:33:34 +0000517}
518
Roger E. Massea2a8b271997-01-03 22:40:34 +0000519static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000520alc_getwidth (self, args)
521 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000522 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000523{
Guido van Rossumd641d671997-04-03 17:06:32 +0000524 return getconfig(self, args, ALgetwidth);
Guido van Rossume3db8621991-09-09 23:33:34 +0000525}
526
Roger E. Massea2a8b271997-01-03 22:40:34 +0000527static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000528alc_getchannels (self, args)
529 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000530 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000531{
Guido van Rossumd641d671997-04-03 17:06:32 +0000532 return getconfig(self, args, ALgetchannels);
Guido van Rossume3db8621991-09-09 23:33:34 +0000533}
534
Roger E. Massea2a8b271997-01-03 22:40:34 +0000535static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000536alc_setchannels (self, args)
537 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000538 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000539{
Guido van Rossumd641d671997-04-03 17:06:32 +0000540 return setconfig(self, args, ALsetchannels);
Guido van Rossume3db8621991-09-09 23:33:34 +0000541}
542
Jack Jansene8a3c281993-02-10 14:10:56 +0000543#ifdef AL_405
544
Roger E. Massea2a8b271997-01-03 22:40:34 +0000545static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000546alc_getsampfmt (self, args)
547 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000548 PyObject *args;
Jack Jansene8a3c281993-02-10 14:10:56 +0000549{
Guido van Rossumd641d671997-04-03 17:06:32 +0000550 return getconfig(self, args, ALgetsampfmt);
Jack Jansene8a3c281993-02-10 14:10:56 +0000551}
552
Roger E. Massea2a8b271997-01-03 22:40:34 +0000553static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000554alc_setsampfmt (self, args)
555 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000556 PyObject *args;
Jack Jansene8a3c281993-02-10 14:10:56 +0000557{
Guido van Rossumd641d671997-04-03 17:06:32 +0000558 return setconfig(self, args, ALsetsampfmt);
Jack Jansene8a3c281993-02-10 14:10:56 +0000559}
560
Roger E. Massea2a8b271997-01-03 22:40:34 +0000561static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000562alc_getfloatmax(self, args)
563 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000564 PyObject *args;
Jack Jansene8a3c281993-02-10 14:10:56 +0000565{
566 double arg;
567
Guido van Rossum43713e52000-02-29 13:59:29 +0000568 if (!PyArg_ParseTuple(args, ":GetFloatMax"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000569 return 0;
570 if ((arg = ALgetfloatmax(self->config)) == 0)
571 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000572 return PyFloat_FromDouble(arg);
Jack Jansene8a3c281993-02-10 14:10:56 +0000573}
574
Roger E. Massea2a8b271997-01-03 22:40:34 +0000575static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000576alc_setfloatmax(self, args)
577 alcobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000578 PyObject *args;
Jack Jansene8a3c281993-02-10 14:10:56 +0000579{
580 double arg;
581
Guido van Rossum43713e52000-02-29 13:59:29 +0000582 if (!PyArg_ParseTuple(args, "d:SetFloatMax", &arg))
Guido van Rossumd641d671997-04-03 17:06:32 +0000583 return 0;
584 if (ALsetfloatmax(self->config, arg) == -1)
585 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000586 Py_INCREF(Py_None);
587 return Py_None;
Jack Jansene8a3c281993-02-10 14:10:56 +0000588}
589#endif /* AL_405 */
590
Guido van Rossumd641d671997-04-03 17:06:32 +0000591static struct PyMethodDef alc_methods[] = {
592#ifdef AL_NO_ELEM /* IRIX 6 */
593 {"SetWidth", (PyCFunction)alc_SetWidth, METH_VARARGS, alc_SetWidth__doc__},
594 {"GetWidth", (PyCFunction)alc_GetWidth, METH_VARARGS, alc_GetWidth__doc__},
595 {"SetSampFmt", (PyCFunction)alc_SetSampFmt, METH_VARARGS, alc_SetSampFmt__doc__},
596 {"GetSampFmt", (PyCFunction)alc_GetSampFmt, METH_VARARGS, alc_GetSampFmt__doc__},
597 {"SetChannels", (PyCFunction)alc_SetChannels, METH_VARARGS, alc_SetChannels__doc__},
598 {"GetChannels", (PyCFunction)alc_GetChannels, METH_VARARGS, alc_GetChannels__doc__},
599 {"SetFloatMax", (PyCFunction)alc_SetFloatMax, METH_VARARGS, alc_SetFloatMax__doc__},
600 {"GetFloatMax", (PyCFunction)alc_GetFloatMax, METH_VARARGS, alc_GetFloatMax__doc__},
601 {"SetDevice", (PyCFunction)alc_SetDevice, METH_VARARGS, alc_SetDevice__doc__},
602 {"GetDevice", (PyCFunction)alc_GetDevice, METH_VARARGS, alc_GetDevice__doc__},
603 {"SetQueueSize", (PyCFunction)alc_SetQueueSize, METH_VARARGS, alc_SetQueueSize__doc__},
604 {"GetQueueSize", (PyCFunction)alc_GetQueueSize, METH_VARARGS, alc_GetQueueSize__doc__},
605#endif /* AL_NO_ELEM */
606 {"getqueuesize", (PyCFunction)alc_getqueuesize, METH_VARARGS},
607 {"setqueuesize", (PyCFunction)alc_setqueuesize, METH_VARARGS},
608 {"getwidth", (PyCFunction)alc_getwidth, METH_VARARGS},
609 {"setwidth", (PyCFunction)alc_setwidth, METH_VARARGS},
610 {"getchannels", (PyCFunction)alc_getchannels, METH_VARARGS},
611 {"setchannels", (PyCFunction)alc_setchannels, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +0000612#ifdef AL_405
Guido van Rossumd641d671997-04-03 17:06:32 +0000613 {"getsampfmt", (PyCFunction)alc_getsampfmt, METH_VARARGS},
614 {"setsampfmt", (PyCFunction)alc_setsampfmt, METH_VARARGS},
615 {"getfloatmax", (PyCFunction)alc_getfloatmax, METH_VARARGS},
616 {"setfloatmax", (PyCFunction)alc_setfloatmax, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +0000617#endif /* AL_405 */
Guido van Rossumd641d671997-04-03 17:06:32 +0000618
619 {NULL, NULL} /* sentinel */
Guido van Rossume3db8621991-09-09 23:33:34 +0000620};
621
Guido van Rossumd641d671997-04-03 17:06:32 +0000622/* ---------- */
623
624
625static PyObject *
626newalcobject(ALconfig config)
Guido van Rossume3db8621991-09-09 23:33:34 +0000627{
Guido van Rossumd641d671997-04-03 17:06:32 +0000628 alcobject *self;
629
Guido van Rossumb18618d2000-05-03 23:44:39 +0000630 self = PyObject_New(alcobject, &Alctype);
Guido van Rossumd641d671997-04-03 17:06:32 +0000631 if (self == NULL)
632 return NULL;
633 /* XXXX Add your own initializers here */
634 self->config = config;
635 return (PyObject *) self;
636}
637
638
639static void
640alc_dealloc(self)
641 alcobject *self;
642{
643 /* XXXX Add your own cleanup code here */
644#ifdef AL_NO_ELEM /* IRIX 6 */
645 (void) alFreeConfig(self->config); /* ignore errors */
646#else
647 (void) ALfreeconfig(self->config); /* ignore errors */
648#endif
Guido van Rossumb18618d2000-05-03 23:44:39 +0000649 PyObject_Del(self);
Guido van Rossume3db8621991-09-09 23:33:34 +0000650}
651
Roger E. Massea2a8b271997-01-03 22:40:34 +0000652static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000653alc_getattr(self, name)
654 alcobject *self;
Guido van Rossume3db8621991-09-09 23:33:34 +0000655 char *name;
656{
Guido van Rossumd641d671997-04-03 17:06:32 +0000657 /* XXXX Add your own getattr code here */
658 return Py_FindMethod(alc_methods, (PyObject *)self, name);
Guido van Rossume3db8621991-09-09 23:33:34 +0000659}
660
Guido van Rossumd641d671997-04-03 17:06:32 +0000661static char Alctype__doc__[] =
662""
663;
664
665static PyTypeObject Alctype = {
Roger E. Massea2a8b271997-01-03 22:40:34 +0000666 PyObject_HEAD_INIT(&PyType_Type)
Guido van Rossumd641d671997-04-03 17:06:32 +0000667 0, /*ob_size*/
668 "config", /*tp_name*/
669 sizeof(alcobject), /*tp_basicsize*/
670 0, /*tp_itemsize*/
Guido van Rossume3db8621991-09-09 23:33:34 +0000671 /* methods */
Guido van Rossumd641d671997-04-03 17:06:32 +0000672 (destructor)alc_dealloc, /*tp_dealloc*/
673 (printfunc)0, /*tp_print*/
674 (getattrfunc)alc_getattr, /*tp_getattr*/
675 (setattrfunc)0, /*tp_setattr*/
676 (cmpfunc)0, /*tp_compare*/
677 (reprfunc)0, /*tp_repr*/
678 0, /*tp_as_number*/
679 0, /*tp_as_sequence*/
680 0, /*tp_as_mapping*/
681 (hashfunc)0, /*tp_hash*/
682 (ternaryfunc)0, /*tp_call*/
683 (reprfunc)0, /*tp_str*/
684
685 /* Space for future expansion */
686 0L,0L,0L,0L,
687 Alctype__doc__ /* Documentation string */
Guido van Rossume3db8621991-09-09 23:33:34 +0000688};
689
Guido van Rossumd641d671997-04-03 17:06:32 +0000690/* End of code for config objects */
691/* ---------------------------------------------------------------- */
Guido van Rossume3db8621991-09-09 23:33:34 +0000692
Guido van Rossumd641d671997-04-03 17:06:32 +0000693#ifdef AL_NO_ELEM /* IRIX 6 */
Guido van Rossume3db8621991-09-09 23:33:34 +0000694
Guido van Rossumd641d671997-04-03 17:06:32 +0000695static char alp_SetConfig__doc__[] =
696"alSetConfig: set the ALconfig of an audio ALport."
697;
Guido van Rossume3db8621991-09-09 23:33:34 +0000698
Roger E. Massea2a8b271997-01-03 22:40:34 +0000699static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000700alp_SetConfig(self, args)
701 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000702 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000703{
Guido van Rossumd641d671997-04-03 17:06:32 +0000704 alcobject *config;
Guido van Rossum43713e52000-02-29 13:59:29 +0000705 if (!PyArg_ParseTuple(args, "O!:SetConfig", &Alctype, &config))
Guido van Rossumd641d671997-04-03 17:06:32 +0000706 return NULL;
707 if (alSetConfig(self->port, config->config) < 0)
708 return NULL;
709 Py_INCREF(Py_None);
Roger E. Massea2a8b271997-01-03 22:40:34 +0000710 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +0000711}
712
Guido van Rossumd641d671997-04-03 17:06:32 +0000713
714static char alp_GetConfig__doc__[] =
715"alGetConfig: get the ALconfig of an audio ALport."
716;
717
Roger E. Massea2a8b271997-01-03 22:40:34 +0000718static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +0000719alp_GetConfig(self, args)
720 alpobject *self;
721 PyObject *args;
722{
723 ALconfig config;
Guido van Rossum43713e52000-02-29 13:59:29 +0000724 if (!PyArg_ParseTuple(args, ":GetConfig"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000725 return NULL;
726 if ((config = alGetConfig(self->port)) == NULL)
727 return NULL;
728 return newalcobject(config);
729}
730
731
732static char alp_GetResource__doc__[] =
733"alGetResource: get the resource associated with an audio port."
734;
735
736static PyObject *
737alp_GetResource(self, args)
738 alpobject *self;
739 PyObject *args;
740{
741 int resource;
742
Guido van Rossum43713e52000-02-29 13:59:29 +0000743 if (!PyArg_ParseTuple(args, ":GetResource"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000744 return NULL;
745 if ((resource = alGetResource(self->port)) == 0)
746 return NULL;
747 return PyInt_FromLong((long) resource);
748}
749
750
751static char alp_GetFD__doc__[] =
752"alGetFD: get the file descriptor for an audio port."
753;
754
755static PyObject *
756alp_GetFD(self, args)
757 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000758 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +0000759{
760 int fd;
761
Guido van Rossum43713e52000-02-29 13:59:29 +0000762 if (!PyArg_ParseTuple(args, ":GetFD"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000763 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000764
Guido van Rossumd641d671997-04-03 17:06:32 +0000765 if ((fd = alGetFD(self->port)) < 0)
766 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000767
Guido van Rossumd641d671997-04-03 17:06:32 +0000768 return PyInt_FromLong((long) fd);
769}
770
771
772static char alp_GetFilled__doc__[] =
773"alGetFilled: return the number of filled sample frames in an audio port."
774;
775
776static PyObject *
777alp_GetFilled(self, args)
778 alpobject *self;
779 PyObject *args;
780{
781 int filled;
782
Guido van Rossum43713e52000-02-29 13:59:29 +0000783 if (!PyArg_ParseTuple(args, ":GetFilled"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000784 return NULL;
785 if ((filled = alGetFilled(self->port)) < 0)
786 return NULL;
787 return PyInt_FromLong((long) filled);
788}
789
790
791static char alp_GetFillable__doc__[] =
792"alGetFillable: report the number of unfilled sample frames in an audio port."
793;
794
795static PyObject *
796alp_GetFillable(self, args)
797 alpobject *self;
798 PyObject *args;
799{
800 int fillable;
801
Guido van Rossum43713e52000-02-29 13:59:29 +0000802 if (!PyArg_ParseTuple(args, ":GetFillable"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000803 return NULL;
804 if ((fillable = alGetFillable(self->port)) < 0)
805 return NULL;
806 return PyInt_FromLong((long) fillable);
807}
808
809
810static char alp_ReadFrames__doc__[] =
811"alReadFrames: read sample frames from an audio port."
812;
813
814static PyObject *
815alp_ReadFrames(self, args)
816 alpobject *self;
817 PyObject *args;
818{
819 void *samples;
820 int framecount;
821 PyObject *v;
822 int size;
823 int ch;
824 ALconfig c;
825
Guido van Rossum43713e52000-02-29 13:59:29 +0000826 if (!PyArg_ParseTuple(args, "i:ReadFrames", &framecount))
Guido van Rossumd641d671997-04-03 17:06:32 +0000827 return NULL;
828 if (framecount < 0) {
829 PyErr_SetString(ErrorObject, "negative framecount");
830 return NULL;
831 }
832 c = alGetConfig(self->port);
833 switch (alGetSampFmt(c)) {
834 case AL_SAMPFMT_TWOSCOMP:
835 switch (alGetWidth(c)) {
836 case AL_SAMPLE_8:
837 size = 1;
838 break;
839 case AL_SAMPLE_16:
840 size = 2;
841 break;
842 case AL_SAMPLE_24:
843 size = 4;
844 break;
845 default:
846 PyErr_SetString(ErrorObject, "can't determine width");
847 alFreeConfig(c);
848 return NULL;
849 }
850 break;
851 case AL_SAMPFMT_FLOAT:
852 size = 4;
853 break;
854 case AL_SAMPFMT_DOUBLE:
855 size = 8;
856 break;
857 default:
858 PyErr_SetString(ErrorObject, "can't determine format");
859 alFreeConfig(c);
860 return NULL;
861 }
862 ch = alGetChannels(c);
863 alFreeConfig(c);
864 if (ch < 0) {
865 PyErr_SetString(ErrorObject, "can't determine # of channels");
866 return NULL;
867 }
868 size *= ch;
869 v = PyString_FromStringAndSize((char *) NULL, size * framecount);
870 if (v == NULL)
871 return NULL;
872
873 Py_BEGIN_ALLOW_THREADS
874 alReadFrames(self->port, (void *) PyString_AS_STRING(v), framecount);
875 Py_END_ALLOW_THREADS
876
877 return v;
878}
879
880
881static char alp_DiscardFrames__doc__[] =
882"alDiscardFrames: discard audio from an audio port."
883;
884
885static PyObject *
886alp_DiscardFrames(self, args)
887 alpobject *self;
888 PyObject *args;
889{
890 int framecount;
891
Guido van Rossum43713e52000-02-29 13:59:29 +0000892 if (!PyArg_ParseTuple(args, "i:DiscardFrames", &framecount))
Guido van Rossumd641d671997-04-03 17:06:32 +0000893 return NULL;
894
895 Py_BEGIN_ALLOW_THREADS
896 framecount = alDiscardFrames(self->port, framecount);
897 Py_END_ALLOW_THREADS
898
899 if (framecount < 0)
900 return NULL;
901
902 return PyInt_FromLong((long) framecount);
903}
904
905
906static char alp_ZeroFrames__doc__[] =
907"alZeroFrames: write zero-valued sample frames to an audio port."
908;
909
910static PyObject *
911alp_ZeroFrames(self, args)
912 alpobject *self;
913 PyObject *args;
914{
915 int framecount;
916
Guido van Rossum43713e52000-02-29 13:59:29 +0000917 if (!PyArg_ParseTuple(args, "i:ZeroFrames", &framecount))
Guido van Rossumd641d671997-04-03 17:06:32 +0000918 return NULL;
919
920 if (framecount < 0) {
921 PyErr_SetString(ErrorObject, "negative framecount");
922 return NULL;
923 }
924
925 Py_BEGIN_ALLOW_THREADS
926 alZeroFrames(self->port, framecount);
927 Py_END_ALLOW_THREADS
928
929 Py_INCREF(Py_None);
930 return Py_None;
931}
932
933
934static char alp_SetFillPoint__doc__[] =
935"alSetFillPoint: set low- or high-water mark for an audio port."
936;
937
938static PyObject *
939alp_SetFillPoint(self, args)
940 alpobject *self;
941 PyObject *args;
942{
943 int fillpoint;
944
Guido van Rossum43713e52000-02-29 13:59:29 +0000945 if (!PyArg_ParseTuple(args, "i:SetFillPoint", &fillpoint))
Guido van Rossumd641d671997-04-03 17:06:32 +0000946 return NULL;
947
948 if (alSetFillPoint(self->port, fillpoint) < 0)
949 return NULL;
950
951 Py_INCREF(Py_None);
952 return Py_None;
953}
954
955
956static char alp_GetFillPoint__doc__[] =
957"alGetFillPoint: get low- or high-water mark for an audio port."
958;
959
960static PyObject *
961alp_GetFillPoint(self, args)
962 alpobject *self;
963 PyObject *args;
964{
965 int fillpoint;
966
Guido van Rossum43713e52000-02-29 13:59:29 +0000967 if (!PyArg_ParseTuple(args, ":GetFillPoint"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000968 return NULL;
969
970 if ((fillpoint = alGetFillPoint(self->port)) < 0)
971 return NULL;
972
973 return PyInt_FromLong((long) fillpoint);
974}
975
976
977static char alp_GetFrameNumber__doc__[] =
978"alGetFrameNumber: get the absolute sample frame number associated with a port."
979;
980
981static PyObject *
982alp_GetFrameNumber(self, args)
983 alpobject *self;
984 PyObject *args;
985{
986 stamp_t fnum;
987
Guido van Rossum43713e52000-02-29 13:59:29 +0000988 if (!PyArg_ParseTuple(args, ":GetFrameNumber"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000989 return NULL;
990
991 if (alGetFrameNumber(self->port, &fnum) < 0)
992 return NULL;
993
994 return PyLong_FromLongLong((long long) fnum);
995}
996
997
998static char alp_GetFrameTime__doc__[] =
999"alGetFrameTime: get the time at which a sample frame came in or will go out."
1000;
1001
1002static PyObject *
1003alp_GetFrameTime(self, args)
1004 alpobject *self;
1005 PyObject *args;
1006{
1007 stamp_t fnum, time;
1008 PyObject *ret, *v0, *v1;
1009
Guido van Rossum43713e52000-02-29 13:59:29 +00001010 if (!PyArg_ParseTuple(args, ":GetFrameTime"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001011 return NULL;
1012 if (alGetFrameTime(self->port, &fnum, &time) < 0)
1013 return NULL;
1014 v0 = PyLong_FromLongLong((long long) fnum);
1015 v1 = PyLong_FromLongLong((long long) time);
1016 if (PyErr_Occurred()) {
1017 Py_XDECREF(v0);
1018 Py_XDECREF(v1);
1019 return NULL;
1020 }
1021 ret = Py_BuildValue("(OO)", v0, v1);
1022 Py_DECREF(v0);
1023 Py_DECREF(v1);
1024 return ret;
1025}
1026
1027
1028static char alp_WriteFrames__doc__[] =
1029"alWriteFrames: write sample frames to an audio port."
1030;
1031
1032static PyObject *
1033alp_WriteFrames(self, args)
1034 alpobject *self;
1035 PyObject *args;
1036{
1037 char *samples;
1038 int length;
1039 int size, ch;
1040 ALconfig c;
1041
Guido van Rossum43713e52000-02-29 13:59:29 +00001042 if (!PyArg_ParseTuple(args, "s#:WriteFrames", &samples, &length))
Guido van Rossumd641d671997-04-03 17:06:32 +00001043 return NULL;
1044 c = alGetConfig(self->port);
1045 switch (alGetSampFmt(c)) {
1046 case AL_SAMPFMT_TWOSCOMP:
1047 switch (alGetWidth(c)) {
1048 case AL_SAMPLE_8:
1049 size = 1;
1050 break;
1051 case AL_SAMPLE_16:
1052 size = 2;
1053 break;
1054 case AL_SAMPLE_24:
1055 size = 4;
1056 break;
1057 default:
1058 PyErr_SetString(ErrorObject, "can't determine width");
1059 alFreeConfig(c);
1060 return NULL;
1061 }
1062 break;
1063 case AL_SAMPFMT_FLOAT:
1064 size = 4;
1065 break;
1066 case AL_SAMPFMT_DOUBLE:
1067 size = 8;
1068 break;
1069 default:
1070 PyErr_SetString(ErrorObject, "can't determine format");
1071 alFreeConfig(c);
1072 return NULL;
1073 }
1074 ch = alGetChannels(c);
1075 alFreeConfig(c);
1076 if (ch < 0) {
1077 PyErr_SetString(ErrorObject, "can't determine # of channels");
1078 return NULL;
1079 }
1080 size *= ch;
1081 if (length % size != 0) {
1082 PyErr_SetString(ErrorObject,
1083 "buffer length not whole number of frames");
1084 return NULL;
1085 }
1086
1087 Py_BEGIN_ALLOW_THREADS
1088 alWriteFrames(self->port, (void *) samples, length / size);
1089 Py_END_ALLOW_THREADS
1090
1091 Py_INCREF(Py_None);
1092 return Py_None;
1093}
1094
1095
1096static char alp_ClosePort__doc__[] =
1097"alClosePort: close an audio port."
1098;
1099
1100static PyObject *
1101alp_ClosePort(self, args)
1102 alpobject *self;
1103 PyObject *args;
1104{
Guido van Rossum43713e52000-02-29 13:59:29 +00001105 if (!PyArg_ParseTuple(args, ":ClosePort"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001106 return NULL;
1107 if (alClosePort(self->port) < 0)
1108 return NULL;
1109 self->port = NULL;
1110 Py_INCREF(Py_None);
1111 return Py_None;
1112}
1113
1114#endif /* AL_NO_ELEM */
1115
1116#ifdef OLD_INTERFACE
1117static PyObject *
1118alp_closeport(self, args)
1119 alpobject *self;
1120 PyObject *args;
1121{
Guido van Rossum43713e52000-02-29 13:59:29 +00001122 if (!PyArg_ParseTuple(args, ":ClosePort"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001123 return NULL;
1124 if (ALcloseport(self->port) < 0)
1125 return NULL;
1126 self->port = NULL;
1127 Py_INCREF(Py_None);
1128 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +00001129}
1130
Roger E. Massea2a8b271997-01-03 22:40:34 +00001131static PyObject *
Guido van Rossum43713e52000-02-29 13:59:29 +00001132alp_getfd(self, args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001133 alpobject *self;
1134 PyObject *args;
1135{
1136 int fd;
1137
Guido van Rossum43713e52000-02-29 13:59:29 +00001138 if (!PyArg_ParseTuple(args, ":GetFD"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001139 return NULL;
1140 if ((fd = ALgetfd(self-> port)) == -1)
1141 return NULL;
1142 return PyInt_FromLong(fd);
1143}
1144
1145static PyObject *
1146alp_getfilled(self, args)
1147 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001148 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001149{
1150 long count;
1151
Guido van Rossum43713e52000-02-29 13:59:29 +00001152 if (!PyArg_ParseTuple(args, ":GetFilled"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001153 return NULL;
1154 if ((count = ALgetfilled(self-> port)) == -1)
1155 return NULL;
1156 return PyInt_FromLong(count);
Guido van Rossume3db8621991-09-09 23:33:34 +00001157}
1158
Roger E. Massea2a8b271997-01-03 22:40:34 +00001159static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001160alp_getfillable(self, args)
1161 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001162 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001163{
1164 long count;
1165
Guido van Rossum43713e52000-02-29 13:59:29 +00001166 if (!PyArg_ParseTuple(args, ":GetFillable"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001167 return NULL;
1168 if ((count = ALgetfillable(self-> port)) == -1)
1169 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001170 return PyInt_FromLong (count);
Guido van Rossume3db8621991-09-09 23:33:34 +00001171}
1172
Roger E. Massea2a8b271997-01-03 22:40:34 +00001173static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001174alp_readsamps(self, args)
1175 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001176 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001177{
1178 long count;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001179 PyObject *v;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001180 ALconfig c;
Guido van Rossume3db8621991-09-09 23:33:34 +00001181 int width;
Guido van Rossumd641d671997-04-03 17:06:32 +00001182 int ret;
Guido van Rossume3db8621991-09-09 23:33:34 +00001183
Guido van Rossum43713e52000-02-29 13:59:29 +00001184 if (!PyArg_ParseTuple(args, "l:readsamps", &count))
Guido van Rossumd641d671997-04-03 17:06:32 +00001185 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001186
Guido van Rossumd641d671997-04-03 17:06:32 +00001187 if (count <= 0) {
1188 PyErr_SetString(ErrorObject, "al.readsamps : arg <= 0");
Guido van Rossume3db8621991-09-09 23:33:34 +00001189 return NULL;
1190 }
1191
Guido van Rossumd641d671997-04-03 17:06:32 +00001192 c = ALgetconfig(self->port);
Jack Jansene8a3c281993-02-10 14:10:56 +00001193#ifdef AL_405
1194 width = ALgetsampfmt(c);
Guido van Rossumd641d671997-04-03 17:06:32 +00001195 if (width == AL_SAMPFMT_FLOAT)
1196 width = sizeof(float);
1197 else if (width == AL_SAMPFMT_DOUBLE)
1198 width = sizeof(double);
Jack Jansene8a3c281993-02-10 14:10:56 +00001199 else
Guido van Rossumd641d671997-04-03 17:06:32 +00001200 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001201#else
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001202 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001203#endif /* AL_405 */
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001204 ALfreeconfig(c);
Guido van Rossumd641d671997-04-03 17:06:32 +00001205 v = PyString_FromStringAndSize((char *)NULL, width * count);
1206 if (v == NULL)
1207 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001208
Roger E. Massea2a8b271997-01-03 22:40:34 +00001209 Py_BEGIN_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001210 ret = ALreadsamps(self->port, (void *) PyString_AsString(v), count);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001211 Py_END_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001212 if (ret == -1) {
1213 Py_DECREF(v);
1214 return NULL;
1215 }
Guido van Rossume3db8621991-09-09 23:33:34 +00001216
1217 return (v);
1218}
1219
Roger E. Massea2a8b271997-01-03 22:40:34 +00001220static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001221alp_writesamps(self, args)
1222 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001223 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001224{
Guido van Rossumfc58e581992-01-27 16:45:55 +00001225 char *buf;
1226 int size, width;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001227 ALconfig c;
Guido van Rossumd641d671997-04-03 17:06:32 +00001228 int ret;
Guido van Rossume3db8621991-09-09 23:33:34 +00001229
Guido van Rossum43713e52000-02-29 13:59:29 +00001230 if (!PyArg_ParseTuple(args, "s#:writesamps", &buf, &size))
Guido van Rossumd641d671997-04-03 17:06:32 +00001231 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001232
Guido van Rossumd641d671997-04-03 17:06:32 +00001233 c = ALgetconfig(self->port);
Jack Jansene8a3c281993-02-10 14:10:56 +00001234#ifdef AL_405
1235 width = ALgetsampfmt(c);
Guido van Rossumd641d671997-04-03 17:06:32 +00001236 if (width == AL_SAMPFMT_FLOAT)
1237 width = sizeof(float);
1238 else if (width == AL_SAMPFMT_DOUBLE)
1239 width = sizeof(double);
Jack Jansene8a3c281993-02-10 14:10:56 +00001240 else
Guido van Rossumd641d671997-04-03 17:06:32 +00001241 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001242#else
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001243 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001244#endif /* AL_405 */
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001245 ALfreeconfig(c);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001246 Py_BEGIN_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001247 ret = ALwritesamps (self->port, (void *) buf, (long) size / width);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001248 Py_END_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001249 if (ret == -1)
1250 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001251
Guido van Rossumd641d671997-04-03 17:06:32 +00001252 Py_INCREF(Py_None);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001253 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +00001254}
1255
Roger E. Massea2a8b271997-01-03 22:40:34 +00001256static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001257alp_getfillpoint(self, args)
1258 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001259 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001260{
1261 long count;
1262
Guido van Rossum43713e52000-02-29 13:59:29 +00001263 if (!PyArg_ParseTuple(args, ":GetFillPoint"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001264 return NULL;
1265 if ((count = ALgetfillpoint(self->port)) == -1)
1266 return NULL;
1267 return PyInt_FromLong(count);
Guido van Rossume3db8621991-09-09 23:33:34 +00001268}
1269
Roger E. Massea2a8b271997-01-03 22:40:34 +00001270static PyObject *
Guido van Rossum43713e52000-02-29 13:59:29 +00001271alp_setfillpoint(self, args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001272 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001273 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001274{
1275 long count;
1276
Guido van Rossum43713e52000-02-29 13:59:29 +00001277 if (!PyArg_ParseTuple(args, "l:SetFillPoint", &count))
Guido van Rossumd641d671997-04-03 17:06:32 +00001278 return NULL;
1279 if (ALsetfillpoint(self->port, count) == -1)
1280 return NULL;
1281 Py_INCREF(Py_None);
1282 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +00001283}
1284
Roger E. Massea2a8b271997-01-03 22:40:34 +00001285static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001286alp_setconfig(self, args)
1287 alpobject *self;
1288 PyObject *args;
1289{
1290 alcobject *config;
1291
Guido van Rossum43713e52000-02-29 13:59:29 +00001292 if (!PyArg_ParseTuple(args, "O!:SetConfig", &Alctype, &config))
Guido van Rossumd641d671997-04-03 17:06:32 +00001293 return NULL;
1294 if (ALsetconfig(self->port, config->config) == -1)
1295 return NULL;
1296 Py_INCREF(Py_None);
1297 return Py_None;
1298}
1299
1300static PyObject *
1301alp_getconfig(self, args)
1302 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001303 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001304{
1305 ALconfig config;
1306
Guido van Rossum43713e52000-02-29 13:59:29 +00001307 if (!PyArg_ParseTuple(args, ":GetConfig"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001308 return NULL;
1309 config = ALgetconfig(self->port);
1310 if (config == NULL)
1311 return NULL;
1312 return newalcobject(config);
Guido van Rossume3db8621991-09-09 23:33:34 +00001313}
1314
Jack Jansene8a3c281993-02-10 14:10:56 +00001315#ifdef AL_405
Roger E. Massea2a8b271997-01-03 22:40:34 +00001316static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001317alp_getstatus(self, args)
1318 alpobject *self;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001319 PyObject *args;
Jack Jansene8a3c281993-02-10 14:10:56 +00001320{
Roger E. Massea2a8b271997-01-03 22:40:34 +00001321 PyObject *list, *v;
Jack Jansene8a3c281993-02-10 14:10:56 +00001322 long *PVbuffer;
1323 long length;
1324 int i;
1325
Guido van Rossumd641d671997-04-03 17:06:32 +00001326 if (!PyArg_Parse(args, "O!", &PyList_Type, &list))
Jack Jansene8a3c281993-02-10 14:10:56 +00001327 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001328 length = PyList_Size(list);
1329 PVbuffer = PyMem_NEW(long, length);
Jack Jansene8a3c281993-02-10 14:10:56 +00001330 if (PVbuffer == NULL)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001331 return PyErr_NoMemory();
Jack Jansene8a3c281993-02-10 14:10:56 +00001332 for (i = 0; i < length; i++) {
Roger E. Massea2a8b271997-01-03 22:40:34 +00001333 v = PyList_GetItem(list, i);
1334 if (!PyInt_Check(v)) {
1335 PyMem_DEL(PVbuffer);
1336 PyErr_BadArgument();
Jack Jansene8a3c281993-02-10 14:10:56 +00001337 return NULL;
1338 }
Roger E. Massea2a8b271997-01-03 22:40:34 +00001339 PVbuffer[i] = PyInt_AsLong(v);
Jack Jansene8a3c281993-02-10 14:10:56 +00001340 }
1341
Guido van Rossumd641d671997-04-03 17:06:32 +00001342 if (ALgetstatus(self->port, PVbuffer, length) == -1)
1343 return NULL;
Jack Jansene8a3c281993-02-10 14:10:56 +00001344
1345 for (i = 0; i < length; i++)
Guido van Rossumd641d671997-04-03 17:06:32 +00001346 PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i]));
Jack Jansene8a3c281993-02-10 14:10:56 +00001347
Roger E. Massea2a8b271997-01-03 22:40:34 +00001348 PyMem_DEL(PVbuffer);
Jack Jansene8a3c281993-02-10 14:10:56 +00001349
Roger E. Massea2a8b271997-01-03 22:40:34 +00001350 Py_INCREF(Py_None);
1351 return Py_None;
Jack Jansene8a3c281993-02-10 14:10:56 +00001352}
1353#endif /* AL_405 */
1354
Guido van Rossumd641d671997-04-03 17:06:32 +00001355#endif /* OLD_INTERFACE */
1356
1357static struct PyMethodDef alp_methods[] = {
1358#ifdef AL_NO_ELEM /* IRIX 6 */
1359 {"SetConfig", (PyCFunction)alp_SetConfig, METH_VARARGS, alp_SetConfig__doc__},
1360 {"GetConfig", (PyCFunction)alp_GetConfig, METH_VARARGS, alp_GetConfig__doc__},
1361 {"GetResource", (PyCFunction)alp_GetResource, METH_VARARGS, alp_GetResource__doc__},
1362 {"GetFD", (PyCFunction)alp_GetFD, METH_VARARGS, alp_GetFD__doc__},
1363 {"GetFilled", (PyCFunction)alp_GetFilled, METH_VARARGS, alp_GetFilled__doc__},
1364 {"GetFillable", (PyCFunction)alp_GetFillable, METH_VARARGS, alp_GetFillable__doc__},
1365 {"ReadFrames", (PyCFunction)alp_ReadFrames, METH_VARARGS, alp_ReadFrames__doc__},
1366 {"DiscardFrames", (PyCFunction)alp_DiscardFrames, METH_VARARGS, alp_DiscardFrames__doc__},
1367 {"ZeroFrames", (PyCFunction)alp_ZeroFrames, METH_VARARGS, alp_ZeroFrames__doc__},
1368 {"SetFillPoint", (PyCFunction)alp_SetFillPoint, METH_VARARGS, alp_SetFillPoint__doc__},
1369 {"GetFillPoint", (PyCFunction)alp_GetFillPoint, METH_VARARGS, alp_GetFillPoint__doc__},
1370 {"GetFrameNumber", (PyCFunction)alp_GetFrameNumber, METH_VARARGS, alp_GetFrameNumber__doc__},
1371 {"GetFrameTime", (PyCFunction)alp_GetFrameTime, METH_VARARGS, alp_GetFrameTime__doc__},
1372 {"WriteFrames", (PyCFunction)alp_WriteFrames, METH_VARARGS, alp_WriteFrames__doc__},
1373 {"ClosePort", (PyCFunction)alp_ClosePort, METH_VARARGS, alp_ClosePort__doc__},
1374#endif /* AL_NO_ELEM */
1375#ifdef OLD_INTERFACE
1376 {"closeport", (PyCFunction)alp_closeport, METH_VARARGS},
1377 {"getfd", (PyCFunction)alp_getfd, METH_VARARGS},
1378 {"fileno", (PyCFunction)alp_getfd, METH_VARARGS},
1379 {"getfilled", (PyCFunction)alp_getfilled, METH_VARARGS},
1380 {"getfillable", (PyCFunction)alp_getfillable, METH_VARARGS},
1381 {"readsamps", (PyCFunction)alp_readsamps, METH_VARARGS},
1382 {"writesamps", (PyCFunction)alp_writesamps, METH_VARARGS},
1383 {"setfillpoint", (PyCFunction)alp_setfillpoint, METH_VARARGS},
1384 {"getfillpoint", (PyCFunction)alp_getfillpoint, METH_VARARGS},
1385 {"setconfig", (PyCFunction)alp_setconfig, METH_VARARGS},
1386 {"getconfig", (PyCFunction)alp_getconfig, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +00001387#ifdef AL_405
Guido van Rossumd641d671997-04-03 17:06:32 +00001388 {"getstatus", (PyCFunction)alp_getstatus, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +00001389#endif /* AL_405 */
Guido van Rossumd641d671997-04-03 17:06:32 +00001390#endif /* OLD_INTERFACE */
1391
1392 {NULL, NULL} /* sentinel */
Guido van Rossume3db8621991-09-09 23:33:34 +00001393};
1394
Guido van Rossumd641d671997-04-03 17:06:32 +00001395/* ---------- */
1396
1397
1398static PyObject *
1399newalpobject(ALport port)
1400{
1401 alpobject *self;
1402
Guido van Rossumb18618d2000-05-03 23:44:39 +00001403 self = PyObject_New(alpobject, &Alptype);
Guido van Rossumd641d671997-04-03 17:06:32 +00001404 if (self == NULL)
1405 return NULL;
1406 /* XXXX Add your own initializers here */
1407 self->port = port;
1408 return (PyObject *) self;
1409}
1410
1411
Guido van Rossume3db8621991-09-09 23:33:34 +00001412static void
Guido van Rossumd641d671997-04-03 17:06:32 +00001413alp_dealloc(self)
1414 alpobject *self;
Guido van Rossume3db8621991-09-09 23:33:34 +00001415{
Guido van Rossumd641d671997-04-03 17:06:32 +00001416 /* XXXX Add your own cleanup code here */
1417 if (self->port) {
1418#ifdef AL_NO_ELEM /* IRIX 6 */
1419 alClosePort(self->port);
1420#else
1421 ALcloseport(self->port);
1422#endif
1423 }
Guido van Rossumb18618d2000-05-03 23:44:39 +00001424 PyObject_Del(self);
Guido van Rossume3db8621991-09-09 23:33:34 +00001425}
1426
Roger E. Massea2a8b271997-01-03 22:40:34 +00001427static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001428alp_getattr(self, name)
1429 alpobject *self;
Guido van Rossume3db8621991-09-09 23:33:34 +00001430 char *name;
1431{
Guido van Rossumd641d671997-04-03 17:06:32 +00001432 /* XXXX Add your own getattr code here */
1433 if (self->port == NULL) {
1434 PyErr_SetString(ErrorObject, "port already closed");
1435 return NULL;
1436 }
1437 return Py_FindMethod(alp_methods, (PyObject *)self, name);
Guido van Rossume3db8621991-09-09 23:33:34 +00001438}
1439
Guido van Rossumd641d671997-04-03 17:06:32 +00001440static char Alptype__doc__[] =
1441""
1442;
1443
1444static PyTypeObject Alptype = {
Roger E. Massea2a8b271997-01-03 22:40:34 +00001445 PyObject_HEAD_INIT(&PyType_Type)
Guido van Rossumd641d671997-04-03 17:06:32 +00001446 0, /*ob_size*/
Guido van Rossume3db8621991-09-09 23:33:34 +00001447 "port", /*tp_name*/
Guido van Rossumd641d671997-04-03 17:06:32 +00001448 sizeof(alpobject), /*tp_basicsize*/
1449 0, /*tp_itemsize*/
Guido van Rossume3db8621991-09-09 23:33:34 +00001450 /* methods */
Guido van Rossumd641d671997-04-03 17:06:32 +00001451 (destructor)alp_dealloc, /*tp_dealloc*/
1452 (printfunc)0, /*tp_print*/
1453 (getattrfunc)alp_getattr, /*tp_getattr*/
1454 (setattrfunc)0, /*tp_setattr*/
1455 (cmpfunc)0, /*tp_compare*/
1456 (reprfunc)0, /*tp_repr*/
1457 0, /*tp_as_number*/
1458 0, /*tp_as_sequence*/
1459 0, /*tp_as_mapping*/
1460 (hashfunc)0, /*tp_hash*/
1461 (ternaryfunc)0, /*tp_call*/
1462 (reprfunc)0, /*tp_str*/
1463
1464 /* Space for future expansion */
1465 0L,0L,0L,0L,
1466 Alptype__doc__ /* Documentation string */
Guido van Rossume3db8621991-09-09 23:33:34 +00001467};
1468
Guido van Rossumd641d671997-04-03 17:06:32 +00001469/* End of code for port objects */
1470/* -------------------------------------------------------- */
1471
1472
1473#ifdef AL_NO_ELEM /* IRIX 6 */
1474
1475static char al_NewConfig__doc__[] =
1476"alNewConfig: create and initialize an audio ALconfig structure."
1477;
1478
Roger E. Massea2a8b271997-01-03 22:40:34 +00001479static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001480al_NewConfig(self, args)
1481 PyObject *self; /* Not used */
1482 PyObject *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001483{
Guido van Rossumd641d671997-04-03 17:06:32 +00001484 ALconfig config;
1485
Guido van Rossum43713e52000-02-29 13:59:29 +00001486 if (!PyArg_ParseTuple(args, ":NewConfig"))
Guido van Rossume3db8621991-09-09 23:33:34 +00001487 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001488 if ((config = alNewConfig()) == NULL)
1489 return NULL;
1490 return newalcobject(config);
Guido van Rossume3db8621991-09-09 23:33:34 +00001491}
1492
Guido van Rossumd641d671997-04-03 17:06:32 +00001493static char al_OpenPort__doc__[] =
1494"alOpenPort: open an audio port."
1495;
Guido van Rossume3db8621991-09-09 23:33:34 +00001496
Roger E. Massea2a8b271997-01-03 22:40:34 +00001497static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00001498al_OpenPort(self, args)
1499 PyObject *self; /* Not used */
1500 PyObject *args;
1501{
1502 ALport port;
1503 char *name, *dir;
1504 alcobject *config = NULL;
1505
Guido van Rossum43713e52000-02-29 13:59:29 +00001506 if (!PyArg_ParseTuple(args, "ss|O!:OpenPort", &name, &dir, &Alctype, &config))
Guido van Rossumd641d671997-04-03 17:06:32 +00001507 return NULL;
1508 if ((port = alOpenPort(name, dir, config ? config->config : NULL)) == NULL)
1509 return NULL;
1510 return newalpobject(port);
1511}
1512
1513static char al_Connect__doc__[] =
1514"alConnect: connect two audio I/O resources."
1515;
1516
1517static PyObject *
1518al_Connect(self, args)
1519 PyObject *self; /* Not used */
1520 PyObject *args;
1521{
1522 int source, dest, nprops = 0, id, i;
1523 ALpv *props = NULL;
1524 ALparamInfo *propinfo = NULL;
1525 PyObject *propobj = NULL;
1526
Guido van Rossum43713e52000-02-29 13:59:29 +00001527 if (!PyArg_ParseTuple(args, "ii|O!:Connect", &source, &dest, &PyList_Type, &propobj))
Guido van Rossumd641d671997-04-03 17:06:32 +00001528 return NULL;
1529 if (propobj != NULL) {
1530 nprops = python2params(source, dest, propobj, &props, &propinfo);
1531 if (nprops < 0)
1532 return NULL;
1533 }
1534
1535 id = alConnect(source, dest, props, nprops);
1536
1537 if (props) {
1538 for (i = 0; i < nprops; i++) {
1539 switch (propinfo[i].valueType) {
1540 case AL_SET_VAL:
1541 case AL_VECTOR_VAL:
1542 PyMem_DEL(props[i].value.ptr);
1543 break;
1544 }
1545 }
1546 PyMem_DEL(props);
1547 PyMem_DEL(propinfo);
1548 }
1549
1550 if (id < 0)
1551 return NULL;
1552 return PyInt_FromLong((long) id);
1553}
1554
1555static char al_Disconnect__doc__[] =
1556"alDisconnect: delete a connection between two audio I/O resources."
1557;
1558
1559static PyObject *
1560al_Disconnect(self, args)
1561 PyObject *self; /* Not used */
1562 PyObject *args;
1563{
1564 int res;
1565
Guido van Rossum43713e52000-02-29 13:59:29 +00001566 if (!PyArg_ParseTuple(args, "i:Disconnect", &res))
Guido van Rossumd641d671997-04-03 17:06:32 +00001567 return NULL;
1568 if (alDisconnect(res) < 0)
1569 return NULL;
1570 Py_INCREF(Py_None);
1571 return Py_None;
1572}
1573
1574static char al_GetParams__doc__[] =
1575"alGetParams: get the values of audio resource parameters."
1576;
1577
1578static PyObject *
1579al_GetParams(self, args)
1580 PyObject *self; /* Not used */
1581 PyObject *args;
1582{
1583 int resource;
1584 PyObject *pvslist, *item = NULL, *v = NULL;
1585 ALpv *pvs;
1586 int i, j, npvs;
1587 ALparamInfo *pinfo;
1588
Guido van Rossum43713e52000-02-29 13:59:29 +00001589 if (!PyArg_ParseTuple(args, "iO!:GetParams", &resource, &PyList_Type, &pvslist))
Guido van Rossumd641d671997-04-03 17:06:32 +00001590 return NULL;
1591 npvs = PyList_Size(pvslist);
1592 pvs = PyMem_NEW(ALpv, npvs);
1593 pinfo = PyMem_NEW(ALparamInfo, npvs);
1594 for (i = 0; i < npvs; i++) {
1595 item = PyList_GetItem(pvslist, i);
1596 if (!PyInt_Check(item)) {
1597 item = NULL;
1598 PyErr_SetString(ErrorObject, "list of integers expected");
1599 goto error;
1600 }
1601 pvs[i].param = (int) PyInt_AsLong(item);
1602 item = NULL; /* not needed anymore */
1603 if (alGetParamInfo(resource, pvs[i].param, &pinfo[i]) < 0)
1604 goto error;
1605 switch (pinfo[i].valueType) {
1606 case AL_NO_VAL:
1607 break;
1608 case AL_MATRIX_VAL:
1609 pinfo[i].maxElems *= pinfo[i].maxElems2;
1610 /* fall through */
1611 case AL_STRING_VAL:
1612 case AL_SET_VAL:
1613 case AL_VECTOR_VAL:
1614 switch (pinfo[i].elementType) {
1615 case AL_INT32_ELEM:
1616 case AL_RESOURCE_ELEM:
1617 case AL_ENUM_ELEM:
1618 pvs[i].value.ptr = PyMem_NEW(int, pinfo[i].maxElems);
1619 pvs[i].sizeIn = pinfo[i].maxElems;
1620 break;
1621 case AL_INT64_ELEM:
1622 case AL_FIXED_ELEM:
1623 pvs[i].value.ptr = PyMem_NEW(long long, pinfo[i].maxElems);
1624 pvs[i].sizeIn = pinfo[i].maxElems;
1625 break;
1626 case AL_CHAR_ELEM:
1627 pvs[i].value.ptr = PyMem_NEW(char, 32);
1628 pvs[i].sizeIn = 32;
1629 break;
1630 case AL_NO_ELEM:
1631 case AL_PTR_ELEM:
1632 default:
1633 PyErr_SetString(ErrorObject, "internal error");
1634 goto error;
1635 }
1636 break;
1637 case AL_SCALAR_VAL:
1638 break;
1639 default:
1640 PyErr_SetString(ErrorObject, "internal error");
1641 goto error;
1642 }
1643 if (pinfo[i].valueType == AL_MATRIX_VAL) {
1644 pinfo[i].maxElems /= pinfo[i].maxElems2;
1645 pvs[i].sizeIn /= pinfo[i].maxElems2;
1646 pvs[i].size2In = pinfo[i].maxElems2;
1647 }
1648 }
1649 if (alGetParams(resource, pvs, npvs) < 0)
1650 goto error;
1651 v = PyList_New(npvs);
1652 for (i = 0; i < npvs; i++) {
1653 if (pvs[i].sizeOut < 0) {
1654 char buf[32];
1655 sprintf(buf, "problem with param %d", i);
1656 PyErr_SetString(ErrorObject, buf);
1657 goto error;
1658 }
1659 switch (pinfo[i].valueType) {
1660 case AL_NO_VAL:
1661 item = Py_None;
1662 Py_INCREF(item);
1663 break;
1664 case AL_STRING_VAL:
1665 item = PyString_FromString(pvs[i].value.ptr);
1666 PyMem_DEL(pvs[i].value.ptr);
1667 break;
1668 case AL_MATRIX_VAL:
1669 /* XXXX this is not right */
1670 pvs[i].sizeOut *= pvs[i].size2Out;
1671 /* fall through */
1672 case AL_SET_VAL:
1673 case AL_VECTOR_VAL:
1674 item = PyList_New(pvs[i].sizeOut);
1675 for (j = 0; j < pvs[i].sizeOut; j++) {
1676 switch (pinfo[i].elementType) {
1677 case AL_INT32_ELEM:
1678 case AL_RESOURCE_ELEM:
1679 case AL_ENUM_ELEM:
1680 PyList_SetItem(item, j, PyInt_FromLong((long) ((int *) pvs[i].value.ptr)[j]));
1681 break;
1682 case AL_INT64_ELEM:
1683 PyList_SetItem(item, j, PyLong_FromLongLong(((long long *) pvs[i].value.ptr)[j]));
1684 break;
1685 case AL_FIXED_ELEM:
1686 PyList_SetItem(item, j, PyFloat_FromDouble(alFixedToDouble(((long long *) pvs[i].value.ptr)[j])));
1687 break;
1688 default:
1689 PyErr_SetString(ErrorObject, "internal error");
1690 goto error;
1691 }
1692 }
1693 PyMem_DEL(pvs[i].value.ptr);
1694 break;
1695 case AL_SCALAR_VAL:
1696 item = param2python(resource, pvs[i].param, pvs[i].value, &pinfo[i]);
1697 break;
1698 }
1699 if (PyErr_Occurred() ||
1700 PyList_SetItem(v, i, Py_BuildValue("(iO)", pvs[i].param,
1701 item)) < 0 ||
1702 PyErr_Occurred())
1703 goto error;
1704 Py_DECREF(item);
1705 }
1706 PyMem_DEL(pvs);
1707 PyMem_DEL(pinfo);
1708 return v;
1709
1710 error:
1711 Py_XDECREF(v);
1712 Py_XDECREF(item);
1713 if (pvs)
1714 PyMem_DEL(pvs);
1715 if (pinfo)
1716 PyMem_DEL(pinfo);
1717 return NULL;
1718}
1719
1720static char al_SetParams__doc__[] =
1721"alSetParams: set the values of audio resource parameters."
1722;
1723
1724static PyObject *
1725al_SetParams(self, args)
1726 PyObject *self; /* Not used */
1727 PyObject *args;
1728{
1729 int resource;
1730 PyObject *pvslist, *item;
1731 ALpv *pvs;
1732 ALparamInfo *pinfo;
1733 int npvs, i;
1734
Guido van Rossum43713e52000-02-29 13:59:29 +00001735 if (!PyArg_ParseTuple(args, "iO!:SetParams", &resource, &PyList_Type, &pvslist))
Guido van Rossumd641d671997-04-03 17:06:32 +00001736 return NULL;
1737 npvs = python2params(resource, -1, pvslist, &pvs, &pinfo);
1738 if (npvs < 0)
1739 return NULL;
1740
1741 if (alSetParams(resource, pvs, npvs) < 0)
1742 goto error;
1743
1744 /* cleanup */
1745 for (i = 0; i < npvs; i++) {
1746 switch (pinfo[i].valueType) {
1747 case AL_SET_VAL:
1748 case AL_VECTOR_VAL:
1749 PyMem_DEL(pvs[i].value.ptr);
1750 break;
1751 }
1752 }
1753 PyMem_DEL(pvs);
1754 PyMem_DEL(pinfo);
1755
1756 Py_INCREF(Py_None);
1757 return Py_None;
1758
1759 error:
1760 /* XXXX we should clean up everything */
1761 if (pvs)
1762 PyMem_DEL(pvs);
1763 if (pinfo)
1764 PyMem_DEL(pinfo);
1765 return NULL;
1766}
1767
1768static char al_QueryValues__doc__[] =
1769"alQueryValues: get the set of possible values for a parameter."
1770;
1771
1772static PyObject *
1773al_QueryValues(self, args)
1774 PyObject *self; /* Not used */
1775 PyObject *args;
1776{
1777 int resource, param;
1778 ALvalue *return_set = NULL;
1779 int setsize = 32, qualsize = 0, nvals, i;
1780 ALpv *quals = NULL;
1781 ALparamInfo pinfo;
1782 ALparamInfo *qualinfo = NULL;
1783 PyObject *qualobj = NULL;
1784 PyObject *res = NULL, *item;
1785
Guido van Rossum43713e52000-02-29 13:59:29 +00001786 if (!PyArg_ParseTuple(args, "ii|O!:QueryValues", &resource, &param,
Guido van Rossumd641d671997-04-03 17:06:32 +00001787 &PyList_Type, &qualobj))
1788 return NULL;
1789 if (qualobj != NULL) {
1790 qualsize = python2params(resource, param, qualobj, &quals, &qualinfo);
1791 if (qualsize < 0)
1792 return NULL;
1793 }
1794 setsize = 32;
1795 return_set = PyMem_NEW(ALvalue, setsize);
1796 if (return_set == NULL) {
1797 PyErr_NoMemory();
1798 goto cleanup;
1799 }
1800
1801 retry:
1802 nvals = alQueryValues(resource, param, return_set, setsize, quals, qualsize);
1803 if (nvals < 0)
1804 goto cleanup;
1805 if (nvals > setsize) {
1806 setsize = nvals;
1807 PyMem_RESIZE(return_set, ALvalue, setsize);
1808 if (return_set == NULL) {
1809 PyErr_NoMemory();
1810 goto cleanup;
1811 }
1812 goto retry;
1813 }
1814
1815 if (alGetParamInfo(resource, param, &pinfo) < 0)
1816 goto cleanup;
1817
1818 res = PyList_New(nvals);
1819 if (res == NULL)
1820 goto cleanup;
1821 for (i = 0; i < nvals; i++) {
1822 item = param2python(resource, param, return_set[i], &pinfo);
1823 if (item == NULL ||
1824 PyList_SetItem(res, i, item) < 0) {
1825 Py_DECREF(res);
1826 res = NULL;
1827 goto cleanup;
1828 }
1829 }
1830
1831 cleanup:
1832 if (return_set)
1833 PyMem_DEL(return_set);
1834 if (quals) {
1835 for (i = 0; i < qualsize; i++) {
1836 switch (qualinfo[i].valueType) {
1837 case AL_SET_VAL:
1838 case AL_VECTOR_VAL:
1839 PyMem_DEL(quals[i].value.ptr);
1840 break;
1841 }
1842 }
1843 PyMem_DEL(quals);
1844 PyMem_DEL(qualinfo);
1845 }
1846
1847 return res;
1848}
1849
1850static char al_GetParamInfo__doc__[] =
1851"alGetParamInfo: get information about a parameter on a particular audio resource."
1852;
1853
1854static PyObject *
1855al_GetParamInfo(self, args)
1856 PyObject *self; /* Not used */
1857 PyObject *args;
1858{
1859 int res, param;
1860 ALparamInfo pinfo;
1861 PyObject *v, *item;;
1862
Guido van Rossum43713e52000-02-29 13:59:29 +00001863 if (!PyArg_ParseTuple(args, "ii:GetParamInfo", &res, &param))
Guido van Rossumd641d671997-04-03 17:06:32 +00001864 return NULL;
1865 if (alGetParamInfo(res, param, &pinfo) < 0)
1866 return NULL;
1867 v = PyDict_New();
1868
1869 item = PyInt_FromLong((long) pinfo.resource);
1870 PyDict_SetItemString(v, "resource", item);
1871 Py_DECREF(item);
1872
1873 item = PyInt_FromLong((long) pinfo.param);
1874 PyDict_SetItemString(v, "param", item);
1875 Py_DECREF(item);
1876
1877 item = PyInt_FromLong((long) pinfo.valueType);
1878 PyDict_SetItemString(v, "valueType", item);
1879 Py_DECREF(item);
1880
1881 if (pinfo.valueType != AL_NO_VAL && pinfo.valueType != AL_SCALAR_VAL) {
1882 /* multiple values */
1883 item = PyInt_FromLong((long) pinfo.maxElems);
1884 PyDict_SetItemString(v, "maxElems", item);
1885 Py_DECREF(item);
1886
1887 if (pinfo.valueType == AL_MATRIX_VAL) {
1888 /* 2 dimensional */
1889 item = PyInt_FromLong((long) pinfo.maxElems2);
1890 PyDict_SetItemString(v, "maxElems2", item);
1891 Py_DECREF(item);
1892 }
1893 }
1894
1895 item = PyInt_FromLong((long) pinfo.elementType);
1896 PyDict_SetItemString(v, "elementType", item);
1897 Py_DECREF(item);
1898
1899 item = PyString_FromString(pinfo.name);
1900 PyDict_SetItemString(v, "name", item);
1901 Py_DECREF(item);
1902
1903 item = param2python(res, param, pinfo.initial, &pinfo);
1904 PyDict_SetItemString(v, "initial", item);
1905 Py_DECREF(item);
1906
1907 if (pinfo.elementType != AL_ENUM_ELEM &&
1908 pinfo.elementType != AL_RESOURCE_ELEM &&
1909 pinfo.elementType != AL_CHAR_ELEM) {
1910 /* range param */
1911 item = param2python(res, param, pinfo.min, &pinfo);
1912 PyDict_SetItemString(v, "min", item);
1913 Py_DECREF(item);
1914
1915 item = param2python(res, param, pinfo.max, &pinfo);
1916 PyDict_SetItemString(v, "max", item);
1917 Py_DECREF(item);
1918
1919 item = param2python(res, param, pinfo.minDelta, &pinfo);
1920 PyDict_SetItemString(v, "minDelta", item);
1921 Py_DECREF(item);
1922
1923 item = param2python(res, param, pinfo.maxDelta, &pinfo);
1924 PyDict_SetItemString(v, "maxDelta", item);
1925 Py_DECREF(item);
1926
1927 item = PyInt_FromLong((long) pinfo.specialVals);
1928 PyDict_SetItemString(v, "specialVals", item);
1929 Py_DECREF(item);
1930 }
1931
1932 return v;
1933}
1934
1935static char al_GetResourceByName__doc__[] =
1936"alGetResourceByName: find an audio resource by name."
1937;
1938
1939static PyObject *
1940al_GetResourceByName(self, args)
1941 PyObject *self; /* Not used */
1942 PyObject *args;
1943{
1944 int res, start_res, type;
1945 char *name;
1946
Guido van Rossum43713e52000-02-29 13:59:29 +00001947 if (!PyArg_ParseTuple(args, "isi:GetResourceByName", &start_res, &name, &type))
Guido van Rossumd641d671997-04-03 17:06:32 +00001948 return NULL;
1949 if ((res = alGetResourceByName(start_res, name, type)) == 0)
1950 return NULL;
1951 return PyInt_FromLong((long) res);
1952}
1953
1954static char al_IsSubtype__doc__[] =
1955"alIsSubtype: indicate if one resource type is a subtype of another."
1956;
1957
1958static PyObject *
1959al_IsSubtype(self, args)
1960 PyObject *self; /* Not used */
1961 PyObject *args;
1962{
1963 int type, subtype;
1964
Guido van Rossum43713e52000-02-29 13:59:29 +00001965 if (!PyArg_ParseTuple(args, "ii:IsSubtype", &type, &subtype))
Guido van Rossumd641d671997-04-03 17:06:32 +00001966 return NULL;
1967 return PyInt_FromLong((long) alIsSubtype(type, subtype));
1968}
1969
1970static char al_SetErrorHandler__doc__[] =
1971""
1972;
1973
1974static PyObject *
1975al_SetErrorHandler(self, args)
1976 PyObject *self; /* Not used */
1977 PyObject *args;
1978{
1979
Guido van Rossum43713e52000-02-29 13:59:29 +00001980 if (!PyArg_ParseTuple(args, ":SetErrorHandler"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001981 return NULL;
1982 Py_INCREF(Py_None);
1983 return Py_None;
1984}
1985
1986#endif /* AL_NO_ELEM */
1987
1988#ifdef OLD_INTERFACE
1989
1990static PyObject *
1991al_openport(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001992 PyObject *self, *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00001993{
Guido van Rossumfc58e581992-01-27 16:45:55 +00001994 char *name, *dir;
Guido van Rossume3db8621991-09-09 23:33:34 +00001995 ALport port;
Guido van Rossumd641d671997-04-03 17:06:32 +00001996 alcobject *config = NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001997
Guido van Rossum43713e52000-02-29 13:59:29 +00001998 if (!PyArg_ParseTuple(args, "ss|O!:OpenPort", &name, &dir, &Alctype, &config))
Guido van Rossumc0aab891991-10-20 20:10:46 +00001999 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00002000 if ((port = ALopenport(name, dir, config ? config->config : NULL)) == NULL)
Guido van Rossume3db8621991-09-09 23:33:34 +00002001 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00002002 return newalpobject(port);
Guido van Rossume3db8621991-09-09 23:33:34 +00002003}
2004
Roger E. Massea2a8b271997-01-03 22:40:34 +00002005static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +00002006al_newconfig(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002007 PyObject *self, *args;
Guido van Rossume3db8621991-09-09 23:33:34 +00002008{
2009 ALconfig config;
2010
Guido van Rossum43713e52000-02-29 13:59:29 +00002011 if (!PyArg_ParseTuple(args, ":NewConfig"))
Guido van Rossumc0aab891991-10-20 20:10:46 +00002012 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00002013 if ((config = ALnewconfig ()) == NULL)
2014 return NULL;
2015 return newalcobject(config);
Guido van Rossume3db8621991-09-09 23:33:34 +00002016}
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002017
Roger E. Massea2a8b271997-01-03 22:40:34 +00002018static PyObject *
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002019al_queryparams(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002020 PyObject *self, *args;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002021{
2022 long device;
2023 long length;
2024 long *PVbuffer;
2025 long PVdummy[2];
Guido van Rossumd641d671997-04-03 17:06:32 +00002026 PyObject *v = NULL;
2027 int i;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002028
Guido van Rossum43713e52000-02-29 13:59:29 +00002029 if (!PyArg_ParseTuple(args, "l:queryparams", &device))
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002030 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00002031 if ((length = ALqueryparams(device, PVdummy, 2L)) == -1)
2032 return NULL;
2033 if ((PVbuffer = PyMem_NEW(long, length)) == NULL)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002034 return PyErr_NoMemory();
Guido van Rossumd641d671997-04-03 17:06:32 +00002035 if (ALqueryparams(device, PVbuffer, length) >= 0 &&
2036 (v = PyList_New((int)length)) != NULL) {
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002037 for (i = 0; i < length; i++)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002038 PyList_SetItem(v, i, PyInt_FromLong(PVbuffer[i]));
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002039 }
Roger E. Massea2a8b271997-01-03 22:40:34 +00002040 PyMem_DEL(PVbuffer);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002041 return v;
2042}
2043
Roger E. Massea2a8b271997-01-03 22:40:34 +00002044static PyObject *
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002045doParams(args, func, modified)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002046 PyObject *args;
Guido van Rossumd641d671997-04-03 17:06:32 +00002047 int (*func)(long, long *, long);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002048 int modified;
2049{
2050 long device;
Roger E. Massea2a8b271997-01-03 22:40:34 +00002051 PyObject *list, *v;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002052 long *PVbuffer;
2053 long length;
2054 int i;
Guido van Rossume3db8621991-09-09 23:33:34 +00002055
Guido van Rossumd641d671997-04-03 17:06:32 +00002056 if (!PyArg_ParseTuple(args, "lO!", &device, &PyList_Type, &list))
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002057 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00002058 length = PyList_Size(list);
2059 PVbuffer = PyMem_NEW(long, length);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002060 if (PVbuffer == NULL)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002061 return PyErr_NoMemory();
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002062 for (i = 0; i < length; i++) {
Roger E. Massea2a8b271997-01-03 22:40:34 +00002063 v = PyList_GetItem(list, i);
2064 if (!PyInt_Check(v)) {
2065 PyMem_DEL(PVbuffer);
2066 PyErr_BadArgument();
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002067 return NULL;
2068 }
Roger E. Massea2a8b271997-01-03 22:40:34 +00002069 PVbuffer[i] = PyInt_AsLong(v);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002070 }
2071
Guido van Rossumd641d671997-04-03 17:06:32 +00002072 if ((*func)(device, PVbuffer, length) == -1) {
2073 PyMem_DEL(PVbuffer);
2074 return NULL;
2075 }
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002076
2077 if (modified) {
2078 for (i = 0; i < length; i++)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002079 PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i]));
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002080 }
2081
Roger E. Massea2a8b271997-01-03 22:40:34 +00002082 PyMem_DEL(PVbuffer);
Guido van Rossumc0aab891991-10-20 20:10:46 +00002083
Roger E. Massea2a8b271997-01-03 22:40:34 +00002084 Py_INCREF(Py_None);
2085 return Py_None;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002086}
2087
Roger E. Massea2a8b271997-01-03 22:40:34 +00002088static PyObject *
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002089al_getparams(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002090 PyObject *self, *args;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002091{
2092 return doParams(args, ALgetparams, 1);
2093}
2094
Roger E. Massea2a8b271997-01-03 22:40:34 +00002095static PyObject *
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002096al_setparams(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002097 PyObject *self, *args;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00002098{
2099 return doParams(args, ALsetparams, 0);
2100}
2101
Roger E. Massea2a8b271997-01-03 22:40:34 +00002102static PyObject *
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002103al_getname(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002104 PyObject *self, *args;
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002105{
2106 long device, descriptor;
2107 char *name;
Guido van Rossumd641d671997-04-03 17:06:32 +00002108
Guido van Rossum43713e52000-02-29 13:59:29 +00002109 if (!PyArg_ParseTuple(args, "ll:getname", &device, &descriptor))
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002110 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00002111 if ((name = ALgetname(device, descriptor)) == NULL)
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002112 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00002113 return PyString_FromString(name);
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002114}
2115
Roger E. Massea2a8b271997-01-03 22:40:34 +00002116static PyObject *
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002117al_getdefault(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002118 PyObject *self, *args;
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002119{
2120 long device, descriptor, value;
Guido van Rossumd641d671997-04-03 17:06:32 +00002121
Guido van Rossum43713e52000-02-29 13:59:29 +00002122 if (!PyArg_ParseTuple(args, "ll:getdefault", &device, &descriptor))
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002123 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00002124 if ((value = ALgetdefault(device, descriptor)) == -1)
2125 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00002126 return PyLong_FromLong(value);
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002127}
2128
Roger E. Massea2a8b271997-01-03 22:40:34 +00002129static PyObject *
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002130al_getminmax(self, args)
Roger E. Massea2a8b271997-01-03 22:40:34 +00002131 PyObject *self, *args;
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002132{
2133 long device, descriptor, min, max;
Guido van Rossumd641d671997-04-03 17:06:32 +00002134
Guido van Rossum43713e52000-02-29 13:59:29 +00002135 if (!PyArg_ParseTuple(args, "ll:getminmax", &device, &descriptor))
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002136 return NULL;
2137 min = -1;
2138 max = -1;
Guido van Rossumd641d671997-04-03 17:06:32 +00002139 if (ALgetminmax(device, descriptor, &min, &max) == -1)
2140 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00002141 return Py_BuildValue("ll", min, max);
Guido van Rossum448f4bf1992-08-19 16:41:15 +00002142}
2143
Guido van Rossumd641d671997-04-03 17:06:32 +00002144#endif /* OLD_INTERFACE */
2145
2146/* List of methods defined in the module */
2147
2148static struct PyMethodDef al_methods[] = {
2149#ifdef AL_NO_ELEM /* IRIX 6 */
2150 {"NewConfig", (PyCFunction)al_NewConfig, METH_VARARGS, al_NewConfig__doc__},
2151 {"OpenPort", (PyCFunction)al_OpenPort, METH_VARARGS, al_OpenPort__doc__},
2152 {"Connect", (PyCFunction)al_Connect, METH_VARARGS, al_Connect__doc__},
2153 {"Disconnect", (PyCFunction)al_Disconnect, METH_VARARGS, al_Disconnect__doc__},
2154 {"GetParams", (PyCFunction)al_GetParams, METH_VARARGS, al_GetParams__doc__},
2155 {"SetParams", (PyCFunction)al_SetParams, METH_VARARGS, al_SetParams__doc__},
2156 {"QueryValues", (PyCFunction)al_QueryValues, METH_VARARGS, al_QueryValues__doc__},
2157 {"GetParamInfo", (PyCFunction)al_GetParamInfo, METH_VARARGS, al_GetParamInfo__doc__},
2158 {"GetResourceByName", (PyCFunction)al_GetResourceByName, METH_VARARGS, al_GetResourceByName__doc__},
2159 {"IsSubtype", (PyCFunction)al_IsSubtype, METH_VARARGS, al_IsSubtype__doc__},
2160#if 0
2161 /* this one not supported */
2162 {"SetErrorHandler", (PyCFunction)al_SetErrorHandler, METH_VARARGS, al_SetErrorHandler__doc__},
2163#endif
2164#endif /* AL_NO_ELEM */
2165#ifdef OLD_INTERFACE
2166 {"openport", (PyCFunction)al_openport, METH_VARARGS},
2167 {"newconfig", (PyCFunction)al_newconfig, METH_VARARGS},
2168 {"queryparams", (PyCFunction)al_queryparams, METH_VARARGS},
2169 {"getparams", (PyCFunction)al_getparams, METH_VARARGS},
2170 {"setparams", (PyCFunction)al_setparams, METH_VARARGS},
2171 {"getname", (PyCFunction)al_getname, METH_VARARGS},
2172 {"getdefault", (PyCFunction)al_getdefault, METH_VARARGS},
2173 {"getminmax", (PyCFunction)al_getminmax, METH_VARARGS},
2174#endif /* OLD_INTERFACE */
2175
2176 {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
Guido van Rossume3db8621991-09-09 23:33:34 +00002177};
2178
Guido van Rossumd641d671997-04-03 17:06:32 +00002179
2180/* Initialization function for the module (*must* be called inital) */
2181
2182static char al_module_documentation[] =
2183""
2184;
2185
Guido van Rossume3db8621991-09-09 23:33:34 +00002186void
2187inital()
2188{
Guido van Rossumd641d671997-04-03 17:06:32 +00002189 PyObject *m, *d, *x;
Guido van Rossume3db8621991-09-09 23:33:34 +00002190
Guido van Rossumd641d671997-04-03 17:06:32 +00002191 /* Create the module and add the functions */
2192 m = Py_InitModule4("al", al_methods,
2193 al_module_documentation,
2194 (PyObject*)NULL,PYTHON_API_VERSION);
2195
2196 /* Add some symbolic constants to the module */
2197 d = PyModule_GetDict(m);
Fred Drake589c35b2000-07-06 19:38:49 +00002198 ErrorObject = PyErr_NewException("al.error", NULL, NULL);
Guido van Rossumd641d671997-04-03 17:06:32 +00002199 PyDict_SetItemString(d, "error", ErrorObject);
2200
2201 /* XXXX Add constants here */
2202#ifdef AL_4CHANNEL
2203 x = PyInt_FromLong((long) AL_4CHANNEL);
2204 if (x == NULL || PyDict_SetItemString(d, "FOURCHANNEL", x) < 0)
2205 goto error;
2206 Py_DECREF(x);
2207#endif
2208#ifdef AL_ADAT_IF_TYPE
2209 x = PyInt_FromLong((long) AL_ADAT_IF_TYPE);
2210 if (x == NULL || PyDict_SetItemString(d, "ADAT_IF_TYPE", x) < 0)
2211 goto error;
2212 Py_DECREF(x);
2213#endif
2214#ifdef AL_ADAT_MCLK_TYPE
2215 x = PyInt_FromLong((long) AL_ADAT_MCLK_TYPE);
2216 if (x == NULL || PyDict_SetItemString(d, "ADAT_MCLK_TYPE", x) < 0)
2217 goto error;
2218 Py_DECREF(x);
2219#endif
2220#ifdef AL_AES_IF_TYPE
2221 x = PyInt_FromLong((long) AL_AES_IF_TYPE);
2222 if (x == NULL || PyDict_SetItemString(d, "AES_IF_TYPE", x) < 0)
2223 goto error;
2224 Py_DECREF(x);
2225#endif
2226#ifdef AL_AES_MCLK_TYPE
2227 x = PyInt_FromLong((long) AL_AES_MCLK_TYPE);
2228 if (x == NULL || PyDict_SetItemString(d, "AES_MCLK_TYPE", x) < 0)
2229 goto error;
2230 Py_DECREF(x);
2231#endif
2232#ifdef AL_ANALOG_IF_TYPE
2233 x = PyInt_FromLong((long) AL_ANALOG_IF_TYPE);
2234 if (x == NULL || PyDict_SetItemString(d, "ANALOG_IF_TYPE", x) < 0)
2235 goto error;
2236 Py_DECREF(x);
2237#endif
2238#ifdef AL_ASSOCIATE
2239 x = PyInt_FromLong((long) AL_ASSOCIATE);
2240 if (x == NULL || PyDict_SetItemString(d, "ASSOCIATE", x) < 0)
2241 goto error;
2242 Py_DECREF(x);
2243#endif
2244#ifdef AL_BAD_BUFFER_NULL
2245 x = PyInt_FromLong((long) AL_BAD_BUFFER_NULL);
2246 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFER_NULL", x) < 0)
2247 goto error;
2248 Py_DECREF(x);
2249#endif
2250#ifdef AL_BAD_BUFFERLENGTH
2251 x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH);
2252 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH", x) < 0)
2253 goto error;
2254 Py_DECREF(x);
2255#endif
2256#ifdef AL_BAD_BUFFERLENGTH_NEG
2257 x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH_NEG);
2258 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_NEG", x) < 0)
2259 goto error;
2260 Py_DECREF(x);
2261#endif
2262#ifdef AL_BAD_BUFFERLENGTH_ODD
2263 x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH_ODD);
2264 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_ODD", x) < 0)
2265 goto error;
2266 Py_DECREF(x);
2267#endif
2268#ifdef AL_BAD_CHANNELS
2269 x = PyInt_FromLong((long) AL_BAD_CHANNELS);
2270 if (x == NULL || PyDict_SetItemString(d, "BAD_CHANNELS", x) < 0)
2271 goto error;
2272 Py_DECREF(x);
2273#endif
2274#ifdef AL_BAD_CONFIG
2275 x = PyInt_FromLong((long) AL_BAD_CONFIG);
2276 if (x == NULL || PyDict_SetItemString(d, "BAD_CONFIG", x) < 0)
2277 goto error;
2278 Py_DECREF(x);
2279#endif
2280#ifdef AL_BAD_COUNT_NEG
2281 x = PyInt_FromLong((long) AL_BAD_COUNT_NEG);
2282 if (x == NULL || PyDict_SetItemString(d, "BAD_COUNT_NEG", x) < 0)
2283 goto error;
2284 Py_DECREF(x);
2285#endif
2286#ifdef AL_BAD_DEVICE
2287 x = PyInt_FromLong((long) AL_BAD_DEVICE);
2288 if (x == NULL || PyDict_SetItemString(d, "BAD_DEVICE", x) < 0)
2289 goto error;
2290 Py_DECREF(x);
2291#endif
2292#ifdef AL_BAD_DEVICE_ACCESS
2293 x = PyInt_FromLong((long) AL_BAD_DEVICE_ACCESS);
2294 if (x == NULL || PyDict_SetItemString(d, "BAD_DEVICE_ACCESS", x) < 0)
2295 goto error;
2296 Py_DECREF(x);
2297#endif
2298#ifdef AL_BAD_DIRECTION
2299 x = PyInt_FromLong((long) AL_BAD_DIRECTION);
2300 if (x == NULL || PyDict_SetItemString(d, "BAD_DIRECTION", x) < 0)
2301 goto error;
2302 Py_DECREF(x);
2303#endif
2304#ifdef AL_BAD_FILLPOINT
2305 x = PyInt_FromLong((long) AL_BAD_FILLPOINT);
2306 if (x == NULL || PyDict_SetItemString(d, "BAD_FILLPOINT", x) < 0)
2307 goto error;
2308 Py_DECREF(x);
2309#endif
2310#ifdef AL_BAD_FLOATMAX
2311 x = PyInt_FromLong((long) AL_BAD_FLOATMAX);
2312 if (x == NULL || PyDict_SetItemString(d, "BAD_FLOATMAX", x) < 0)
2313 goto error;
2314 Py_DECREF(x);
2315#endif
2316#ifdef AL_BAD_ILLEGAL_STATE
2317 x = PyInt_FromLong((long) AL_BAD_ILLEGAL_STATE);
2318 if (x == NULL || PyDict_SetItemString(d, "BAD_ILLEGAL_STATE", x) < 0)
2319 goto error;
2320 Py_DECREF(x);
2321#endif
2322#ifdef AL_BAD_NO_PORTS
2323 x = PyInt_FromLong((long) AL_BAD_NO_PORTS);
2324 if (x == NULL || PyDict_SetItemString(d, "BAD_NO_PORTS", x) < 0)
2325 goto error;
2326 Py_DECREF(x);
2327#endif
2328#ifdef AL_BAD_NOT_FOUND
2329 x = PyInt_FromLong((long) AL_BAD_NOT_FOUND);
2330 if (x == NULL || PyDict_SetItemString(d, "BAD_NOT_FOUND", x) < 0)
2331 goto error;
2332 Py_DECREF(x);
2333#endif
2334#ifdef AL_BAD_NOT_IMPLEMENTED
2335 x = PyInt_FromLong((long) AL_BAD_NOT_IMPLEMENTED);
2336 if (x == NULL || PyDict_SetItemString(d, "BAD_NOT_IMPLEMENTED", x) < 0)
2337 goto error;
2338 Py_DECREF(x);
2339#endif
2340#ifdef AL_BAD_OUT_OF_MEM
2341 x = PyInt_FromLong((long) AL_BAD_OUT_OF_MEM);
2342 if (x == NULL || PyDict_SetItemString(d, "BAD_OUT_OF_MEM", x) < 0)
2343 goto error;
2344 Py_DECREF(x);
2345#endif
2346#ifdef AL_BAD_PARAM
2347 x = PyInt_FromLong((long) AL_BAD_PARAM);
2348 if (x == NULL || PyDict_SetItemString(d, "BAD_PARAM", x) < 0)
2349 goto error;
2350 Py_DECREF(x);
2351#endif
2352#ifdef AL_BAD_PERMISSIONS
2353 x = PyInt_FromLong((long) AL_BAD_PERMISSIONS);
2354 if (x == NULL || PyDict_SetItemString(d, "BAD_PERMISSIONS", x) < 0)
2355 goto error;
2356 Py_DECREF(x);
2357#endif
2358#ifdef AL_BAD_PORT
2359 x = PyInt_FromLong((long) AL_BAD_PORT);
2360 if (x == NULL || PyDict_SetItemString(d, "BAD_PORT", x) < 0)
2361 goto error;
2362 Py_DECREF(x);
2363#endif
2364#ifdef AL_BAD_PORTSTYLE
2365 x = PyInt_FromLong((long) AL_BAD_PORTSTYLE);
2366 if (x == NULL || PyDict_SetItemString(d, "BAD_PORTSTYLE", x) < 0)
2367 goto error;
2368 Py_DECREF(x);
2369#endif
2370#ifdef AL_BAD_PVBUFFER
2371 x = PyInt_FromLong((long) AL_BAD_PVBUFFER);
2372 if (x == NULL || PyDict_SetItemString(d, "BAD_PVBUFFER", x) < 0)
2373 goto error;
2374 Py_DECREF(x);
2375#endif
2376#ifdef AL_BAD_QSIZE
2377 x = PyInt_FromLong((long) AL_BAD_QSIZE);
2378 if (x == NULL || PyDict_SetItemString(d, "BAD_QSIZE", x) < 0)
2379 goto error;
2380 Py_DECREF(x);
2381#endif
2382#ifdef AL_BAD_RATE
2383 x = PyInt_FromLong((long) AL_BAD_RATE);
2384 if (x == NULL || PyDict_SetItemString(d, "BAD_RATE", x) < 0)
2385 goto error;
2386 Py_DECREF(x);
2387#endif
2388#ifdef AL_BAD_RESOURCE
2389 x = PyInt_FromLong((long) AL_BAD_RESOURCE);
2390 if (x == NULL || PyDict_SetItemString(d, "BAD_RESOURCE", x) < 0)
2391 goto error;
2392 Py_DECREF(x);
2393#endif
2394#ifdef AL_BAD_SAMPFMT
2395 x = PyInt_FromLong((long) AL_BAD_SAMPFMT);
2396 if (x == NULL || PyDict_SetItemString(d, "BAD_SAMPFMT", x) < 0)
2397 goto error;
2398 Py_DECREF(x);
2399#endif
2400#ifdef AL_BAD_TRANSFER_SIZE
2401 x = PyInt_FromLong((long) AL_BAD_TRANSFER_SIZE);
2402 if (x == NULL || PyDict_SetItemString(d, "BAD_TRANSFER_SIZE", x) < 0)
2403 goto error;
2404 Py_DECREF(x);
2405#endif
2406#ifdef AL_BAD_WIDTH
2407 x = PyInt_FromLong((long) AL_BAD_WIDTH);
2408 if (x == NULL || PyDict_SetItemString(d, "BAD_WIDTH", x) < 0)
2409 goto error;
2410 Py_DECREF(x);
2411#endif
2412#ifdef AL_CHANNEL_MODE
2413 x = PyInt_FromLong((long) AL_CHANNEL_MODE);
2414 if (x == NULL || PyDict_SetItemString(d, "CHANNEL_MODE", x) < 0)
2415 goto error;
2416 Py_DECREF(x);
2417#endif
2418#ifdef AL_CHANNELS
2419 x = PyInt_FromLong((long) AL_CHANNELS);
2420 if (x == NULL || PyDict_SetItemString(d, "CHANNELS", x) < 0)
2421 goto error;
2422 Py_DECREF(x);
2423#endif
2424#ifdef AL_CHAR_ELEM
2425 x = PyInt_FromLong((long) AL_CHAR_ELEM);
2426 if (x == NULL || PyDict_SetItemString(d, "CHAR_ELEM", x) < 0)
2427 goto error;
2428 Py_DECREF(x);
2429#endif
2430#ifdef AL_CLOCK_GEN
2431 x = PyInt_FromLong((long) AL_CLOCK_GEN);
2432 if (x == NULL || PyDict_SetItemString(d, "CLOCK_GEN", x) < 0)
2433 goto error;
2434 Py_DECREF(x);
2435#endif
2436#ifdef AL_CLOCKGEN_TYPE
2437 x = PyInt_FromLong((long) AL_CLOCKGEN_TYPE);
2438 if (x == NULL || PyDict_SetItemString(d, "CLOCKGEN_TYPE", x) < 0)
2439 goto error;
2440 Py_DECREF(x);
2441#endif
2442#ifdef AL_CONNECT
2443 x = PyInt_FromLong((long) AL_CONNECT);
2444 if (x == NULL || PyDict_SetItemString(d, "CONNECT", x) < 0)
2445 goto error;
2446 Py_DECREF(x);
2447#endif
2448#ifdef AL_CONNECTION_TYPE
2449 x = PyInt_FromLong((long) AL_CONNECTION_TYPE);
2450 if (x == NULL || PyDict_SetItemString(d, "CONNECTION_TYPE", x) < 0)
2451 goto error;
2452 Py_DECREF(x);
2453#endif
2454#ifdef AL_CONNECTIONS
2455 x = PyInt_FromLong((long) AL_CONNECTIONS);
2456 if (x == NULL || PyDict_SetItemString(d, "CONNECTIONS", x) < 0)
2457 goto error;
2458 Py_DECREF(x);
2459#endif
2460#ifdef AL_CRYSTAL_MCLK_TYPE
2461 x = PyInt_FromLong((long) AL_CRYSTAL_MCLK_TYPE);
2462 if (x == NULL || PyDict_SetItemString(d, "CRYSTAL_MCLK_TYPE", x) < 0)
2463 goto error;
2464 Py_DECREF(x);
2465#endif
2466#ifdef AL_DEFAULT_DEVICE
2467 x = PyInt_FromLong((long) AL_DEFAULT_DEVICE);
2468 if (x == NULL || PyDict_SetItemString(d, "DEFAULT_DEVICE", x) < 0)
2469 goto error;
2470 Py_DECREF(x);
2471#endif
2472#ifdef AL_DEFAULT_INPUT
2473 x = PyInt_FromLong((long) AL_DEFAULT_INPUT);
2474 if (x == NULL || PyDict_SetItemString(d, "DEFAULT_INPUT", x) < 0)
2475 goto error;
2476 Py_DECREF(x);
2477#endif
2478#ifdef AL_DEFAULT_OUTPUT
2479 x = PyInt_FromLong((long) AL_DEFAULT_OUTPUT);
2480 if (x == NULL || PyDict_SetItemString(d, "DEFAULT_OUTPUT", x) < 0)
2481 goto error;
2482 Py_DECREF(x);
2483#endif
2484#ifdef AL_DEST
2485 x = PyInt_FromLong((long) AL_DEST);
2486 if (x == NULL || PyDict_SetItemString(d, "DEST", x) < 0)
2487 goto error;
2488 Py_DECREF(x);
2489#endif
2490#ifdef AL_DEVICE_TYPE
2491 x = PyInt_FromLong((long) AL_DEVICE_TYPE);
2492 if (x == NULL || PyDict_SetItemString(d, "DEVICE_TYPE", x) < 0)
2493 goto error;
2494 Py_DECREF(x);
2495#endif
2496#ifdef AL_DEVICES
2497 x = PyInt_FromLong((long) AL_DEVICES);
2498 if (x == NULL || PyDict_SetItemString(d, "DEVICES", x) < 0)
2499 goto error;
2500 Py_DECREF(x);
2501#endif
2502#ifdef AL_DIGITAL_IF_TYPE
2503 x = PyInt_FromLong((long) AL_DIGITAL_IF_TYPE);
2504 if (x == NULL || PyDict_SetItemString(d, "DIGITAL_IF_TYPE", x) < 0)
2505 goto error;
2506 Py_DECREF(x);
2507#endif
2508#ifdef AL_DIGITAL_INPUT_RATE
2509 x = PyInt_FromLong((long) AL_DIGITAL_INPUT_RATE);
2510 if (x == NULL || PyDict_SetItemString(d, "DIGITAL_INPUT_RATE", x) < 0)
2511 goto error;
2512 Py_DECREF(x);
2513#endif
2514#ifdef AL_DISCONNECT
2515 x = PyInt_FromLong((long) AL_DISCONNECT);
2516 if (x == NULL || PyDict_SetItemString(d, "DISCONNECT", x) < 0)
2517 goto error;
2518 Py_DECREF(x);
2519#endif
2520#ifdef AL_ENUM_ELEM
2521 x = PyInt_FromLong((long) AL_ENUM_ELEM);
2522 if (x == NULL || PyDict_SetItemString(d, "ENUM_ELEM", x) < 0)
2523 goto error;
2524 Py_DECREF(x);
2525#endif
2526#ifdef AL_ENUM_VALUE
2527 x = PyInt_FromLong((long) AL_ENUM_VALUE);
2528 if (x == NULL || PyDict_SetItemString(d, "ENUM_VALUE", x) < 0)
2529 goto error;
2530 Py_DECREF(x);
2531#endif
2532#ifdef AL_ERROR_INPUT_OVERFLOW
2533 x = PyInt_FromLong((long) AL_ERROR_INPUT_OVERFLOW);
2534 if (x == NULL || PyDict_SetItemString(d, "ERROR_INPUT_OVERFLOW", x) < 0)
2535 goto error;
2536 Py_DECREF(x);
2537#endif
2538#ifdef AL_ERROR_LENGTH
2539 x = PyInt_FromLong((long) AL_ERROR_LENGTH);
2540 if (x == NULL || PyDict_SetItemString(d, "ERROR_LENGTH", x) < 0)
2541 goto error;
2542 Py_DECREF(x);
2543#endif
2544#ifdef AL_ERROR_LOCATION_LSP
2545 x = PyInt_FromLong((long) AL_ERROR_LOCATION_LSP);
2546 if (x == NULL || PyDict_SetItemString(d, "ERROR_LOCATION_LSP", x) < 0)
2547 goto error;
2548 Py_DECREF(x);
2549#endif
2550#ifdef AL_ERROR_LOCATION_MSP
2551 x = PyInt_FromLong((long) AL_ERROR_LOCATION_MSP);
2552 if (x == NULL || PyDict_SetItemString(d, "ERROR_LOCATION_MSP", x) < 0)
2553 goto error;
2554 Py_DECREF(x);
2555#endif
2556#ifdef AL_ERROR_NUMBER
2557 x = PyInt_FromLong((long) AL_ERROR_NUMBER);
2558 if (x == NULL || PyDict_SetItemString(d, "ERROR_NUMBER", x) < 0)
2559 goto error;
2560 Py_DECREF(x);
2561#endif
2562#ifdef AL_ERROR_OUTPUT_UNDERFLOW
2563 x = PyInt_FromLong((long) AL_ERROR_OUTPUT_UNDERFLOW);
2564 if (x == NULL || PyDict_SetItemString(d, "ERROR_OUTPUT_UNDERFLOW", x) < 0)
2565 goto error;
2566 Py_DECREF(x);
2567#endif
2568#ifdef AL_ERROR_TYPE
2569 x = PyInt_FromLong((long) AL_ERROR_TYPE);
2570 if (x == NULL || PyDict_SetItemString(d, "ERROR_TYPE", x) < 0)
2571 goto error;
2572 Py_DECREF(x);
2573#endif
2574#ifdef AL_FIXED_ELEM
2575 x = PyInt_FromLong((long) AL_FIXED_ELEM);
2576 if (x == NULL || PyDict_SetItemString(d, "FIXED_ELEM", x) < 0)
2577 goto error;
2578 Py_DECREF(x);
2579#endif
2580#ifdef AL_FIXED_MCLK_TYPE
2581 x = PyInt_FromLong((long) AL_FIXED_MCLK_TYPE);
2582 if (x == NULL || PyDict_SetItemString(d, "FIXED_MCLK_TYPE", x) < 0)
2583 goto error;
2584 Py_DECREF(x);
2585#endif
2586#ifdef AL_GAIN
2587 x = PyInt_FromLong((long) AL_GAIN);
2588 if (x == NULL || PyDict_SetItemString(d, "GAIN", x) < 0)
2589 goto error;
2590 Py_DECREF(x);
2591#endif
2592#ifdef AL_GAIN_REF
2593 x = PyInt_FromLong((long) AL_GAIN_REF);
2594 if (x == NULL || PyDict_SetItemString(d, "GAIN_REF", x) < 0)
2595 goto error;
2596 Py_DECREF(x);
2597#endif
2598#ifdef AL_HRB_TYPE
2599 x = PyInt_FromLong((long) AL_HRB_TYPE);
2600 if (x == NULL || PyDict_SetItemString(d, "HRB_TYPE", x) < 0)
2601 goto error;
2602 Py_DECREF(x);
2603#endif
2604#ifdef AL_INPUT_COUNT
2605 x = PyInt_FromLong((long) AL_INPUT_COUNT);
2606 if (x == NULL || PyDict_SetItemString(d, "INPUT_COUNT", x) < 0)
2607 goto error;
2608 Py_DECREF(x);
2609#endif
2610#ifdef AL_INPUT_DEVICE_TYPE
2611 x = PyInt_FromLong((long) AL_INPUT_DEVICE_TYPE);
2612 if (x == NULL || PyDict_SetItemString(d, "INPUT_DEVICE_TYPE", x) < 0)
2613 goto error;
2614 Py_DECREF(x);
2615#endif
2616#ifdef AL_INPUT_DIGITAL
2617 x = PyInt_FromLong((long) AL_INPUT_DIGITAL);
2618 if (x == NULL || PyDict_SetItemString(d, "INPUT_DIGITAL", x) < 0)
2619 goto error;
2620 Py_DECREF(x);
2621#endif
2622#ifdef AL_INPUT_HRB_TYPE
2623 x = PyInt_FromLong((long) AL_INPUT_HRB_TYPE);
2624 if (x == NULL || PyDict_SetItemString(d, "INPUT_HRB_TYPE", x) < 0)
2625 goto error;
2626 Py_DECREF(x);
2627#endif
2628#ifdef AL_INPUT_LINE
2629 x = PyInt_FromLong((long) AL_INPUT_LINE);
2630 if (x == NULL || PyDict_SetItemString(d, "INPUT_LINE", x) < 0)
2631 goto error;
2632 Py_DECREF(x);
2633#endif
2634#ifdef AL_INPUT_MIC
2635 x = PyInt_FromLong((long) AL_INPUT_MIC);
2636 if (x == NULL || PyDict_SetItemString(d, "INPUT_MIC", x) < 0)
2637 goto error;
2638 Py_DECREF(x);
2639#endif
2640#ifdef AL_INPUT_PORT_TYPE
2641 x = PyInt_FromLong((long) AL_INPUT_PORT_TYPE);
2642 if (x == NULL || PyDict_SetItemString(d, "INPUT_PORT_TYPE", x) < 0)
2643 goto error;
2644 Py_DECREF(x);
2645#endif
2646#ifdef AL_INPUT_RATE
2647 x = PyInt_FromLong((long) AL_INPUT_RATE);
2648 if (x == NULL || PyDict_SetItemString(d, "INPUT_RATE", x) < 0)
2649 goto error;
2650 Py_DECREF(x);
2651#endif
2652#ifdef AL_INPUT_SOURCE
2653 x = PyInt_FromLong((long) AL_INPUT_SOURCE);
2654 if (x == NULL || PyDict_SetItemString(d, "INPUT_SOURCE", x) < 0)
2655 goto error;
2656 Py_DECREF(x);
2657#endif
2658#ifdef AL_INT32_ELEM
2659 x = PyInt_FromLong((long) AL_INT32_ELEM);
2660 if (x == NULL || PyDict_SetItemString(d, "INT32_ELEM", x) < 0)
2661 goto error;
2662 Py_DECREF(x);
2663#endif
2664#ifdef AL_INT64_ELEM
2665 x = PyInt_FromLong((long) AL_INT64_ELEM);
2666 if (x == NULL || PyDict_SetItemString(d, "INT64_ELEM", x) < 0)
2667 goto error;
2668 Py_DECREF(x);
2669#endif
2670#ifdef AL_INTERFACE
2671 x = PyInt_FromLong((long) AL_INTERFACE);
2672 if (x == NULL || PyDict_SetItemString(d, "INTERFACE", x) < 0)
2673 goto error;
2674 Py_DECREF(x);
2675#endif
2676#ifdef AL_INTERFACE_TYPE
2677 x = PyInt_FromLong((long) AL_INTERFACE_TYPE);
2678 if (x == NULL || PyDict_SetItemString(d, "INTERFACE_TYPE", x) < 0)
2679 goto error;
2680 Py_DECREF(x);
2681#endif
2682#ifdef AL_INVALID_PARAM
2683 x = PyInt_FromLong((long) AL_INVALID_PARAM);
2684 if (x == NULL || PyDict_SetItemString(d, "INVALID_PARAM", x) < 0)
2685 goto error;
2686 Py_DECREF(x);
2687#endif
2688#ifdef AL_INVALID_VALUE
2689 x = PyInt_FromLong((long) AL_INVALID_VALUE);
2690 if (x == NULL || PyDict_SetItemString(d, "INVALID_VALUE", x) < 0)
2691 goto error;
2692 Py_DECREF(x);
2693#endif
2694#ifdef AL_JITTER
2695 x = PyInt_FromLong((long) AL_JITTER);
2696 if (x == NULL || PyDict_SetItemString(d, "JITTER", x) < 0)
2697 goto error;
2698 Py_DECREF(x);
2699#endif
2700#ifdef AL_LABEL
2701 x = PyInt_FromLong((long) AL_LABEL);
2702 if (x == NULL || PyDict_SetItemString(d, "LABEL", x) < 0)
2703 goto error;
2704 Py_DECREF(x);
2705#endif
2706#ifdef AL_LEFT_INPUT_ATTEN
2707 x = PyInt_FromLong((long) AL_LEFT_INPUT_ATTEN);
2708 if (x == NULL || PyDict_SetItemString(d, "LEFT_INPUT_ATTEN", x) < 0)
2709 goto error;
2710 Py_DECREF(x);
2711#endif
2712#ifdef AL_LEFT_MONITOR_ATTEN
2713 x = PyInt_FromLong((long) AL_LEFT_MONITOR_ATTEN);
2714 if (x == NULL || PyDict_SetItemString(d, "LEFT_MONITOR_ATTEN", x) < 0)
2715 goto error;
2716 Py_DECREF(x);
2717#endif
2718#ifdef AL_LEFT_SPEAKER_GAIN
2719 x = PyInt_FromLong((long) AL_LEFT_SPEAKER_GAIN);
2720 if (x == NULL || PyDict_SetItemString(d, "LEFT_SPEAKER_GAIN", x) < 0)
2721 goto error;
2722 Py_DECREF(x);
2723#endif
2724#ifdef AL_LEFT1_INPUT_ATTEN
2725 x = PyInt_FromLong((long) AL_LEFT1_INPUT_ATTEN);
2726 if (x == NULL || PyDict_SetItemString(d, "LEFT1_INPUT_ATTEN", x) < 0)
2727 goto error;
2728 Py_DECREF(x);
2729#endif
2730#ifdef AL_LEFT2_INPUT_ATTEN
2731 x = PyInt_FromLong((long) AL_LEFT2_INPUT_ATTEN);
2732 if (x == NULL || PyDict_SetItemString(d, "LEFT2_INPUT_ATTEN", x) < 0)
2733 goto error;
2734 Py_DECREF(x);
2735#endif
2736#ifdef AL_LINE_IF_TYPE
2737 x = PyInt_FromLong((long) AL_LINE_IF_TYPE);
2738 if (x == NULL || PyDict_SetItemString(d, "LINE_IF_TYPE", x) < 0)
2739 goto error;
2740 Py_DECREF(x);
2741#endif
2742#ifdef AL_MASTER_CLOCK
2743 x = PyInt_FromLong((long) AL_MASTER_CLOCK);
2744 if (x == NULL || PyDict_SetItemString(d, "MASTER_CLOCK", x) < 0)
2745 goto error;
2746 Py_DECREF(x);
2747#endif
2748#ifdef AL_MATRIX_VAL
2749 x = PyInt_FromLong((long) AL_MATRIX_VAL);
2750 if (x == NULL || PyDict_SetItemString(d, "MATRIX_VAL", x) < 0)
2751 goto error;
2752 Py_DECREF(x);
2753#endif
2754#ifdef AL_MAX_ERROR
2755 x = PyInt_FromLong((long) AL_MAX_ERROR);
2756 if (x == NULL || PyDict_SetItemString(d, "MAX_ERROR", x) < 0)
2757 goto error;
2758 Py_DECREF(x);
2759#endif
2760#ifdef AL_MAX_EVENT_PARAM
2761 x = PyInt_FromLong((long) AL_MAX_EVENT_PARAM);
2762 if (x == NULL || PyDict_SetItemString(d, "MAX_EVENT_PARAM", x) < 0)
2763 goto error;
2764 Py_DECREF(x);
2765#endif
2766#ifdef AL_MAX_PBUFSIZE
2767 x = PyInt_FromLong((long) AL_MAX_PBUFSIZE);
2768 if (x == NULL || PyDict_SetItemString(d, "MAX_PBUFSIZE", x) < 0)
2769 goto error;
2770 Py_DECREF(x);
2771#endif
2772#ifdef AL_MAX_PORTS
2773 x = PyInt_FromLong((long) AL_MAX_PORTS);
2774 if (x == NULL || PyDict_SetItemString(d, "MAX_PORTS", x) < 0)
2775 goto error;
2776 Py_DECREF(x);
2777#endif
2778#ifdef AL_MAX_RESOURCE_ID
2779 x = PyInt_FromLong((long) AL_MAX_RESOURCE_ID);
2780 if (x == NULL || PyDict_SetItemString(d, "MAX_RESOURCE_ID", x) < 0)
2781 goto error;
2782 Py_DECREF(x);
2783#endif
2784#ifdef AL_MAX_SETSIZE
2785 x = PyInt_FromLong((long) AL_MAX_SETSIZE);
2786 if (x == NULL || PyDict_SetItemString(d, "MAX_SETSIZE", x) < 0)
2787 goto error;
2788 Py_DECREF(x);
2789#endif
2790#ifdef AL_MAX_STRLEN
2791 x = PyInt_FromLong((long) AL_MAX_STRLEN);
2792 if (x == NULL || PyDict_SetItemString(d, "MAX_STRLEN", x) < 0)
2793 goto error;
2794 Py_DECREF(x);
2795#endif
2796#ifdef AL_MCLK_TYPE
2797 x = PyInt_FromLong((long) AL_MCLK_TYPE);
2798 if (x == NULL || PyDict_SetItemString(d, "MCLK_TYPE", x) < 0)
2799 goto error;
2800 Py_DECREF(x);
2801#endif
2802#ifdef AL_MIC_IF_TYPE
2803 x = PyInt_FromLong((long) AL_MIC_IF_TYPE);
2804 if (x == NULL || PyDict_SetItemString(d, "MIC_IF_TYPE", x) < 0)
2805 goto error;
2806 Py_DECREF(x);
2807#endif
2808#ifdef AL_MONITOR_CTL
2809 x = PyInt_FromLong((long) AL_MONITOR_CTL);
2810 if (x == NULL || PyDict_SetItemString(d, "MONITOR_CTL", x) < 0)
2811 goto error;
2812 Py_DECREF(x);
2813#endif
2814#ifdef AL_MONITOR_OFF
2815 x = PyInt_FromLong((long) AL_MONITOR_OFF);
2816 if (x == NULL || PyDict_SetItemString(d, "MONITOR_OFF", x) < 0)
2817 goto error;
2818 Py_DECREF(x);
2819#endif
2820#ifdef AL_MONITOR_ON
2821 x = PyInt_FromLong((long) AL_MONITOR_ON);
2822 if (x == NULL || PyDict_SetItemString(d, "MONITOR_ON", x) < 0)
2823 goto error;
2824 Py_DECREF(x);
2825#endif
2826#ifdef AL_MONO
2827 x = PyInt_FromLong((long) AL_MONO);
2828 if (x == NULL || PyDict_SetItemString(d, "MONO", x) < 0)
2829 goto error;
2830 Py_DECREF(x);
2831#endif
2832#ifdef AL_MUTE
2833 x = PyInt_FromLong((long) AL_MUTE);
2834 if (x == NULL || PyDict_SetItemString(d, "MUTE", x) < 0)
2835 goto error;
2836 Py_DECREF(x);
2837#endif
2838#ifdef AL_NAME
2839 x = PyInt_FromLong((long) AL_NAME);
2840 if (x == NULL || PyDict_SetItemString(d, "NAME", x) < 0)
2841 goto error;
2842 Py_DECREF(x);
2843#endif
2844#ifdef AL_NEG_INFINITY
2845 x = PyInt_FromLong((long) AL_NEG_INFINITY);
2846 if (x == NULL || PyDict_SetItemString(d, "NEG_INFINITY", x) < 0)
2847 goto error;
2848 Py_DECREF(x);
2849#endif
2850#ifdef AL_NEG_INFINITY_BIT
2851 x = PyInt_FromLong((long) AL_NEG_INFINITY_BIT);
2852 if (x == NULL || PyDict_SetItemString(d, "NEG_INFINITY_BIT", x) < 0)
2853 goto error;
2854 Py_DECREF(x);
2855#endif
2856#ifdef AL_NO_CHANGE
2857 x = PyInt_FromLong((long) AL_NO_CHANGE);
2858 if (x == NULL || PyDict_SetItemString(d, "NO_CHANGE", x) < 0)
2859 goto error;
2860 Py_DECREF(x);
2861#endif
2862#ifdef AL_NO_CHANGE_BIT
2863 x = PyInt_FromLong((long) AL_NO_CHANGE_BIT);
2864 if (x == NULL || PyDict_SetItemString(d, "NO_CHANGE_BIT", x) < 0)
2865 goto error;
2866 Py_DECREF(x);
2867#endif
2868#ifdef AL_NO_ELEM
2869 x = PyInt_FromLong((long) AL_NO_ELEM);
2870 if (x == NULL || PyDict_SetItemString(d, "NO_ELEM", x) < 0)
2871 goto error;
2872 Py_DECREF(x);
2873#endif
2874#ifdef AL_NO_ERRORS
2875 x = PyInt_FromLong((long) AL_NO_ERRORS);
2876 if (x == NULL || PyDict_SetItemString(d, "NO_ERRORS", x) < 0)
2877 goto error;
2878 Py_DECREF(x);
2879#endif
2880#ifdef AL_NO_OP
2881 x = PyInt_FromLong((long) AL_NO_OP);
2882 if (x == NULL || PyDict_SetItemString(d, "NO_OP", x) < 0)
2883 goto error;
2884 Py_DECREF(x);
2885#endif
2886#ifdef AL_NO_VAL
2887 x = PyInt_FromLong((long) AL_NO_VAL);
2888 if (x == NULL || PyDict_SetItemString(d, "NO_VAL", x) < 0)
2889 goto error;
2890 Py_DECREF(x);
2891#endif
2892#ifdef AL_NULL_RESOURCE
2893 x = PyInt_FromLong((long) AL_NULL_RESOURCE);
2894 if (x == NULL || PyDict_SetItemString(d, "NULL_RESOURCE", x) < 0)
2895 goto error;
2896 Py_DECREF(x);
2897#endif
2898#ifdef AL_OUTPUT_COUNT
2899 x = PyInt_FromLong((long) AL_OUTPUT_COUNT);
2900 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_COUNT", x) < 0)
2901 goto error;
2902 Py_DECREF(x);
2903#endif
2904#ifdef AL_OUTPUT_DEVICE_TYPE
2905 x = PyInt_FromLong((long) AL_OUTPUT_DEVICE_TYPE);
2906 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_DEVICE_TYPE", x) < 0)
2907 goto error;
2908 Py_DECREF(x);
2909#endif
2910#ifdef AL_OUTPUT_HRB_TYPE
2911 x = PyInt_FromLong((long) AL_OUTPUT_HRB_TYPE);
2912 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_HRB_TYPE", x) < 0)
2913 goto error;
2914 Py_DECREF(x);
2915#endif
2916#ifdef AL_OUTPUT_PORT_TYPE
2917 x = PyInt_FromLong((long) AL_OUTPUT_PORT_TYPE);
2918 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_PORT_TYPE", x) < 0)
2919 goto error;
2920 Py_DECREF(x);
2921#endif
2922#ifdef AL_OUTPUT_RATE
2923 x = PyInt_FromLong((long) AL_OUTPUT_RATE);
2924 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_RATE", x) < 0)
2925 goto error;
2926 Py_DECREF(x);
2927#endif
2928#ifdef AL_PARAM_BIT
2929 x = PyInt_FromLong((long) AL_PARAM_BIT);
2930 if (x == NULL || PyDict_SetItemString(d, "PARAM_BIT", x) < 0)
2931 goto error;
2932 Py_DECREF(x);
2933#endif
2934#ifdef AL_PARAMS
2935 x = PyInt_FromLong((long) AL_PARAMS);
2936 if (x == NULL || PyDict_SetItemString(d, "PARAMS", x) < 0)
2937 goto error;
2938 Py_DECREF(x);
2939#endif
2940#ifdef AL_PORT_COUNT
2941 x = PyInt_FromLong((long) AL_PORT_COUNT);
2942 if (x == NULL || PyDict_SetItemString(d, "PORT_COUNT", x) < 0)
2943 goto error;
2944 Py_DECREF(x);
2945#endif
2946#ifdef AL_PORT_TYPE
2947 x = PyInt_FromLong((long) AL_PORT_TYPE);
2948 if (x == NULL || PyDict_SetItemString(d, "PORT_TYPE", x) < 0)
2949 goto error;
2950 Py_DECREF(x);
2951#endif
2952#ifdef AL_PORTS
2953 x = PyInt_FromLong((long) AL_PORTS);
2954 if (x == NULL || PyDict_SetItemString(d, "PORTS", x) < 0)
2955 goto error;
2956 Py_DECREF(x);
2957#endif
2958#ifdef AL_PORTSTYLE_DIRECT
2959 x = PyInt_FromLong((long) AL_PORTSTYLE_DIRECT);
2960 if (x == NULL || PyDict_SetItemString(d, "PORTSTYLE_DIRECT", x) < 0)
2961 goto error;
2962 Py_DECREF(x);
2963#endif
2964#ifdef AL_PORTSTYLE_SERIAL
2965 x = PyInt_FromLong((long) AL_PORTSTYLE_SERIAL);
2966 if (x == NULL || PyDict_SetItemString(d, "PORTSTYLE_SERIAL", x) < 0)
2967 goto error;
2968 Py_DECREF(x);
2969#endif
2970#ifdef AL_PRINT_ERRORS
2971 x = PyInt_FromLong((long) AL_PRINT_ERRORS);
2972 if (x == NULL || PyDict_SetItemString(d, "PRINT_ERRORS", x) < 0)
2973 goto error;
2974 Py_DECREF(x);
2975#endif
2976#ifdef AL_PTR_ELEM
2977 x = PyInt_FromLong((long) AL_PTR_ELEM);
2978 if (x == NULL || PyDict_SetItemString(d, "PTR_ELEM", x) < 0)
2979 goto error;
2980 Py_DECREF(x);
2981#endif
2982#ifdef AL_RANGE_VALUE
2983 x = PyInt_FromLong((long) AL_RANGE_VALUE);
2984 if (x == NULL || PyDict_SetItemString(d, "RANGE_VALUE", x) < 0)
2985 goto error;
2986 Py_DECREF(x);
2987#endif
2988#ifdef AL_RATE
2989 x = PyInt_FromLong((long) AL_RATE);
2990 if (x == NULL || PyDict_SetItemString(d, "RATE", x) < 0)
2991 goto error;
2992 Py_DECREF(x);
2993#endif
2994#ifdef AL_RATE_11025
2995 x = PyInt_FromLong((long) AL_RATE_11025);
2996 if (x == NULL || PyDict_SetItemString(d, "RATE_11025", x) < 0)
2997 goto error;
2998 Py_DECREF(x);
2999#endif
3000#ifdef AL_RATE_16000
3001 x = PyInt_FromLong((long) AL_RATE_16000);
3002 if (x == NULL || PyDict_SetItemString(d, "RATE_16000", x) < 0)
3003 goto error;
3004 Py_DECREF(x);
3005#endif
3006#ifdef AL_RATE_22050
3007 x = PyInt_FromLong((long) AL_RATE_22050);
3008 if (x == NULL || PyDict_SetItemString(d, "RATE_22050", x) < 0)
3009 goto error;
3010 Py_DECREF(x);
3011#endif
3012#ifdef AL_RATE_32000
3013 x = PyInt_FromLong((long) AL_RATE_32000);
3014 if (x == NULL || PyDict_SetItemString(d, "RATE_32000", x) < 0)
3015 goto error;
3016 Py_DECREF(x);
3017#endif
3018#ifdef AL_RATE_44100
3019 x = PyInt_FromLong((long) AL_RATE_44100);
3020 if (x == NULL || PyDict_SetItemString(d, "RATE_44100", x) < 0)
3021 goto error;
3022 Py_DECREF(x);
3023#endif
3024#ifdef AL_RATE_48000
3025 x = PyInt_FromLong((long) AL_RATE_48000);
3026 if (x == NULL || PyDict_SetItemString(d, "RATE_48000", x) < 0)
3027 goto error;
3028 Py_DECREF(x);
3029#endif
3030#ifdef AL_RATE_8000
3031 x = PyInt_FromLong((long) AL_RATE_8000);
3032 if (x == NULL || PyDict_SetItemString(d, "RATE_8000", x) < 0)
3033 goto error;
3034 Py_DECREF(x);
3035#endif
3036#ifdef AL_RATE_AES_1
3037 x = PyInt_FromLong((long) AL_RATE_AES_1);
3038 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_1", x) < 0)
3039 goto error;
3040 Py_DECREF(x);
3041#endif
3042#ifdef AL_RATE_AES_1s
3043 x = PyInt_FromLong((long) AL_RATE_AES_1s);
3044 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_1s", x) < 0)
3045 goto error;
3046 Py_DECREF(x);
3047#endif
3048#ifdef AL_RATE_AES_2
3049 x = PyInt_FromLong((long) AL_RATE_AES_2);
3050 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_2", x) < 0)
3051 goto error;
3052 Py_DECREF(x);
3053#endif
3054#ifdef AL_RATE_AES_3
3055 x = PyInt_FromLong((long) AL_RATE_AES_3);
3056 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_3", x) < 0)
3057 goto error;
3058 Py_DECREF(x);
3059#endif
3060#ifdef AL_RATE_AES_4
3061 x = PyInt_FromLong((long) AL_RATE_AES_4);
3062 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_4", x) < 0)
3063 goto error;
3064 Py_DECREF(x);
3065#endif
3066#ifdef AL_RATE_AES_6
3067 x = PyInt_FromLong((long) AL_RATE_AES_6);
3068 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_6", x) < 0)
3069 goto error;
3070 Py_DECREF(x);
3071#endif
3072#ifdef AL_RATE_FRACTION_D
3073 x = PyInt_FromLong((long) AL_RATE_FRACTION_D);
3074 if (x == NULL || PyDict_SetItemString(d, "RATE_FRACTION_D", x) < 0)
3075 goto error;
3076 Py_DECREF(x);
3077#endif
3078#ifdef AL_RATE_FRACTION_N
3079 x = PyInt_FromLong((long) AL_RATE_FRACTION_N);
3080 if (x == NULL || PyDict_SetItemString(d, "RATE_FRACTION_N", x) < 0)
3081 goto error;
3082 Py_DECREF(x);
3083#endif
3084#ifdef AL_RATE_INPUTRATE
3085 x = PyInt_FromLong((long) AL_RATE_INPUTRATE);
3086 if (x == NULL || PyDict_SetItemString(d, "RATE_INPUTRATE", x) < 0)
3087 goto error;
3088 Py_DECREF(x);
3089#endif
3090#ifdef AL_RATE_NO_DIGITAL_INPUT
3091 x = PyInt_FromLong((long) AL_RATE_NO_DIGITAL_INPUT);
3092 if (x == NULL || PyDict_SetItemString(d, "RATE_NO_DIGITAL_INPUT", x) < 0)
3093 goto error;
3094 Py_DECREF(x);
3095#endif
3096#ifdef AL_RATE_UNACQUIRED
3097 x = PyInt_FromLong((long) AL_RATE_UNACQUIRED);
3098 if (x == NULL || PyDict_SetItemString(d, "RATE_UNACQUIRED", x) < 0)
3099 goto error;
3100 Py_DECREF(x);
3101#endif
3102#ifdef AL_RATE_UNDEFINED
3103 x = PyInt_FromLong((long) AL_RATE_UNDEFINED);
3104 if (x == NULL || PyDict_SetItemString(d, "RATE_UNDEFINED", x) < 0)
3105 goto error;
3106 Py_DECREF(x);
3107#endif
3108#ifdef AL_REF_0DBV
3109 x = PyInt_FromLong((long) AL_REF_0DBV);
3110 if (x == NULL || PyDict_SetItemString(d, "REF_0DBV", x) < 0)
3111 goto error;
3112 Py_DECREF(x);
3113#endif
3114#ifdef AL_REF_NONE
3115 x = PyInt_FromLong((long) AL_REF_NONE);
3116 if (x == NULL || PyDict_SetItemString(d, "REF_NONE", x) < 0)
3117 goto error;
3118 Py_DECREF(x);
3119#endif
3120#ifdef AL_RESERVED1_TYPE
3121 x = PyInt_FromLong((long) AL_RESERVED1_TYPE);
3122 if (x == NULL || PyDict_SetItemString(d, "RESERVED1_TYPE", x) < 0)
3123 goto error;
3124 Py_DECREF(x);
3125#endif
3126#ifdef AL_RESERVED2_TYPE
3127 x = PyInt_FromLong((long) AL_RESERVED2_TYPE);
3128 if (x == NULL || PyDict_SetItemString(d, "RESERVED2_TYPE", x) < 0)
3129 goto error;
3130 Py_DECREF(x);
3131#endif
3132#ifdef AL_RESERVED3_TYPE
3133 x = PyInt_FromLong((long) AL_RESERVED3_TYPE);
3134 if (x == NULL || PyDict_SetItemString(d, "RESERVED3_TYPE", x) < 0)
3135 goto error;
3136 Py_DECREF(x);
3137#endif
3138#ifdef AL_RESERVED4_TYPE
3139 x = PyInt_FromLong((long) AL_RESERVED4_TYPE);
3140 if (x == NULL || PyDict_SetItemString(d, "RESERVED4_TYPE", x) < 0)
3141 goto error;
3142 Py_DECREF(x);
3143#endif
3144#ifdef AL_RESOURCE
3145 x = PyInt_FromLong((long) AL_RESOURCE);
3146 if (x == NULL || PyDict_SetItemString(d, "RESOURCE", x) < 0)
3147 goto error;
3148 Py_DECREF(x);
3149#endif
3150#ifdef AL_RESOURCE_ELEM
3151 x = PyInt_FromLong((long) AL_RESOURCE_ELEM);
3152 if (x == NULL || PyDict_SetItemString(d, "RESOURCE_ELEM", x) < 0)
3153 goto error;
3154 Py_DECREF(x);
3155#endif
3156#ifdef AL_RESOURCE_TYPE
3157 x = PyInt_FromLong((long) AL_RESOURCE_TYPE);
3158 if (x == NULL || PyDict_SetItemString(d, "RESOURCE_TYPE", x) < 0)
3159 goto error;
3160 Py_DECREF(x);
3161#endif
3162#ifdef AL_RIGHT_INPUT_ATTEN
3163 x = PyInt_FromLong((long) AL_RIGHT_INPUT_ATTEN);
3164 if (x == NULL || PyDict_SetItemString(d, "RIGHT_INPUT_ATTEN", x) < 0)
3165 goto error;
3166 Py_DECREF(x);
3167#endif
3168#ifdef AL_RIGHT_MONITOR_ATTEN
3169 x = PyInt_FromLong((long) AL_RIGHT_MONITOR_ATTEN);
3170 if (x == NULL || PyDict_SetItemString(d, "RIGHT_MONITOR_ATTEN", x) < 0)
3171 goto error;
3172 Py_DECREF(x);
3173#endif
3174#ifdef AL_RIGHT_SPEAKER_GAIN
3175 x = PyInt_FromLong((long) AL_RIGHT_SPEAKER_GAIN);
3176 if (x == NULL || PyDict_SetItemString(d, "RIGHT_SPEAKER_GAIN", x) < 0)
3177 goto error;
3178 Py_DECREF(x);
3179#endif
3180#ifdef AL_RIGHT1_INPUT_ATTEN
3181 x = PyInt_FromLong((long) AL_RIGHT1_INPUT_ATTEN);
3182 if (x == NULL || PyDict_SetItemString(d, "RIGHT1_INPUT_ATTEN", x) < 0)
3183 goto error;
3184 Py_DECREF(x);
3185#endif
3186#ifdef AL_RIGHT2_INPUT_ATTEN
3187 x = PyInt_FromLong((long) AL_RIGHT2_INPUT_ATTEN);
3188 if (x == NULL || PyDict_SetItemString(d, "RIGHT2_INPUT_ATTEN", x) < 0)
3189 goto error;
3190 Py_DECREF(x);
3191#endif
3192#ifdef AL_SAMPFMT_DOUBLE
3193 x = PyInt_FromLong((long) AL_SAMPFMT_DOUBLE);
3194 if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_DOUBLE", x) < 0)
3195 goto error;
3196 Py_DECREF(x);
3197#endif
3198#ifdef AL_SAMPFMT_FLOAT
3199 x = PyInt_FromLong((long) AL_SAMPFMT_FLOAT);
3200 if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_FLOAT", x) < 0)
3201 goto error;
3202 Py_DECREF(x);
3203#endif
3204#ifdef AL_SAMPFMT_TWOSCOMP
3205 x = PyInt_FromLong((long) AL_SAMPFMT_TWOSCOMP);
3206 if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_TWOSCOMP", x) < 0)
3207 goto error;
3208 Py_DECREF(x);
3209#endif
3210#ifdef AL_SAMPLE_16
3211 x = PyInt_FromLong((long) AL_SAMPLE_16);
3212 if (x == NULL || PyDict_SetItemString(d, "SAMPLE_16", x) < 0)
3213 goto error;
3214 Py_DECREF(x);
3215#endif
3216#ifdef AL_SAMPLE_24
3217 x = PyInt_FromLong((long) AL_SAMPLE_24);
3218 if (x == NULL || PyDict_SetItemString(d, "SAMPLE_24", x) < 0)
3219 goto error;
3220 Py_DECREF(x);
3221#endif
3222#ifdef AL_SAMPLE_8
3223 x = PyInt_FromLong((long) AL_SAMPLE_8);
3224 if (x == NULL || PyDict_SetItemString(d, "SAMPLE_8", x) < 0)
3225 goto error;
3226 Py_DECREF(x);
3227#endif
3228#ifdef AL_SCALAR_VAL
3229 x = PyInt_FromLong((long) AL_SCALAR_VAL);
3230 if (x == NULL || PyDict_SetItemString(d, "SCALAR_VAL", x) < 0)
3231 goto error;
3232 Py_DECREF(x);
3233#endif
3234#ifdef AL_SET_VAL
3235 x = PyInt_FromLong((long) AL_SET_VAL);
3236 if (x == NULL || PyDict_SetItemString(d, "SET_VAL", x) < 0)
3237 goto error;
3238 Py_DECREF(x);
3239#endif
3240#ifdef AL_SHORT_NAME
3241 x = PyInt_FromLong((long) AL_SHORT_NAME);
3242 if (x == NULL || PyDict_SetItemString(d, "SHORT_NAME", x) < 0)
3243 goto error;
3244 Py_DECREF(x);
3245#endif
3246#ifdef AL_SOURCE
3247 x = PyInt_FromLong((long) AL_SOURCE);
3248 if (x == NULL || PyDict_SetItemString(d, "SOURCE", x) < 0)
3249 goto error;
3250 Py_DECREF(x);
3251#endif
3252#ifdef AL_SPEAKER_IF_TYPE
3253 x = PyInt_FromLong((long) AL_SPEAKER_IF_TYPE);
3254 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_IF_TYPE", x) < 0)
3255 goto error;
3256 Py_DECREF(x);
3257#endif
3258#ifdef AL_SPEAKER_MUTE_CTL
3259 x = PyInt_FromLong((long) AL_SPEAKER_MUTE_CTL);
3260 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_CTL", x) < 0)
3261 goto error;
3262 Py_DECREF(x);
3263#endif
3264#ifdef AL_SPEAKER_MUTE_OFF
3265 x = PyInt_FromLong((long) AL_SPEAKER_MUTE_OFF);
3266 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_OFF", x) < 0)
3267 goto error;
3268 Py_DECREF(x);
3269#endif
3270#ifdef AL_SPEAKER_MUTE_ON
3271 x = PyInt_FromLong((long) AL_SPEAKER_MUTE_ON);
3272 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_ON", x) < 0)
3273 goto error;
3274 Py_DECREF(x);
3275#endif
3276#ifdef AL_SPEAKER_PLUS_LINE_IF_TYPE
3277 x = PyInt_FromLong((long) AL_SPEAKER_PLUS_LINE_IF_TYPE);
3278 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_PLUS_LINE_IF_TYPE", x) < 0)
3279 goto error;
3280 Py_DECREF(x);
3281#endif
3282#ifdef AL_STEREO
3283 x = PyInt_FromLong((long) AL_STEREO);
3284 if (x == NULL || PyDict_SetItemString(d, "STEREO", x) < 0)
3285 goto error;
3286 Py_DECREF(x);
3287#endif
3288#ifdef AL_STRING_VAL
3289 x = PyInt_FromLong((long) AL_STRING_VAL);
3290 if (x == NULL || PyDict_SetItemString(d, "STRING_VAL", x) < 0)
3291 goto error;
3292 Py_DECREF(x);
3293#endif
3294#ifdef AL_SUBSYSTEM
3295 x = PyInt_FromLong((long) AL_SUBSYSTEM);
3296 if (x == NULL || PyDict_SetItemString(d, "SUBSYSTEM", x) < 0)
3297 goto error;
3298 Py_DECREF(x);
3299#endif
3300#ifdef AL_SUBSYSTEM_TYPE
3301 x = PyInt_FromLong((long) AL_SUBSYSTEM_TYPE);
3302 if (x == NULL || PyDict_SetItemString(d, "SUBSYSTEM_TYPE", x) < 0)
3303 goto error;
3304 Py_DECREF(x);
3305#endif
3306#ifdef AL_SYNC_INPUT_TO_AES
3307 x = PyInt_FromLong((long) AL_SYNC_INPUT_TO_AES);
3308 if (x == NULL || PyDict_SetItemString(d, "SYNC_INPUT_TO_AES", x) < 0)
3309 goto error;
3310 Py_DECREF(x);
3311#endif
3312#ifdef AL_SYNC_OUTPUT_TO_AES
3313 x = PyInt_FromLong((long) AL_SYNC_OUTPUT_TO_AES);
3314 if (x == NULL || PyDict_SetItemString(d, "SYNC_OUTPUT_TO_AES", x) < 0)
3315 goto error;
3316 Py_DECREF(x);
3317#endif
3318#ifdef AL_SYSTEM
3319 x = PyInt_FromLong((long) AL_SYSTEM);
3320 if (x == NULL || PyDict_SetItemString(d, "SYSTEM", x) < 0)
3321 goto error;
3322 Py_DECREF(x);
3323#endif
3324#ifdef AL_SYSTEM_TYPE
3325 x = PyInt_FromLong((long) AL_SYSTEM_TYPE);
3326 if (x == NULL || PyDict_SetItemString(d, "SYSTEM_TYPE", x) < 0)
3327 goto error;
3328 Py_DECREF(x);
3329#endif
3330#ifdef AL_TEST_IF_TYPE
3331 x = PyInt_FromLong((long) AL_TEST_IF_TYPE);
3332 if (x == NULL || PyDict_SetItemString(d, "TEST_IF_TYPE", x) < 0)
3333 goto error;
3334 Py_DECREF(x);
3335#endif
3336#ifdef AL_TYPE
3337 x = PyInt_FromLong((long) AL_TYPE);
3338 if (x == NULL || PyDict_SetItemString(d, "TYPE", x) < 0)
3339 goto error;
3340 Py_DECREF(x);
3341#endif
3342#ifdef AL_TYPE_BIT
3343 x = PyInt_FromLong((long) AL_TYPE_BIT);
3344 if (x == NULL || PyDict_SetItemString(d, "TYPE_BIT", x) < 0)
3345 goto error;
3346 Py_DECREF(x);
3347#endif
3348#ifdef AL_UNUSED_COUNT
3349 x = PyInt_FromLong((long) AL_UNUSED_COUNT);
3350 if (x == NULL || PyDict_SetItemString(d, "UNUSED_COUNT", x) < 0)
3351 goto error;
3352 Py_DECREF(x);
3353#endif
3354#ifdef AL_UNUSED_PORTS
3355 x = PyInt_FromLong((long) AL_UNUSED_PORTS);
3356 if (x == NULL || PyDict_SetItemString(d, "UNUSED_PORTS", x) < 0)
3357 goto error;
3358 Py_DECREF(x);
3359#endif
3360#ifdef AL_VARIABLE_MCLK_TYPE
3361 x = PyInt_FromLong((long) AL_VARIABLE_MCLK_TYPE);
3362 if (x == NULL || PyDict_SetItemString(d, "VARIABLE_MCLK_TYPE", x) < 0)
3363 goto error;
3364 Py_DECREF(x);
3365#endif
3366#ifdef AL_VECTOR_VAL
3367 x = PyInt_FromLong((long) AL_VECTOR_VAL);
3368 if (x == NULL || PyDict_SetItemString(d, "VECTOR_VAL", x) < 0)
3369 goto error;
3370 Py_DECREF(x);
3371#endif
3372#ifdef AL_VIDEO_MCLK_TYPE
3373 x = PyInt_FromLong((long) AL_VIDEO_MCLK_TYPE);
3374 if (x == NULL || PyDict_SetItemString(d, "VIDEO_MCLK_TYPE", x) < 0)
3375 goto error;
3376 Py_DECREF(x);
3377#endif
3378#ifdef AL_WORDSIZE
3379 x = PyInt_FromLong((long) AL_WORDSIZE);
3380 if (x == NULL || PyDict_SetItemString(d, "WORDSIZE", x) < 0)
3381 goto error;
3382 Py_DECREF(x);
3383#endif
3384
3385#ifdef AL_NO_ELEM /* IRIX 6 */
3386 (void) alSetErrorHandler(ErrorHandler);
3387#endif /* AL_NO_ELEM */
3388#ifdef OLD_INTERFACE
3389 (void) ALseterrorhandler(ErrorHandler);
3390#endif /* OLD_INTERFACE */
Guido van Rossume3db8621991-09-09 23:33:34 +00003391
Guido van Rossumd641d671997-04-03 17:06:32 +00003392 /* Check for errors */
3393 if (PyErr_Occurred()) {
3394 error:
3395 Py_FatalError("can't initialize module al");
3396 }
Guido van Rossume3db8621991-09-09 23:33:34 +00003397}