blob: 84a989541c3bc8a9373a3b969ad5597283f8781e [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:
Jeremy Hylton03657cf2000-07-12 13:05:33 +0000179 param->sizeIn = PySequence_Size(value);
Guido van Rossumd641d671997-04-03 17:06:32 +0000180 param->value.ptr = PyMem_NEW(int, param->sizeIn);
181 stepsize = sizeof(int);
182 break;
183 case AL_INT64_ELEM:
184 case AL_FIXED_ELEM:
Jeremy Hylton03657cf2000-07-12 13:05:33 +0000185 param->sizeIn = PySequence_Size(value);
Guido van Rossumd641d671997-04-03 17:06:32 +0000186 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 *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000256SetConfig(alcobject *self, PyObject *args, int (*func)(ALconfig, int))
Guido van Rossumd641d671997-04-03 17:06:32 +0000257{
258 int par;
259
Guido van Rossum43713e52000-02-29 13:59:29 +0000260 if (!PyArg_ParseTuple(args, "i:SetConfig", &par))
Guido van Rossumd641d671997-04-03 17:06:32 +0000261 return NULL;
262
263 if ((*func)(self->config, par) == -1)
264 return NULL;
265
266 Py_INCREF(Py_None);
Roger E. Massea2a8b271997-01-03 22:40:34 +0000267 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +0000268}
269
Roger E. Massea2a8b271997-01-03 22:40:34 +0000270static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000271GetConfig(alcobject *self, PyObject *args, int (*func)(ALconfig))
Guido van Rossumd641d671997-04-03 17:06:32 +0000272{
273 int par;
274
Guido van Rossum43713e52000-02-29 13:59:29 +0000275 if (!PyArg_ParseTuple(args, ":GetConfig"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000276 return NULL;
277
278 if ((par = (*func)(self->config)) == -1)
279 return NULL;
280
281 return PyInt_FromLong((long) par);
282}
283
284static char alc_SetWidth__doc__[] =
285"alSetWidth: set the wordsize for integer audio data."
286;
287
288static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000289alc_SetWidth(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000290{
291 return SetConfig(self, args, alSetWidth);
292}
293
294
295static char alc_GetWidth__doc__[] =
296"alGetWidth: get the wordsize for integer audio data."
297;
298
299static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000300alc_GetWidth(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000301{
302 return GetConfig(self, args, alGetWidth);
303}
304
305
306static char alc_SetSampFmt__doc__[] =
307"alSetSampFmt: set the sample format setting in an audio ALconfig structure."
308;
309
310static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000311alc_SetSampFmt(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000312{
313 return SetConfig(self, args, alSetSampFmt);
314}
315
316
317static char alc_GetSampFmt__doc__[] =
318"alGetSampFmt: get the sample format setting in an audio ALconfig structure."
319;
320
321static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000322alc_GetSampFmt(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000323{
324 return GetConfig(self, args, alGetSampFmt);
325}
326
327
328static char alc_SetChannels__doc__[] =
329"alSetChannels: set the channel settings in an audio ALconfig."
330;
331
332static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000333alc_SetChannels(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000334{
335 return SetConfig(self, args, alSetChannels);
336}
337
338
339static char alc_GetChannels__doc__[] =
340"alGetChannels: get the channel settings in an audio ALconfig."
341;
342
343static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000344alc_GetChannels(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000345{
346 return GetConfig(self, args, alGetChannels);
347}
348
349
350static char alc_SetFloatMax__doc__[] =
351"alSetFloatMax: set the maximum value of floating point sample data."
352;
353
354static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000355alc_SetFloatMax(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000356{
357 double maximum_value;
358
Guido van Rossum43713e52000-02-29 13:59:29 +0000359 if (!PyArg_ParseTuple(args, "d:SetFloatMax", &maximum_value))
Guido van Rossumd641d671997-04-03 17:06:32 +0000360 return NULL;
361 if (alSetFloatMax(self->config, maximum_value) < 0)
362 return NULL;
363 Py_INCREF(Py_None);
364 return Py_None;
365}
366
367
368static char alc_GetFloatMax__doc__[] =
369"alGetFloatMax: get the maximum value of floating point sample data."
370;
371
372static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000373alc_GetFloatMax(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000374{
375 double maximum_value;
376
Guido van Rossum43713e52000-02-29 13:59:29 +0000377 if (!PyArg_ParseTuple(args, ":GetFloatMax"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000378 return NULL;
379 if ((maximum_value = alGetFloatMax(self->config)) == 0)
380 return NULL;
381 return PyFloat_FromDouble(maximum_value);
382}
383
384
385static char alc_SetDevice__doc__[] =
386"alSetDevice: set the device setting in an audio ALconfig structure."
387;
388
389static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000390alc_SetDevice(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000391{
392 return SetConfig(self, args, alSetDevice);
393}
394
395
396static char alc_GetDevice__doc__[] =
397"alGetDevice: get the device setting in an audio ALconfig structure."
398;
399
400static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000401alc_GetDevice(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000402{
403 return GetConfig(self, args, alGetDevice);
404}
405
406
407static char alc_SetQueueSize__doc__[] =
408"alSetQueueSize: set audio port buffer size."
409;
410
411static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000412alc_SetQueueSize(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000413{
414 return SetConfig(self, args, alSetQueueSize);
415}
416
417
418static char alc_GetQueueSize__doc__[] =
419"alGetQueueSize: get audio port buffer size."
420;
421
422static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000423alc_GetQueueSize(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000424{
425 return GetConfig(self, args, alGetQueueSize);
426}
427
428#endif /* AL_NO_ELEM */
429
430static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000431setconfig(alcobject *self, PyObject *args, int (*func)(ALconfig, long))
Guido van Rossumd641d671997-04-03 17:06:32 +0000432{
433 long par;
434
Guido van Rossum43713e52000-02-29 13:59:29 +0000435 if (!PyArg_ParseTuple(args, "l:SetConfig", &par))
Guido van Rossumd641d671997-04-03 17:06:32 +0000436 return NULL;
437
438 if ((*func)(self->config, par) == -1)
439 return NULL;
440
441 Py_INCREF(Py_None);
442 return Py_None;
443}
444
445static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000446getconfig(alcobject *self, PyObject *args, long (*func)(ALconfig))
Guido van Rossume3db8621991-09-09 23:33:34 +0000447{
448 long par;
449
Guido van Rossum43713e52000-02-29 13:59:29 +0000450 if (!PyArg_ParseTuple(args, ":GetConfig"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000451 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000452
Guido van Rossumd641d671997-04-03 17:06:32 +0000453 if ((par = (*func)(self->config)) == -1)
454 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000455
Guido van Rossumd641d671997-04-03 17:06:32 +0000456 return PyInt_FromLong((long) par);
Guido van Rossume3db8621991-09-09 23:33:34 +0000457}
458
Roger E. Massea2a8b271997-01-03 22:40:34 +0000459static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000460alc_setqueuesize (alcobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000461{
Guido van Rossumd641d671997-04-03 17:06:32 +0000462 return setconfig(self, args, ALsetqueuesize);
Guido van Rossume3db8621991-09-09 23:33:34 +0000463}
464
Roger E. Massea2a8b271997-01-03 22:40:34 +0000465static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000466alc_getqueuesize (alcobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000467{
Guido van Rossumd641d671997-04-03 17:06:32 +0000468 return getconfig(self, args, ALgetqueuesize);
Guido van Rossume3db8621991-09-09 23:33:34 +0000469}
470
Roger E. Massea2a8b271997-01-03 22:40:34 +0000471static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000472alc_setwidth (alcobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000473{
Guido van Rossumd641d671997-04-03 17:06:32 +0000474 return setconfig(self, args, ALsetwidth);
Guido van Rossume3db8621991-09-09 23:33:34 +0000475}
476
Roger E. Massea2a8b271997-01-03 22:40:34 +0000477static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000478alc_getwidth (alcobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000479{
Guido van Rossumd641d671997-04-03 17:06:32 +0000480 return getconfig(self, args, ALgetwidth);
Guido van Rossume3db8621991-09-09 23:33:34 +0000481}
482
Roger E. Massea2a8b271997-01-03 22:40:34 +0000483static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000484alc_getchannels (alcobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000485{
Guido van Rossumd641d671997-04-03 17:06:32 +0000486 return getconfig(self, args, ALgetchannels);
Guido van Rossume3db8621991-09-09 23:33:34 +0000487}
488
Roger E. Massea2a8b271997-01-03 22:40:34 +0000489static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000490alc_setchannels (alcobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000491{
Guido van Rossumd641d671997-04-03 17:06:32 +0000492 return setconfig(self, args, ALsetchannels);
Guido van Rossume3db8621991-09-09 23:33:34 +0000493}
494
Jack Jansene8a3c281993-02-10 14:10:56 +0000495#ifdef AL_405
496
Roger E. Massea2a8b271997-01-03 22:40:34 +0000497static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000498alc_getsampfmt (alcobject *self, PyObject *args)
Jack Jansene8a3c281993-02-10 14:10:56 +0000499{
Guido van Rossumd641d671997-04-03 17:06:32 +0000500 return getconfig(self, args, ALgetsampfmt);
Jack Jansene8a3c281993-02-10 14:10:56 +0000501}
502
Roger E. Massea2a8b271997-01-03 22:40:34 +0000503static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000504alc_setsampfmt (alcobject *self, PyObject *args)
Jack Jansene8a3c281993-02-10 14:10:56 +0000505{
Guido van Rossumd641d671997-04-03 17:06:32 +0000506 return setconfig(self, args, ALsetsampfmt);
Jack Jansene8a3c281993-02-10 14:10:56 +0000507}
508
Roger E. Massea2a8b271997-01-03 22:40:34 +0000509static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000510alc_getfloatmax(alcobject *self, PyObject *args)
Jack Jansene8a3c281993-02-10 14:10:56 +0000511{
512 double arg;
513
Guido van Rossum43713e52000-02-29 13:59:29 +0000514 if (!PyArg_ParseTuple(args, ":GetFloatMax"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000515 return 0;
516 if ((arg = ALgetfloatmax(self->config)) == 0)
517 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000518 return PyFloat_FromDouble(arg);
Jack Jansene8a3c281993-02-10 14:10:56 +0000519}
520
Roger E. Massea2a8b271997-01-03 22:40:34 +0000521static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000522alc_setfloatmax(alcobject *self, PyObject *args)
Jack Jansene8a3c281993-02-10 14:10:56 +0000523{
524 double arg;
525
Guido van Rossum43713e52000-02-29 13:59:29 +0000526 if (!PyArg_ParseTuple(args, "d:SetFloatMax", &arg))
Guido van Rossumd641d671997-04-03 17:06:32 +0000527 return 0;
528 if (ALsetfloatmax(self->config, arg) == -1)
529 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000530 Py_INCREF(Py_None);
531 return Py_None;
Jack Jansene8a3c281993-02-10 14:10:56 +0000532}
533#endif /* AL_405 */
534
Guido van Rossumd641d671997-04-03 17:06:32 +0000535static struct PyMethodDef alc_methods[] = {
536#ifdef AL_NO_ELEM /* IRIX 6 */
537 {"SetWidth", (PyCFunction)alc_SetWidth, METH_VARARGS, alc_SetWidth__doc__},
538 {"GetWidth", (PyCFunction)alc_GetWidth, METH_VARARGS, alc_GetWidth__doc__},
539 {"SetSampFmt", (PyCFunction)alc_SetSampFmt, METH_VARARGS, alc_SetSampFmt__doc__},
540 {"GetSampFmt", (PyCFunction)alc_GetSampFmt, METH_VARARGS, alc_GetSampFmt__doc__},
541 {"SetChannels", (PyCFunction)alc_SetChannels, METH_VARARGS, alc_SetChannels__doc__},
542 {"GetChannels", (PyCFunction)alc_GetChannels, METH_VARARGS, alc_GetChannels__doc__},
543 {"SetFloatMax", (PyCFunction)alc_SetFloatMax, METH_VARARGS, alc_SetFloatMax__doc__},
544 {"GetFloatMax", (PyCFunction)alc_GetFloatMax, METH_VARARGS, alc_GetFloatMax__doc__},
545 {"SetDevice", (PyCFunction)alc_SetDevice, METH_VARARGS, alc_SetDevice__doc__},
546 {"GetDevice", (PyCFunction)alc_GetDevice, METH_VARARGS, alc_GetDevice__doc__},
547 {"SetQueueSize", (PyCFunction)alc_SetQueueSize, METH_VARARGS, alc_SetQueueSize__doc__},
548 {"GetQueueSize", (PyCFunction)alc_GetQueueSize, METH_VARARGS, alc_GetQueueSize__doc__},
549#endif /* AL_NO_ELEM */
550 {"getqueuesize", (PyCFunction)alc_getqueuesize, METH_VARARGS},
551 {"setqueuesize", (PyCFunction)alc_setqueuesize, METH_VARARGS},
552 {"getwidth", (PyCFunction)alc_getwidth, METH_VARARGS},
553 {"setwidth", (PyCFunction)alc_setwidth, METH_VARARGS},
554 {"getchannels", (PyCFunction)alc_getchannels, METH_VARARGS},
555 {"setchannels", (PyCFunction)alc_setchannels, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +0000556#ifdef AL_405
Guido van Rossumd641d671997-04-03 17:06:32 +0000557 {"getsampfmt", (PyCFunction)alc_getsampfmt, METH_VARARGS},
558 {"setsampfmt", (PyCFunction)alc_setsampfmt, METH_VARARGS},
559 {"getfloatmax", (PyCFunction)alc_getfloatmax, METH_VARARGS},
560 {"setfloatmax", (PyCFunction)alc_setfloatmax, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +0000561#endif /* AL_405 */
Guido van Rossumd641d671997-04-03 17:06:32 +0000562
563 {NULL, NULL} /* sentinel */
Guido van Rossume3db8621991-09-09 23:33:34 +0000564};
565
Guido van Rossumd641d671997-04-03 17:06:32 +0000566/* ---------- */
567
568
569static PyObject *
570newalcobject(ALconfig config)
Guido van Rossume3db8621991-09-09 23:33:34 +0000571{
Guido van Rossumd641d671997-04-03 17:06:32 +0000572 alcobject *self;
573
Guido van Rossumb18618d2000-05-03 23:44:39 +0000574 self = PyObject_New(alcobject, &Alctype);
Guido van Rossumd641d671997-04-03 17:06:32 +0000575 if (self == NULL)
576 return NULL;
577 /* XXXX Add your own initializers here */
578 self->config = config;
579 return (PyObject *) self;
580}
581
582
583static void
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000584alc_dealloc(alcobject *self)
Guido van Rossumd641d671997-04-03 17:06:32 +0000585{
586 /* XXXX Add your own cleanup code here */
587#ifdef AL_NO_ELEM /* IRIX 6 */
588 (void) alFreeConfig(self->config); /* ignore errors */
589#else
590 (void) ALfreeconfig(self->config); /* ignore errors */
591#endif
Guido van Rossumb18618d2000-05-03 23:44:39 +0000592 PyObject_Del(self);
Guido van Rossume3db8621991-09-09 23:33:34 +0000593}
594
Roger E. Massea2a8b271997-01-03 22:40:34 +0000595static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000596alc_getattr(alcobject *self, char *name)
Guido van Rossume3db8621991-09-09 23:33:34 +0000597{
Guido van Rossumd641d671997-04-03 17:06:32 +0000598 /* XXXX Add your own getattr code here */
599 return Py_FindMethod(alc_methods, (PyObject *)self, name);
Guido van Rossume3db8621991-09-09 23:33:34 +0000600}
601
Guido van Rossumd641d671997-04-03 17:06:32 +0000602static char Alctype__doc__[] =
603""
604;
605
606static PyTypeObject Alctype = {
Roger E. Massea2a8b271997-01-03 22:40:34 +0000607 PyObject_HEAD_INIT(&PyType_Type)
Guido van Rossumd641d671997-04-03 17:06:32 +0000608 0, /*ob_size*/
609 "config", /*tp_name*/
610 sizeof(alcobject), /*tp_basicsize*/
611 0, /*tp_itemsize*/
Guido van Rossume3db8621991-09-09 23:33:34 +0000612 /* methods */
Guido van Rossumd641d671997-04-03 17:06:32 +0000613 (destructor)alc_dealloc, /*tp_dealloc*/
614 (printfunc)0, /*tp_print*/
615 (getattrfunc)alc_getattr, /*tp_getattr*/
616 (setattrfunc)0, /*tp_setattr*/
617 (cmpfunc)0, /*tp_compare*/
618 (reprfunc)0, /*tp_repr*/
619 0, /*tp_as_number*/
620 0, /*tp_as_sequence*/
621 0, /*tp_as_mapping*/
622 (hashfunc)0, /*tp_hash*/
623 (ternaryfunc)0, /*tp_call*/
624 (reprfunc)0, /*tp_str*/
625
626 /* Space for future expansion */
627 0L,0L,0L,0L,
628 Alctype__doc__ /* Documentation string */
Guido van Rossume3db8621991-09-09 23:33:34 +0000629};
630
Guido van Rossumd641d671997-04-03 17:06:32 +0000631/* End of code for config objects */
632/* ---------------------------------------------------------------- */
Guido van Rossume3db8621991-09-09 23:33:34 +0000633
Guido van Rossumd641d671997-04-03 17:06:32 +0000634#ifdef AL_NO_ELEM /* IRIX 6 */
Guido van Rossume3db8621991-09-09 23:33:34 +0000635
Guido van Rossumd641d671997-04-03 17:06:32 +0000636static char alp_SetConfig__doc__[] =
637"alSetConfig: set the ALconfig of an audio ALport."
638;
Guido van Rossume3db8621991-09-09 23:33:34 +0000639
Roger E. Massea2a8b271997-01-03 22:40:34 +0000640static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000641alp_SetConfig(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000642{
Guido van Rossumd641d671997-04-03 17:06:32 +0000643 alcobject *config;
Guido van Rossum43713e52000-02-29 13:59:29 +0000644 if (!PyArg_ParseTuple(args, "O!:SetConfig", &Alctype, &config))
Guido van Rossumd641d671997-04-03 17:06:32 +0000645 return NULL;
646 if (alSetConfig(self->port, config->config) < 0)
647 return NULL;
648 Py_INCREF(Py_None);
Roger E. Massea2a8b271997-01-03 22:40:34 +0000649 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +0000650}
651
Guido van Rossumd641d671997-04-03 17:06:32 +0000652
653static char alp_GetConfig__doc__[] =
654"alGetConfig: get the ALconfig of an audio ALport."
655;
656
Roger E. Massea2a8b271997-01-03 22:40:34 +0000657static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000658alp_GetConfig(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000659{
660 ALconfig config;
Guido van Rossum43713e52000-02-29 13:59:29 +0000661 if (!PyArg_ParseTuple(args, ":GetConfig"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000662 return NULL;
663 if ((config = alGetConfig(self->port)) == NULL)
664 return NULL;
665 return newalcobject(config);
666}
667
668
669static char alp_GetResource__doc__[] =
670"alGetResource: get the resource associated with an audio port."
671;
672
673static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000674alp_GetResource(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000675{
676 int resource;
677
Guido van Rossum43713e52000-02-29 13:59:29 +0000678 if (!PyArg_ParseTuple(args, ":GetResource"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000679 return NULL;
680 if ((resource = alGetResource(self->port)) == 0)
681 return NULL;
682 return PyInt_FromLong((long) resource);
683}
684
685
686static char alp_GetFD__doc__[] =
687"alGetFD: get the file descriptor for an audio port."
688;
689
690static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000691alp_GetFD(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000692{
693 int fd;
694
Guido van Rossum43713e52000-02-29 13:59:29 +0000695 if (!PyArg_ParseTuple(args, ":GetFD"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000696 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000697
Guido van Rossumd641d671997-04-03 17:06:32 +0000698 if ((fd = alGetFD(self->port)) < 0)
699 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000700
Guido van Rossumd641d671997-04-03 17:06:32 +0000701 return PyInt_FromLong((long) fd);
702}
703
704
705static char alp_GetFilled__doc__[] =
706"alGetFilled: return the number of filled sample frames in an audio port."
707;
708
709static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000710alp_GetFilled(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000711{
712 int filled;
713
Guido van Rossum43713e52000-02-29 13:59:29 +0000714 if (!PyArg_ParseTuple(args, ":GetFilled"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000715 return NULL;
716 if ((filled = alGetFilled(self->port)) < 0)
717 return NULL;
718 return PyInt_FromLong((long) filled);
719}
720
721
722static char alp_GetFillable__doc__[] =
723"alGetFillable: report the number of unfilled sample frames in an audio port."
724;
725
726static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000727alp_GetFillable(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000728{
729 int fillable;
730
Guido van Rossum43713e52000-02-29 13:59:29 +0000731 if (!PyArg_ParseTuple(args, ":GetFillable"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000732 return NULL;
733 if ((fillable = alGetFillable(self->port)) < 0)
734 return NULL;
735 return PyInt_FromLong((long) fillable);
736}
737
738
739static char alp_ReadFrames__doc__[] =
740"alReadFrames: read sample frames from an audio port."
741;
742
743static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000744alp_ReadFrames(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000745{
746 void *samples;
747 int framecount;
748 PyObject *v;
749 int size;
750 int ch;
751 ALconfig c;
752
Guido van Rossum43713e52000-02-29 13:59:29 +0000753 if (!PyArg_ParseTuple(args, "i:ReadFrames", &framecount))
Guido van Rossumd641d671997-04-03 17:06:32 +0000754 return NULL;
755 if (framecount < 0) {
756 PyErr_SetString(ErrorObject, "negative framecount");
757 return NULL;
758 }
759 c = alGetConfig(self->port);
760 switch (alGetSampFmt(c)) {
761 case AL_SAMPFMT_TWOSCOMP:
762 switch (alGetWidth(c)) {
763 case AL_SAMPLE_8:
764 size = 1;
765 break;
766 case AL_SAMPLE_16:
767 size = 2;
768 break;
769 case AL_SAMPLE_24:
770 size = 4;
771 break;
772 default:
773 PyErr_SetString(ErrorObject, "can't determine width");
774 alFreeConfig(c);
775 return NULL;
776 }
777 break;
778 case AL_SAMPFMT_FLOAT:
779 size = 4;
780 break;
781 case AL_SAMPFMT_DOUBLE:
782 size = 8;
783 break;
784 default:
785 PyErr_SetString(ErrorObject, "can't determine format");
786 alFreeConfig(c);
787 return NULL;
788 }
789 ch = alGetChannels(c);
790 alFreeConfig(c);
791 if (ch < 0) {
792 PyErr_SetString(ErrorObject, "can't determine # of channels");
793 return NULL;
794 }
795 size *= ch;
796 v = PyString_FromStringAndSize((char *) NULL, size * framecount);
797 if (v == NULL)
798 return NULL;
799
800 Py_BEGIN_ALLOW_THREADS
801 alReadFrames(self->port, (void *) PyString_AS_STRING(v), framecount);
802 Py_END_ALLOW_THREADS
803
804 return v;
805}
806
807
808static char alp_DiscardFrames__doc__[] =
809"alDiscardFrames: discard audio from an audio port."
810;
811
812static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000813alp_DiscardFrames(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000814{
815 int framecount;
816
Guido van Rossum43713e52000-02-29 13:59:29 +0000817 if (!PyArg_ParseTuple(args, "i:DiscardFrames", &framecount))
Guido van Rossumd641d671997-04-03 17:06:32 +0000818 return NULL;
819
820 Py_BEGIN_ALLOW_THREADS
821 framecount = alDiscardFrames(self->port, framecount);
822 Py_END_ALLOW_THREADS
823
824 if (framecount < 0)
825 return NULL;
826
827 return PyInt_FromLong((long) framecount);
828}
829
830
831static char alp_ZeroFrames__doc__[] =
832"alZeroFrames: write zero-valued sample frames to an audio port."
833;
834
835static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000836alp_ZeroFrames(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000837{
838 int framecount;
839
Guido van Rossum43713e52000-02-29 13:59:29 +0000840 if (!PyArg_ParseTuple(args, "i:ZeroFrames", &framecount))
Guido van Rossumd641d671997-04-03 17:06:32 +0000841 return NULL;
842
843 if (framecount < 0) {
844 PyErr_SetString(ErrorObject, "negative framecount");
845 return NULL;
846 }
847
848 Py_BEGIN_ALLOW_THREADS
849 alZeroFrames(self->port, framecount);
850 Py_END_ALLOW_THREADS
851
852 Py_INCREF(Py_None);
853 return Py_None;
854}
855
856
857static char alp_SetFillPoint__doc__[] =
858"alSetFillPoint: set low- or high-water mark for an audio port."
859;
860
861static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000862alp_SetFillPoint(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000863{
864 int fillpoint;
865
Guido van Rossum43713e52000-02-29 13:59:29 +0000866 if (!PyArg_ParseTuple(args, "i:SetFillPoint", &fillpoint))
Guido van Rossumd641d671997-04-03 17:06:32 +0000867 return NULL;
868
869 if (alSetFillPoint(self->port, fillpoint) < 0)
870 return NULL;
871
872 Py_INCREF(Py_None);
873 return Py_None;
874}
875
876
877static char alp_GetFillPoint__doc__[] =
878"alGetFillPoint: get low- or high-water mark for an audio port."
879;
880
881static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000882alp_GetFillPoint(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000883{
884 int fillpoint;
885
Guido van Rossum43713e52000-02-29 13:59:29 +0000886 if (!PyArg_ParseTuple(args, ":GetFillPoint"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000887 return NULL;
888
889 if ((fillpoint = alGetFillPoint(self->port)) < 0)
890 return NULL;
891
892 return PyInt_FromLong((long) fillpoint);
893}
894
895
896static char alp_GetFrameNumber__doc__[] =
897"alGetFrameNumber: get the absolute sample frame number associated with a port."
898;
899
900static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000901alp_GetFrameNumber(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000902{
903 stamp_t fnum;
904
Guido van Rossum43713e52000-02-29 13:59:29 +0000905 if (!PyArg_ParseTuple(args, ":GetFrameNumber"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000906 return NULL;
907
908 if (alGetFrameNumber(self->port, &fnum) < 0)
909 return NULL;
910
911 return PyLong_FromLongLong((long long) fnum);
912}
913
914
915static char alp_GetFrameTime__doc__[] =
916"alGetFrameTime: get the time at which a sample frame came in or will go out."
917;
918
919static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000920alp_GetFrameTime(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000921{
922 stamp_t fnum, time;
923 PyObject *ret, *v0, *v1;
924
Guido van Rossum43713e52000-02-29 13:59:29 +0000925 if (!PyArg_ParseTuple(args, ":GetFrameTime"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000926 return NULL;
927 if (alGetFrameTime(self->port, &fnum, &time) < 0)
928 return NULL;
929 v0 = PyLong_FromLongLong((long long) fnum);
930 v1 = PyLong_FromLongLong((long long) time);
931 if (PyErr_Occurred()) {
932 Py_XDECREF(v0);
933 Py_XDECREF(v1);
934 return NULL;
935 }
936 ret = Py_BuildValue("(OO)", v0, v1);
937 Py_DECREF(v0);
938 Py_DECREF(v1);
939 return ret;
940}
941
942
943static char alp_WriteFrames__doc__[] =
944"alWriteFrames: write sample frames to an audio port."
945;
946
947static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000948alp_WriteFrames(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000949{
950 char *samples;
951 int length;
952 int size, ch;
953 ALconfig c;
954
Guido van Rossum43713e52000-02-29 13:59:29 +0000955 if (!PyArg_ParseTuple(args, "s#:WriteFrames", &samples, &length))
Guido van Rossumd641d671997-04-03 17:06:32 +0000956 return NULL;
957 c = alGetConfig(self->port);
958 switch (alGetSampFmt(c)) {
959 case AL_SAMPFMT_TWOSCOMP:
960 switch (alGetWidth(c)) {
961 case AL_SAMPLE_8:
962 size = 1;
963 break;
964 case AL_SAMPLE_16:
965 size = 2;
966 break;
967 case AL_SAMPLE_24:
968 size = 4;
969 break;
970 default:
971 PyErr_SetString(ErrorObject, "can't determine width");
972 alFreeConfig(c);
973 return NULL;
974 }
975 break;
976 case AL_SAMPFMT_FLOAT:
977 size = 4;
978 break;
979 case AL_SAMPFMT_DOUBLE:
980 size = 8;
981 break;
982 default:
983 PyErr_SetString(ErrorObject, "can't determine format");
984 alFreeConfig(c);
985 return NULL;
986 }
987 ch = alGetChannels(c);
988 alFreeConfig(c);
989 if (ch < 0) {
990 PyErr_SetString(ErrorObject, "can't determine # of channels");
991 return NULL;
992 }
993 size *= ch;
994 if (length % size != 0) {
995 PyErr_SetString(ErrorObject,
996 "buffer length not whole number of frames");
997 return NULL;
998 }
999
1000 Py_BEGIN_ALLOW_THREADS
1001 alWriteFrames(self->port, (void *) samples, length / size);
1002 Py_END_ALLOW_THREADS
1003
1004 Py_INCREF(Py_None);
1005 return Py_None;
1006}
1007
1008
1009static char alp_ClosePort__doc__[] =
1010"alClosePort: close an audio port."
1011;
1012
1013static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001014alp_ClosePort(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001015{
Guido van Rossum43713e52000-02-29 13:59:29 +00001016 if (!PyArg_ParseTuple(args, ":ClosePort"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001017 return NULL;
1018 if (alClosePort(self->port) < 0)
1019 return NULL;
1020 self->port = NULL;
1021 Py_INCREF(Py_None);
1022 return Py_None;
1023}
1024
1025#endif /* AL_NO_ELEM */
1026
1027#ifdef OLD_INTERFACE
1028static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001029alp_closeport(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001030{
Guido van Rossum43713e52000-02-29 13:59:29 +00001031 if (!PyArg_ParseTuple(args, ":ClosePort"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001032 return NULL;
1033 if (ALcloseport(self->port) < 0)
1034 return NULL;
1035 self->port = NULL;
1036 Py_INCREF(Py_None);
1037 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +00001038}
1039
Roger E. Massea2a8b271997-01-03 22:40:34 +00001040static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001041alp_getfd(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001042{
1043 int fd;
1044
Guido van Rossum43713e52000-02-29 13:59:29 +00001045 if (!PyArg_ParseTuple(args, ":GetFD"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001046 return NULL;
1047 if ((fd = ALgetfd(self-> port)) == -1)
1048 return NULL;
1049 return PyInt_FromLong(fd);
1050}
1051
1052static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001053alp_getfilled(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001054{
1055 long count;
1056
Guido van Rossum43713e52000-02-29 13:59:29 +00001057 if (!PyArg_ParseTuple(args, ":GetFilled"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001058 return NULL;
1059 if ((count = ALgetfilled(self-> port)) == -1)
1060 return NULL;
1061 return PyInt_FromLong(count);
Guido van Rossume3db8621991-09-09 23:33:34 +00001062}
1063
Roger E. Massea2a8b271997-01-03 22:40:34 +00001064static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001065alp_getfillable(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001066{
1067 long count;
1068
Guido van Rossum43713e52000-02-29 13:59:29 +00001069 if (!PyArg_ParseTuple(args, ":GetFillable"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001070 return NULL;
1071 if ((count = ALgetfillable(self-> port)) == -1)
1072 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001073 return PyInt_FromLong (count);
Guido van Rossume3db8621991-09-09 23:33:34 +00001074}
1075
Roger E. Massea2a8b271997-01-03 22:40:34 +00001076static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001077alp_readsamps(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001078{
1079 long count;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001080 PyObject *v;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001081 ALconfig c;
Guido van Rossume3db8621991-09-09 23:33:34 +00001082 int width;
Guido van Rossumd641d671997-04-03 17:06:32 +00001083 int ret;
Guido van Rossume3db8621991-09-09 23:33:34 +00001084
Guido van Rossum43713e52000-02-29 13:59:29 +00001085 if (!PyArg_ParseTuple(args, "l:readsamps", &count))
Guido van Rossumd641d671997-04-03 17:06:32 +00001086 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001087
Guido van Rossumd641d671997-04-03 17:06:32 +00001088 if (count <= 0) {
1089 PyErr_SetString(ErrorObject, "al.readsamps : arg <= 0");
Guido van Rossume3db8621991-09-09 23:33:34 +00001090 return NULL;
1091 }
1092
Guido van Rossumd641d671997-04-03 17:06:32 +00001093 c = ALgetconfig(self->port);
Jack Jansene8a3c281993-02-10 14:10:56 +00001094#ifdef AL_405
1095 width = ALgetsampfmt(c);
Guido van Rossumd641d671997-04-03 17:06:32 +00001096 if (width == AL_SAMPFMT_FLOAT)
1097 width = sizeof(float);
1098 else if (width == AL_SAMPFMT_DOUBLE)
1099 width = sizeof(double);
Jack Jansene8a3c281993-02-10 14:10:56 +00001100 else
Guido van Rossumd641d671997-04-03 17:06:32 +00001101 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001102#else
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001103 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001104#endif /* AL_405 */
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001105 ALfreeconfig(c);
Guido van Rossumd641d671997-04-03 17:06:32 +00001106 v = PyString_FromStringAndSize((char *)NULL, width * count);
1107 if (v == NULL)
1108 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001109
Roger E. Massea2a8b271997-01-03 22:40:34 +00001110 Py_BEGIN_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001111 ret = ALreadsamps(self->port, (void *) PyString_AsString(v), count);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001112 Py_END_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001113 if (ret == -1) {
1114 Py_DECREF(v);
1115 return NULL;
1116 }
Guido van Rossume3db8621991-09-09 23:33:34 +00001117
1118 return (v);
1119}
1120
Roger E. Massea2a8b271997-01-03 22:40:34 +00001121static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001122alp_writesamps(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001123{
Guido van Rossumfc58e581992-01-27 16:45:55 +00001124 char *buf;
1125 int size, width;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001126 ALconfig c;
Guido van Rossumd641d671997-04-03 17:06:32 +00001127 int ret;
Guido van Rossume3db8621991-09-09 23:33:34 +00001128
Guido van Rossum43713e52000-02-29 13:59:29 +00001129 if (!PyArg_ParseTuple(args, "s#:writesamps", &buf, &size))
Guido van Rossumd641d671997-04-03 17:06:32 +00001130 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001131
Guido van Rossumd641d671997-04-03 17:06:32 +00001132 c = ALgetconfig(self->port);
Jack Jansene8a3c281993-02-10 14:10:56 +00001133#ifdef AL_405
1134 width = ALgetsampfmt(c);
Guido van Rossumd641d671997-04-03 17:06:32 +00001135 if (width == AL_SAMPFMT_FLOAT)
1136 width = sizeof(float);
1137 else if (width == AL_SAMPFMT_DOUBLE)
1138 width = sizeof(double);
Jack Jansene8a3c281993-02-10 14:10:56 +00001139 else
Guido van Rossumd641d671997-04-03 17:06:32 +00001140 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001141#else
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001142 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001143#endif /* AL_405 */
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001144 ALfreeconfig(c);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001145 Py_BEGIN_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001146 ret = ALwritesamps (self->port, (void *) buf, (long) size / width);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001147 Py_END_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001148 if (ret == -1)
1149 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001150
Guido van Rossumd641d671997-04-03 17:06:32 +00001151 Py_INCREF(Py_None);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001152 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +00001153}
1154
Roger E. Massea2a8b271997-01-03 22:40:34 +00001155static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001156alp_getfillpoint(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001157{
1158 long count;
1159
Guido van Rossum43713e52000-02-29 13:59:29 +00001160 if (!PyArg_ParseTuple(args, ":GetFillPoint"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001161 return NULL;
1162 if ((count = ALgetfillpoint(self->port)) == -1)
1163 return NULL;
1164 return PyInt_FromLong(count);
Guido van Rossume3db8621991-09-09 23:33:34 +00001165}
1166
Roger E. Massea2a8b271997-01-03 22:40:34 +00001167static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001168alp_setfillpoint(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001169{
1170 long count;
1171
Guido van Rossum43713e52000-02-29 13:59:29 +00001172 if (!PyArg_ParseTuple(args, "l:SetFillPoint", &count))
Guido van Rossumd641d671997-04-03 17:06:32 +00001173 return NULL;
1174 if (ALsetfillpoint(self->port, count) == -1)
1175 return NULL;
1176 Py_INCREF(Py_None);
1177 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +00001178}
1179
Roger E. Massea2a8b271997-01-03 22:40:34 +00001180static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001181alp_setconfig(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001182{
1183 alcobject *config;
1184
Guido van Rossum43713e52000-02-29 13:59:29 +00001185 if (!PyArg_ParseTuple(args, "O!:SetConfig", &Alctype, &config))
Guido van Rossumd641d671997-04-03 17:06:32 +00001186 return NULL;
1187 if (ALsetconfig(self->port, config->config) == -1)
1188 return NULL;
1189 Py_INCREF(Py_None);
1190 return Py_None;
1191}
1192
1193static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001194alp_getconfig(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001195{
1196 ALconfig config;
1197
Guido van Rossum43713e52000-02-29 13:59:29 +00001198 if (!PyArg_ParseTuple(args, ":GetConfig"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001199 return NULL;
1200 config = ALgetconfig(self->port);
1201 if (config == NULL)
1202 return NULL;
1203 return newalcobject(config);
Guido van Rossume3db8621991-09-09 23:33:34 +00001204}
1205
Jack Jansene8a3c281993-02-10 14:10:56 +00001206#ifdef AL_405
Roger E. Massea2a8b271997-01-03 22:40:34 +00001207static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001208alp_getstatus(alpobject *self, PyObject *args)
Jack Jansene8a3c281993-02-10 14:10:56 +00001209{
Roger E. Massea2a8b271997-01-03 22:40:34 +00001210 PyObject *list, *v;
Jack Jansene8a3c281993-02-10 14:10:56 +00001211 long *PVbuffer;
1212 long length;
1213 int i;
1214
Guido van Rossumd641d671997-04-03 17:06:32 +00001215 if (!PyArg_Parse(args, "O!", &PyList_Type, &list))
Jack Jansene8a3c281993-02-10 14:10:56 +00001216 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001217 length = PyList_Size(list);
1218 PVbuffer = PyMem_NEW(long, length);
Jack Jansene8a3c281993-02-10 14:10:56 +00001219 if (PVbuffer == NULL)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001220 return PyErr_NoMemory();
Jack Jansene8a3c281993-02-10 14:10:56 +00001221 for (i = 0; i < length; i++) {
Roger E. Massea2a8b271997-01-03 22:40:34 +00001222 v = PyList_GetItem(list, i);
1223 if (!PyInt_Check(v)) {
1224 PyMem_DEL(PVbuffer);
1225 PyErr_BadArgument();
Jack Jansene8a3c281993-02-10 14:10:56 +00001226 return NULL;
1227 }
Roger E. Massea2a8b271997-01-03 22:40:34 +00001228 PVbuffer[i] = PyInt_AsLong(v);
Jack Jansene8a3c281993-02-10 14:10:56 +00001229 }
1230
Guido van Rossumd641d671997-04-03 17:06:32 +00001231 if (ALgetstatus(self->port, PVbuffer, length) == -1)
1232 return NULL;
Jack Jansene8a3c281993-02-10 14:10:56 +00001233
1234 for (i = 0; i < length; i++)
Guido van Rossumd641d671997-04-03 17:06:32 +00001235 PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i]));
Jack Jansene8a3c281993-02-10 14:10:56 +00001236
Roger E. Massea2a8b271997-01-03 22:40:34 +00001237 PyMem_DEL(PVbuffer);
Jack Jansene8a3c281993-02-10 14:10:56 +00001238
Roger E. Massea2a8b271997-01-03 22:40:34 +00001239 Py_INCREF(Py_None);
1240 return Py_None;
Jack Jansene8a3c281993-02-10 14:10:56 +00001241}
1242#endif /* AL_405 */
1243
Guido van Rossumd641d671997-04-03 17:06:32 +00001244#endif /* OLD_INTERFACE */
1245
1246static struct PyMethodDef alp_methods[] = {
1247#ifdef AL_NO_ELEM /* IRIX 6 */
1248 {"SetConfig", (PyCFunction)alp_SetConfig, METH_VARARGS, alp_SetConfig__doc__},
1249 {"GetConfig", (PyCFunction)alp_GetConfig, METH_VARARGS, alp_GetConfig__doc__},
1250 {"GetResource", (PyCFunction)alp_GetResource, METH_VARARGS, alp_GetResource__doc__},
1251 {"GetFD", (PyCFunction)alp_GetFD, METH_VARARGS, alp_GetFD__doc__},
1252 {"GetFilled", (PyCFunction)alp_GetFilled, METH_VARARGS, alp_GetFilled__doc__},
1253 {"GetFillable", (PyCFunction)alp_GetFillable, METH_VARARGS, alp_GetFillable__doc__},
1254 {"ReadFrames", (PyCFunction)alp_ReadFrames, METH_VARARGS, alp_ReadFrames__doc__},
1255 {"DiscardFrames", (PyCFunction)alp_DiscardFrames, METH_VARARGS, alp_DiscardFrames__doc__},
1256 {"ZeroFrames", (PyCFunction)alp_ZeroFrames, METH_VARARGS, alp_ZeroFrames__doc__},
1257 {"SetFillPoint", (PyCFunction)alp_SetFillPoint, METH_VARARGS, alp_SetFillPoint__doc__},
1258 {"GetFillPoint", (PyCFunction)alp_GetFillPoint, METH_VARARGS, alp_GetFillPoint__doc__},
1259 {"GetFrameNumber", (PyCFunction)alp_GetFrameNumber, METH_VARARGS, alp_GetFrameNumber__doc__},
1260 {"GetFrameTime", (PyCFunction)alp_GetFrameTime, METH_VARARGS, alp_GetFrameTime__doc__},
1261 {"WriteFrames", (PyCFunction)alp_WriteFrames, METH_VARARGS, alp_WriteFrames__doc__},
1262 {"ClosePort", (PyCFunction)alp_ClosePort, METH_VARARGS, alp_ClosePort__doc__},
1263#endif /* AL_NO_ELEM */
1264#ifdef OLD_INTERFACE
1265 {"closeport", (PyCFunction)alp_closeport, METH_VARARGS},
1266 {"getfd", (PyCFunction)alp_getfd, METH_VARARGS},
1267 {"fileno", (PyCFunction)alp_getfd, METH_VARARGS},
1268 {"getfilled", (PyCFunction)alp_getfilled, METH_VARARGS},
1269 {"getfillable", (PyCFunction)alp_getfillable, METH_VARARGS},
1270 {"readsamps", (PyCFunction)alp_readsamps, METH_VARARGS},
1271 {"writesamps", (PyCFunction)alp_writesamps, METH_VARARGS},
1272 {"setfillpoint", (PyCFunction)alp_setfillpoint, METH_VARARGS},
1273 {"getfillpoint", (PyCFunction)alp_getfillpoint, METH_VARARGS},
1274 {"setconfig", (PyCFunction)alp_setconfig, METH_VARARGS},
1275 {"getconfig", (PyCFunction)alp_getconfig, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +00001276#ifdef AL_405
Guido van Rossumd641d671997-04-03 17:06:32 +00001277 {"getstatus", (PyCFunction)alp_getstatus, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +00001278#endif /* AL_405 */
Guido van Rossumd641d671997-04-03 17:06:32 +00001279#endif /* OLD_INTERFACE */
1280
1281 {NULL, NULL} /* sentinel */
Guido van Rossume3db8621991-09-09 23:33:34 +00001282};
1283
Guido van Rossumd641d671997-04-03 17:06:32 +00001284/* ---------- */
1285
1286
1287static PyObject *
1288newalpobject(ALport port)
1289{
1290 alpobject *self;
1291
Guido van Rossumb18618d2000-05-03 23:44:39 +00001292 self = PyObject_New(alpobject, &Alptype);
Guido van Rossumd641d671997-04-03 17:06:32 +00001293 if (self == NULL)
1294 return NULL;
1295 /* XXXX Add your own initializers here */
1296 self->port = port;
1297 return (PyObject *) self;
1298}
1299
1300
Guido van Rossume3db8621991-09-09 23:33:34 +00001301static void
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001302alp_dealloc(alpobject *self)
Guido van Rossume3db8621991-09-09 23:33:34 +00001303{
Guido van Rossumd641d671997-04-03 17:06:32 +00001304 /* XXXX Add your own cleanup code here */
1305 if (self->port) {
1306#ifdef AL_NO_ELEM /* IRIX 6 */
1307 alClosePort(self->port);
1308#else
1309 ALcloseport(self->port);
1310#endif
1311 }
Guido van Rossumb18618d2000-05-03 23:44:39 +00001312 PyObject_Del(self);
Guido van Rossume3db8621991-09-09 23:33:34 +00001313}
1314
Roger E. Massea2a8b271997-01-03 22:40:34 +00001315static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001316alp_getattr(alpobject *self, char *name)
Guido van Rossume3db8621991-09-09 23:33:34 +00001317{
Guido van Rossumd641d671997-04-03 17:06:32 +00001318 /* XXXX Add your own getattr code here */
1319 if (self->port == NULL) {
1320 PyErr_SetString(ErrorObject, "port already closed");
1321 return NULL;
1322 }
1323 return Py_FindMethod(alp_methods, (PyObject *)self, name);
Guido van Rossume3db8621991-09-09 23:33:34 +00001324}
1325
Guido van Rossumd641d671997-04-03 17:06:32 +00001326static char Alptype__doc__[] =
1327""
1328;
1329
1330static PyTypeObject Alptype = {
Roger E. Massea2a8b271997-01-03 22:40:34 +00001331 PyObject_HEAD_INIT(&PyType_Type)
Guido van Rossumd641d671997-04-03 17:06:32 +00001332 0, /*ob_size*/
Guido van Rossume3db8621991-09-09 23:33:34 +00001333 "port", /*tp_name*/
Guido van Rossumd641d671997-04-03 17:06:32 +00001334 sizeof(alpobject), /*tp_basicsize*/
1335 0, /*tp_itemsize*/
Guido van Rossume3db8621991-09-09 23:33:34 +00001336 /* methods */
Guido van Rossumd641d671997-04-03 17:06:32 +00001337 (destructor)alp_dealloc, /*tp_dealloc*/
1338 (printfunc)0, /*tp_print*/
1339 (getattrfunc)alp_getattr, /*tp_getattr*/
1340 (setattrfunc)0, /*tp_setattr*/
1341 (cmpfunc)0, /*tp_compare*/
1342 (reprfunc)0, /*tp_repr*/
1343 0, /*tp_as_number*/
1344 0, /*tp_as_sequence*/
1345 0, /*tp_as_mapping*/
1346 (hashfunc)0, /*tp_hash*/
1347 (ternaryfunc)0, /*tp_call*/
1348 (reprfunc)0, /*tp_str*/
1349
1350 /* Space for future expansion */
1351 0L,0L,0L,0L,
1352 Alptype__doc__ /* Documentation string */
Guido van Rossume3db8621991-09-09 23:33:34 +00001353};
1354
Guido van Rossumd641d671997-04-03 17:06:32 +00001355/* End of code for port objects */
1356/* -------------------------------------------------------- */
1357
1358
1359#ifdef AL_NO_ELEM /* IRIX 6 */
1360
1361static char al_NewConfig__doc__[] =
1362"alNewConfig: create and initialize an audio ALconfig structure."
1363;
1364
Roger E. Massea2a8b271997-01-03 22:40:34 +00001365static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001366al_NewConfig(PyObject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001367{
Guido van Rossumd641d671997-04-03 17:06:32 +00001368 ALconfig config;
1369
Guido van Rossum43713e52000-02-29 13:59:29 +00001370 if (!PyArg_ParseTuple(args, ":NewConfig"))
Guido van Rossume3db8621991-09-09 23:33:34 +00001371 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001372 if ((config = alNewConfig()) == NULL)
1373 return NULL;
1374 return newalcobject(config);
Guido van Rossume3db8621991-09-09 23:33:34 +00001375}
1376
Guido van Rossumd641d671997-04-03 17:06:32 +00001377static char al_OpenPort__doc__[] =
1378"alOpenPort: open an audio port."
1379;
Guido van Rossume3db8621991-09-09 23:33:34 +00001380
Roger E. Massea2a8b271997-01-03 22:40:34 +00001381static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001382al_OpenPort(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001383{
1384 ALport port;
1385 char *name, *dir;
1386 alcobject *config = NULL;
1387
Guido van Rossum43713e52000-02-29 13:59:29 +00001388 if (!PyArg_ParseTuple(args, "ss|O!:OpenPort", &name, &dir, &Alctype, &config))
Guido van Rossumd641d671997-04-03 17:06:32 +00001389 return NULL;
1390 if ((port = alOpenPort(name, dir, config ? config->config : NULL)) == NULL)
1391 return NULL;
1392 return newalpobject(port);
1393}
1394
1395static char al_Connect__doc__[] =
1396"alConnect: connect two audio I/O resources."
1397;
1398
1399static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001400al_Connect(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001401{
1402 int source, dest, nprops = 0, id, i;
1403 ALpv *props = NULL;
1404 ALparamInfo *propinfo = NULL;
1405 PyObject *propobj = NULL;
1406
Guido van Rossum43713e52000-02-29 13:59:29 +00001407 if (!PyArg_ParseTuple(args, "ii|O!:Connect", &source, &dest, &PyList_Type, &propobj))
Guido van Rossumd641d671997-04-03 17:06:32 +00001408 return NULL;
1409 if (propobj != NULL) {
1410 nprops = python2params(source, dest, propobj, &props, &propinfo);
1411 if (nprops < 0)
1412 return NULL;
1413 }
1414
1415 id = alConnect(source, dest, props, nprops);
1416
1417 if (props) {
1418 for (i = 0; i < nprops; i++) {
1419 switch (propinfo[i].valueType) {
1420 case AL_SET_VAL:
1421 case AL_VECTOR_VAL:
1422 PyMem_DEL(props[i].value.ptr);
1423 break;
1424 }
1425 }
1426 PyMem_DEL(props);
1427 PyMem_DEL(propinfo);
1428 }
1429
1430 if (id < 0)
1431 return NULL;
1432 return PyInt_FromLong((long) id);
1433}
1434
1435static char al_Disconnect__doc__[] =
1436"alDisconnect: delete a connection between two audio I/O resources."
1437;
1438
1439static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001440al_Disconnect(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001441{
1442 int res;
1443
Guido van Rossum43713e52000-02-29 13:59:29 +00001444 if (!PyArg_ParseTuple(args, "i:Disconnect", &res))
Guido van Rossumd641d671997-04-03 17:06:32 +00001445 return NULL;
1446 if (alDisconnect(res) < 0)
1447 return NULL;
1448 Py_INCREF(Py_None);
1449 return Py_None;
1450}
1451
1452static char al_GetParams__doc__[] =
1453"alGetParams: get the values of audio resource parameters."
1454;
1455
1456static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001457al_GetParams(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001458{
1459 int resource;
1460 PyObject *pvslist, *item = NULL, *v = NULL;
1461 ALpv *pvs;
1462 int i, j, npvs;
1463 ALparamInfo *pinfo;
1464
Guido van Rossum43713e52000-02-29 13:59:29 +00001465 if (!PyArg_ParseTuple(args, "iO!:GetParams", &resource, &PyList_Type, &pvslist))
Guido van Rossumd641d671997-04-03 17:06:32 +00001466 return NULL;
1467 npvs = PyList_Size(pvslist);
1468 pvs = PyMem_NEW(ALpv, npvs);
1469 pinfo = PyMem_NEW(ALparamInfo, npvs);
1470 for (i = 0; i < npvs; i++) {
1471 item = PyList_GetItem(pvslist, i);
1472 if (!PyInt_Check(item)) {
1473 item = NULL;
1474 PyErr_SetString(ErrorObject, "list of integers expected");
1475 goto error;
1476 }
1477 pvs[i].param = (int) PyInt_AsLong(item);
1478 item = NULL; /* not needed anymore */
1479 if (alGetParamInfo(resource, pvs[i].param, &pinfo[i]) < 0)
1480 goto error;
1481 switch (pinfo[i].valueType) {
1482 case AL_NO_VAL:
1483 break;
1484 case AL_MATRIX_VAL:
1485 pinfo[i].maxElems *= pinfo[i].maxElems2;
1486 /* fall through */
1487 case AL_STRING_VAL:
1488 case AL_SET_VAL:
1489 case AL_VECTOR_VAL:
1490 switch (pinfo[i].elementType) {
1491 case AL_INT32_ELEM:
1492 case AL_RESOURCE_ELEM:
1493 case AL_ENUM_ELEM:
1494 pvs[i].value.ptr = PyMem_NEW(int, pinfo[i].maxElems);
1495 pvs[i].sizeIn = pinfo[i].maxElems;
1496 break;
1497 case AL_INT64_ELEM:
1498 case AL_FIXED_ELEM:
1499 pvs[i].value.ptr = PyMem_NEW(long long, pinfo[i].maxElems);
1500 pvs[i].sizeIn = pinfo[i].maxElems;
1501 break;
1502 case AL_CHAR_ELEM:
1503 pvs[i].value.ptr = PyMem_NEW(char, 32);
1504 pvs[i].sizeIn = 32;
1505 break;
1506 case AL_NO_ELEM:
1507 case AL_PTR_ELEM:
1508 default:
1509 PyErr_SetString(ErrorObject, "internal error");
1510 goto error;
1511 }
1512 break;
1513 case AL_SCALAR_VAL:
1514 break;
1515 default:
1516 PyErr_SetString(ErrorObject, "internal error");
1517 goto error;
1518 }
1519 if (pinfo[i].valueType == AL_MATRIX_VAL) {
1520 pinfo[i].maxElems /= pinfo[i].maxElems2;
1521 pvs[i].sizeIn /= pinfo[i].maxElems2;
1522 pvs[i].size2In = pinfo[i].maxElems2;
1523 }
1524 }
1525 if (alGetParams(resource, pvs, npvs) < 0)
1526 goto error;
1527 v = PyList_New(npvs);
1528 for (i = 0; i < npvs; i++) {
1529 if (pvs[i].sizeOut < 0) {
1530 char buf[32];
1531 sprintf(buf, "problem with param %d", i);
1532 PyErr_SetString(ErrorObject, buf);
1533 goto error;
1534 }
1535 switch (pinfo[i].valueType) {
1536 case AL_NO_VAL:
1537 item = Py_None;
1538 Py_INCREF(item);
1539 break;
1540 case AL_STRING_VAL:
1541 item = PyString_FromString(pvs[i].value.ptr);
1542 PyMem_DEL(pvs[i].value.ptr);
1543 break;
1544 case AL_MATRIX_VAL:
1545 /* XXXX this is not right */
1546 pvs[i].sizeOut *= pvs[i].size2Out;
1547 /* fall through */
1548 case AL_SET_VAL:
1549 case AL_VECTOR_VAL:
1550 item = PyList_New(pvs[i].sizeOut);
1551 for (j = 0; j < pvs[i].sizeOut; j++) {
1552 switch (pinfo[i].elementType) {
1553 case AL_INT32_ELEM:
1554 case AL_RESOURCE_ELEM:
1555 case AL_ENUM_ELEM:
1556 PyList_SetItem(item, j, PyInt_FromLong((long) ((int *) pvs[i].value.ptr)[j]));
1557 break;
1558 case AL_INT64_ELEM:
1559 PyList_SetItem(item, j, PyLong_FromLongLong(((long long *) pvs[i].value.ptr)[j]));
1560 break;
1561 case AL_FIXED_ELEM:
1562 PyList_SetItem(item, j, PyFloat_FromDouble(alFixedToDouble(((long long *) pvs[i].value.ptr)[j])));
1563 break;
1564 default:
1565 PyErr_SetString(ErrorObject, "internal error");
1566 goto error;
1567 }
1568 }
1569 PyMem_DEL(pvs[i].value.ptr);
1570 break;
1571 case AL_SCALAR_VAL:
1572 item = param2python(resource, pvs[i].param, pvs[i].value, &pinfo[i]);
1573 break;
1574 }
1575 if (PyErr_Occurred() ||
1576 PyList_SetItem(v, i, Py_BuildValue("(iO)", pvs[i].param,
1577 item)) < 0 ||
1578 PyErr_Occurred())
1579 goto error;
1580 Py_DECREF(item);
1581 }
1582 PyMem_DEL(pvs);
1583 PyMem_DEL(pinfo);
1584 return v;
1585
1586 error:
1587 Py_XDECREF(v);
1588 Py_XDECREF(item);
1589 if (pvs)
1590 PyMem_DEL(pvs);
1591 if (pinfo)
1592 PyMem_DEL(pinfo);
1593 return NULL;
1594}
1595
1596static char al_SetParams__doc__[] =
1597"alSetParams: set the values of audio resource parameters."
1598;
1599
1600static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001601al_SetParams(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001602{
1603 int resource;
1604 PyObject *pvslist, *item;
1605 ALpv *pvs;
1606 ALparamInfo *pinfo;
1607 int npvs, i;
1608
Guido van Rossum43713e52000-02-29 13:59:29 +00001609 if (!PyArg_ParseTuple(args, "iO!:SetParams", &resource, &PyList_Type, &pvslist))
Guido van Rossumd641d671997-04-03 17:06:32 +00001610 return NULL;
1611 npvs = python2params(resource, -1, pvslist, &pvs, &pinfo);
1612 if (npvs < 0)
1613 return NULL;
1614
1615 if (alSetParams(resource, pvs, npvs) < 0)
1616 goto error;
1617
1618 /* cleanup */
1619 for (i = 0; i < npvs; i++) {
1620 switch (pinfo[i].valueType) {
1621 case AL_SET_VAL:
1622 case AL_VECTOR_VAL:
1623 PyMem_DEL(pvs[i].value.ptr);
1624 break;
1625 }
1626 }
1627 PyMem_DEL(pvs);
1628 PyMem_DEL(pinfo);
1629
1630 Py_INCREF(Py_None);
1631 return Py_None;
1632
1633 error:
1634 /* XXXX we should clean up everything */
1635 if (pvs)
1636 PyMem_DEL(pvs);
1637 if (pinfo)
1638 PyMem_DEL(pinfo);
1639 return NULL;
1640}
1641
1642static char al_QueryValues__doc__[] =
1643"alQueryValues: get the set of possible values for a parameter."
1644;
1645
1646static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001647al_QueryValues(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001648{
1649 int resource, param;
1650 ALvalue *return_set = NULL;
1651 int setsize = 32, qualsize = 0, nvals, i;
1652 ALpv *quals = NULL;
1653 ALparamInfo pinfo;
1654 ALparamInfo *qualinfo = NULL;
1655 PyObject *qualobj = NULL;
1656 PyObject *res = NULL, *item;
1657
Guido van Rossum43713e52000-02-29 13:59:29 +00001658 if (!PyArg_ParseTuple(args, "ii|O!:QueryValues", &resource, &param,
Guido van Rossumd641d671997-04-03 17:06:32 +00001659 &PyList_Type, &qualobj))
1660 return NULL;
1661 if (qualobj != NULL) {
1662 qualsize = python2params(resource, param, qualobj, &quals, &qualinfo);
1663 if (qualsize < 0)
1664 return NULL;
1665 }
1666 setsize = 32;
1667 return_set = PyMem_NEW(ALvalue, setsize);
1668 if (return_set == NULL) {
1669 PyErr_NoMemory();
1670 goto cleanup;
1671 }
1672
1673 retry:
1674 nvals = alQueryValues(resource, param, return_set, setsize, quals, qualsize);
1675 if (nvals < 0)
1676 goto cleanup;
1677 if (nvals > setsize) {
1678 setsize = nvals;
1679 PyMem_RESIZE(return_set, ALvalue, setsize);
1680 if (return_set == NULL) {
1681 PyErr_NoMemory();
1682 goto cleanup;
1683 }
1684 goto retry;
1685 }
1686
1687 if (alGetParamInfo(resource, param, &pinfo) < 0)
1688 goto cleanup;
1689
1690 res = PyList_New(nvals);
1691 if (res == NULL)
1692 goto cleanup;
1693 for (i = 0; i < nvals; i++) {
1694 item = param2python(resource, param, return_set[i], &pinfo);
1695 if (item == NULL ||
1696 PyList_SetItem(res, i, item) < 0) {
1697 Py_DECREF(res);
1698 res = NULL;
1699 goto cleanup;
1700 }
1701 }
1702
1703 cleanup:
1704 if (return_set)
1705 PyMem_DEL(return_set);
1706 if (quals) {
1707 for (i = 0; i < qualsize; i++) {
1708 switch (qualinfo[i].valueType) {
1709 case AL_SET_VAL:
1710 case AL_VECTOR_VAL:
1711 PyMem_DEL(quals[i].value.ptr);
1712 break;
1713 }
1714 }
1715 PyMem_DEL(quals);
1716 PyMem_DEL(qualinfo);
1717 }
1718
1719 return res;
1720}
1721
1722static char al_GetParamInfo__doc__[] =
1723"alGetParamInfo: get information about a parameter on a particular audio resource."
1724;
1725
1726static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001727al_GetParamInfo(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001728{
1729 int res, param;
1730 ALparamInfo pinfo;
1731 PyObject *v, *item;;
1732
Guido van Rossum43713e52000-02-29 13:59:29 +00001733 if (!PyArg_ParseTuple(args, "ii:GetParamInfo", &res, &param))
Guido van Rossumd641d671997-04-03 17:06:32 +00001734 return NULL;
1735 if (alGetParamInfo(res, param, &pinfo) < 0)
1736 return NULL;
1737 v = PyDict_New();
1738
1739 item = PyInt_FromLong((long) pinfo.resource);
1740 PyDict_SetItemString(v, "resource", item);
1741 Py_DECREF(item);
1742
1743 item = PyInt_FromLong((long) pinfo.param);
1744 PyDict_SetItemString(v, "param", item);
1745 Py_DECREF(item);
1746
1747 item = PyInt_FromLong((long) pinfo.valueType);
1748 PyDict_SetItemString(v, "valueType", item);
1749 Py_DECREF(item);
1750
1751 if (pinfo.valueType != AL_NO_VAL && pinfo.valueType != AL_SCALAR_VAL) {
1752 /* multiple values */
1753 item = PyInt_FromLong((long) pinfo.maxElems);
1754 PyDict_SetItemString(v, "maxElems", item);
1755 Py_DECREF(item);
1756
1757 if (pinfo.valueType == AL_MATRIX_VAL) {
1758 /* 2 dimensional */
1759 item = PyInt_FromLong((long) pinfo.maxElems2);
1760 PyDict_SetItemString(v, "maxElems2", item);
1761 Py_DECREF(item);
1762 }
1763 }
1764
1765 item = PyInt_FromLong((long) pinfo.elementType);
1766 PyDict_SetItemString(v, "elementType", item);
1767 Py_DECREF(item);
1768
1769 item = PyString_FromString(pinfo.name);
1770 PyDict_SetItemString(v, "name", item);
1771 Py_DECREF(item);
1772
1773 item = param2python(res, param, pinfo.initial, &pinfo);
1774 PyDict_SetItemString(v, "initial", item);
1775 Py_DECREF(item);
1776
1777 if (pinfo.elementType != AL_ENUM_ELEM &&
1778 pinfo.elementType != AL_RESOURCE_ELEM &&
1779 pinfo.elementType != AL_CHAR_ELEM) {
1780 /* range param */
1781 item = param2python(res, param, pinfo.min, &pinfo);
1782 PyDict_SetItemString(v, "min", item);
1783 Py_DECREF(item);
1784
1785 item = param2python(res, param, pinfo.max, &pinfo);
1786 PyDict_SetItemString(v, "max", item);
1787 Py_DECREF(item);
1788
1789 item = param2python(res, param, pinfo.minDelta, &pinfo);
1790 PyDict_SetItemString(v, "minDelta", item);
1791 Py_DECREF(item);
1792
1793 item = param2python(res, param, pinfo.maxDelta, &pinfo);
1794 PyDict_SetItemString(v, "maxDelta", item);
1795 Py_DECREF(item);
1796
1797 item = PyInt_FromLong((long) pinfo.specialVals);
1798 PyDict_SetItemString(v, "specialVals", item);
1799 Py_DECREF(item);
1800 }
1801
1802 return v;
1803}
1804
1805static char al_GetResourceByName__doc__[] =
1806"alGetResourceByName: find an audio resource by name."
1807;
1808
1809static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001810al_GetResourceByName(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001811{
1812 int res, start_res, type;
1813 char *name;
1814
Guido van Rossum43713e52000-02-29 13:59:29 +00001815 if (!PyArg_ParseTuple(args, "isi:GetResourceByName", &start_res, &name, &type))
Guido van Rossumd641d671997-04-03 17:06:32 +00001816 return NULL;
1817 if ((res = alGetResourceByName(start_res, name, type)) == 0)
1818 return NULL;
1819 return PyInt_FromLong((long) res);
1820}
1821
1822static char al_IsSubtype__doc__[] =
1823"alIsSubtype: indicate if one resource type is a subtype of another."
1824;
1825
1826static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001827al_IsSubtype(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001828{
1829 int type, subtype;
1830
Guido van Rossum43713e52000-02-29 13:59:29 +00001831 if (!PyArg_ParseTuple(args, "ii:IsSubtype", &type, &subtype))
Guido van Rossumd641d671997-04-03 17:06:32 +00001832 return NULL;
1833 return PyInt_FromLong((long) alIsSubtype(type, subtype));
1834}
1835
1836static char al_SetErrorHandler__doc__[] =
1837""
1838;
1839
1840static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001841al_SetErrorHandler(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001842{
1843
Guido van Rossum43713e52000-02-29 13:59:29 +00001844 if (!PyArg_ParseTuple(args, ":SetErrorHandler"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001845 return NULL;
1846 Py_INCREF(Py_None);
1847 return Py_None;
1848}
1849
1850#endif /* AL_NO_ELEM */
1851
1852#ifdef OLD_INTERFACE
1853
1854static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001855al_openport(PyObject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001856{
Guido van Rossumfc58e581992-01-27 16:45:55 +00001857 char *name, *dir;
Guido van Rossume3db8621991-09-09 23:33:34 +00001858 ALport port;
Guido van Rossumd641d671997-04-03 17:06:32 +00001859 alcobject *config = NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001860
Guido van Rossum43713e52000-02-29 13:59:29 +00001861 if (!PyArg_ParseTuple(args, "ss|O!:OpenPort", &name, &dir, &Alctype, &config))
Guido van Rossumc0aab891991-10-20 20:10:46 +00001862 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001863 if ((port = ALopenport(name, dir, config ? config->config : NULL)) == NULL)
Guido van Rossume3db8621991-09-09 23:33:34 +00001864 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001865 return newalpobject(port);
Guido van Rossume3db8621991-09-09 23:33:34 +00001866}
1867
Roger E. Massea2a8b271997-01-03 22:40:34 +00001868static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001869al_newconfig(PyObject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001870{
1871 ALconfig config;
1872
Guido van Rossum43713e52000-02-29 13:59:29 +00001873 if (!PyArg_ParseTuple(args, ":NewConfig"))
Guido van Rossumc0aab891991-10-20 20:10:46 +00001874 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001875 if ((config = ALnewconfig ()) == NULL)
1876 return NULL;
1877 return newalcobject(config);
Guido van Rossume3db8621991-09-09 23:33:34 +00001878}
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001879
Roger E. Massea2a8b271997-01-03 22:40:34 +00001880static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001881al_queryparams(PyObject *self, PyObject *args)
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001882{
1883 long device;
1884 long length;
1885 long *PVbuffer;
1886 long PVdummy[2];
Guido van Rossumd641d671997-04-03 17:06:32 +00001887 PyObject *v = NULL;
1888 int i;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001889
Guido van Rossum43713e52000-02-29 13:59:29 +00001890 if (!PyArg_ParseTuple(args, "l:queryparams", &device))
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001891 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001892 if ((length = ALqueryparams(device, PVdummy, 2L)) == -1)
1893 return NULL;
1894 if ((PVbuffer = PyMem_NEW(long, length)) == NULL)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001895 return PyErr_NoMemory();
Guido van Rossumd641d671997-04-03 17:06:32 +00001896 if (ALqueryparams(device, PVbuffer, length) >= 0 &&
1897 (v = PyList_New((int)length)) != NULL) {
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001898 for (i = 0; i < length; i++)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001899 PyList_SetItem(v, i, PyInt_FromLong(PVbuffer[i]));
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001900 }
Roger E. Massea2a8b271997-01-03 22:40:34 +00001901 PyMem_DEL(PVbuffer);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001902 return v;
1903}
1904
Roger E. Massea2a8b271997-01-03 22:40:34 +00001905static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001906doParams(PyObject *args, int (*func)(long, long *, long), int modified)
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001907{
1908 long device;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001909 PyObject *list, *v;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001910 long *PVbuffer;
1911 long length;
1912 int i;
Guido van Rossume3db8621991-09-09 23:33:34 +00001913
Guido van Rossumd641d671997-04-03 17:06:32 +00001914 if (!PyArg_ParseTuple(args, "lO!", &device, &PyList_Type, &list))
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001915 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001916 length = PyList_Size(list);
1917 PVbuffer = PyMem_NEW(long, length);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001918 if (PVbuffer == NULL)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001919 return PyErr_NoMemory();
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001920 for (i = 0; i < length; i++) {
Roger E. Massea2a8b271997-01-03 22:40:34 +00001921 v = PyList_GetItem(list, i);
1922 if (!PyInt_Check(v)) {
1923 PyMem_DEL(PVbuffer);
1924 PyErr_BadArgument();
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001925 return NULL;
1926 }
Roger E. Massea2a8b271997-01-03 22:40:34 +00001927 PVbuffer[i] = PyInt_AsLong(v);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001928 }
1929
Guido van Rossumd641d671997-04-03 17:06:32 +00001930 if ((*func)(device, PVbuffer, length) == -1) {
1931 PyMem_DEL(PVbuffer);
1932 return NULL;
1933 }
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001934
1935 if (modified) {
1936 for (i = 0; i < length; i++)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001937 PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i]));
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001938 }
1939
Roger E. Massea2a8b271997-01-03 22:40:34 +00001940 PyMem_DEL(PVbuffer);
Guido van Rossumc0aab891991-10-20 20:10:46 +00001941
Roger E. Massea2a8b271997-01-03 22:40:34 +00001942 Py_INCREF(Py_None);
1943 return Py_None;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001944}
1945
Roger E. Massea2a8b271997-01-03 22:40:34 +00001946static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001947al_getparams(PyObject *self, PyObject *args)
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001948{
1949 return doParams(args, ALgetparams, 1);
1950}
1951
Roger E. Massea2a8b271997-01-03 22:40:34 +00001952static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001953al_setparams(PyObject *self, PyObject *args)
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001954{
1955 return doParams(args, ALsetparams, 0);
1956}
1957
Roger E. Massea2a8b271997-01-03 22:40:34 +00001958static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001959al_getname(PyObject *self, PyObject *args)
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001960{
1961 long device, descriptor;
1962 char *name;
Guido van Rossumd641d671997-04-03 17:06:32 +00001963
Guido van Rossum43713e52000-02-29 13:59:29 +00001964 if (!PyArg_ParseTuple(args, "ll:getname", &device, &descriptor))
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001965 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001966 if ((name = ALgetname(device, descriptor)) == NULL)
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001967 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001968 return PyString_FromString(name);
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001969}
1970
Roger E. Massea2a8b271997-01-03 22:40:34 +00001971static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001972al_getdefault(PyObject *self, PyObject *args)
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001973{
1974 long device, descriptor, value;
Guido van Rossumd641d671997-04-03 17:06:32 +00001975
Guido van Rossum43713e52000-02-29 13:59:29 +00001976 if (!PyArg_ParseTuple(args, "ll:getdefault", &device, &descriptor))
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001977 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001978 if ((value = ALgetdefault(device, descriptor)) == -1)
1979 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001980 return PyLong_FromLong(value);
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001981}
1982
Roger E. Massea2a8b271997-01-03 22:40:34 +00001983static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001984al_getminmax(PyObject *self, PyObject *args)
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001985{
1986 long device, descriptor, min, max;
Guido van Rossumd641d671997-04-03 17:06:32 +00001987
Guido van Rossum43713e52000-02-29 13:59:29 +00001988 if (!PyArg_ParseTuple(args, "ll:getminmax", &device, &descriptor))
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001989 return NULL;
1990 min = -1;
1991 max = -1;
Guido van Rossumd641d671997-04-03 17:06:32 +00001992 if (ALgetminmax(device, descriptor, &min, &max) == -1)
1993 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001994 return Py_BuildValue("ll", min, max);
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001995}
1996
Guido van Rossumd641d671997-04-03 17:06:32 +00001997#endif /* OLD_INTERFACE */
1998
1999/* List of methods defined in the module */
2000
2001static struct PyMethodDef al_methods[] = {
2002#ifdef AL_NO_ELEM /* IRIX 6 */
2003 {"NewConfig", (PyCFunction)al_NewConfig, METH_VARARGS, al_NewConfig__doc__},
2004 {"OpenPort", (PyCFunction)al_OpenPort, METH_VARARGS, al_OpenPort__doc__},
2005 {"Connect", (PyCFunction)al_Connect, METH_VARARGS, al_Connect__doc__},
2006 {"Disconnect", (PyCFunction)al_Disconnect, METH_VARARGS, al_Disconnect__doc__},
2007 {"GetParams", (PyCFunction)al_GetParams, METH_VARARGS, al_GetParams__doc__},
2008 {"SetParams", (PyCFunction)al_SetParams, METH_VARARGS, al_SetParams__doc__},
2009 {"QueryValues", (PyCFunction)al_QueryValues, METH_VARARGS, al_QueryValues__doc__},
2010 {"GetParamInfo", (PyCFunction)al_GetParamInfo, METH_VARARGS, al_GetParamInfo__doc__},
2011 {"GetResourceByName", (PyCFunction)al_GetResourceByName, METH_VARARGS, al_GetResourceByName__doc__},
2012 {"IsSubtype", (PyCFunction)al_IsSubtype, METH_VARARGS, al_IsSubtype__doc__},
2013#if 0
2014 /* this one not supported */
2015 {"SetErrorHandler", (PyCFunction)al_SetErrorHandler, METH_VARARGS, al_SetErrorHandler__doc__},
2016#endif
2017#endif /* AL_NO_ELEM */
2018#ifdef OLD_INTERFACE
2019 {"openport", (PyCFunction)al_openport, METH_VARARGS},
2020 {"newconfig", (PyCFunction)al_newconfig, METH_VARARGS},
2021 {"queryparams", (PyCFunction)al_queryparams, METH_VARARGS},
2022 {"getparams", (PyCFunction)al_getparams, METH_VARARGS},
2023 {"setparams", (PyCFunction)al_setparams, METH_VARARGS},
2024 {"getname", (PyCFunction)al_getname, METH_VARARGS},
2025 {"getdefault", (PyCFunction)al_getdefault, METH_VARARGS},
2026 {"getminmax", (PyCFunction)al_getminmax, METH_VARARGS},
2027#endif /* OLD_INTERFACE */
2028
2029 {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
Guido van Rossume3db8621991-09-09 23:33:34 +00002030};
2031
Guido van Rossumd641d671997-04-03 17:06:32 +00002032
2033/* Initialization function for the module (*must* be called inital) */
2034
2035static char al_module_documentation[] =
2036""
2037;
2038
Guido van Rossume3db8621991-09-09 23:33:34 +00002039void
2040inital()
2041{
Guido van Rossumd641d671997-04-03 17:06:32 +00002042 PyObject *m, *d, *x;
Guido van Rossume3db8621991-09-09 23:33:34 +00002043
Guido van Rossumd641d671997-04-03 17:06:32 +00002044 /* Create the module and add the functions */
2045 m = Py_InitModule4("al", al_methods,
2046 al_module_documentation,
2047 (PyObject*)NULL,PYTHON_API_VERSION);
2048
2049 /* Add some symbolic constants to the module */
2050 d = PyModule_GetDict(m);
Fred Drake589c35b2000-07-06 19:38:49 +00002051 ErrorObject = PyErr_NewException("al.error", NULL, NULL);
Guido van Rossumd641d671997-04-03 17:06:32 +00002052 PyDict_SetItemString(d, "error", ErrorObject);
2053
2054 /* XXXX Add constants here */
2055#ifdef AL_4CHANNEL
2056 x = PyInt_FromLong((long) AL_4CHANNEL);
2057 if (x == NULL || PyDict_SetItemString(d, "FOURCHANNEL", x) < 0)
2058 goto error;
2059 Py_DECREF(x);
2060#endif
2061#ifdef AL_ADAT_IF_TYPE
2062 x = PyInt_FromLong((long) AL_ADAT_IF_TYPE);
2063 if (x == NULL || PyDict_SetItemString(d, "ADAT_IF_TYPE", x) < 0)
2064 goto error;
2065 Py_DECREF(x);
2066#endif
2067#ifdef AL_ADAT_MCLK_TYPE
2068 x = PyInt_FromLong((long) AL_ADAT_MCLK_TYPE);
2069 if (x == NULL || PyDict_SetItemString(d, "ADAT_MCLK_TYPE", x) < 0)
2070 goto error;
2071 Py_DECREF(x);
2072#endif
2073#ifdef AL_AES_IF_TYPE
2074 x = PyInt_FromLong((long) AL_AES_IF_TYPE);
2075 if (x == NULL || PyDict_SetItemString(d, "AES_IF_TYPE", x) < 0)
2076 goto error;
2077 Py_DECREF(x);
2078#endif
2079#ifdef AL_AES_MCLK_TYPE
2080 x = PyInt_FromLong((long) AL_AES_MCLK_TYPE);
2081 if (x == NULL || PyDict_SetItemString(d, "AES_MCLK_TYPE", x) < 0)
2082 goto error;
2083 Py_DECREF(x);
2084#endif
2085#ifdef AL_ANALOG_IF_TYPE
2086 x = PyInt_FromLong((long) AL_ANALOG_IF_TYPE);
2087 if (x == NULL || PyDict_SetItemString(d, "ANALOG_IF_TYPE", x) < 0)
2088 goto error;
2089 Py_DECREF(x);
2090#endif
2091#ifdef AL_ASSOCIATE
2092 x = PyInt_FromLong((long) AL_ASSOCIATE);
2093 if (x == NULL || PyDict_SetItemString(d, "ASSOCIATE", x) < 0)
2094 goto error;
2095 Py_DECREF(x);
2096#endif
2097#ifdef AL_BAD_BUFFER_NULL
2098 x = PyInt_FromLong((long) AL_BAD_BUFFER_NULL);
2099 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFER_NULL", x) < 0)
2100 goto error;
2101 Py_DECREF(x);
2102#endif
2103#ifdef AL_BAD_BUFFERLENGTH
2104 x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH);
2105 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH", x) < 0)
2106 goto error;
2107 Py_DECREF(x);
2108#endif
2109#ifdef AL_BAD_BUFFERLENGTH_NEG
2110 x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH_NEG);
2111 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_NEG", x) < 0)
2112 goto error;
2113 Py_DECREF(x);
2114#endif
2115#ifdef AL_BAD_BUFFERLENGTH_ODD
2116 x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH_ODD);
2117 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_ODD", x) < 0)
2118 goto error;
2119 Py_DECREF(x);
2120#endif
2121#ifdef AL_BAD_CHANNELS
2122 x = PyInt_FromLong((long) AL_BAD_CHANNELS);
2123 if (x == NULL || PyDict_SetItemString(d, "BAD_CHANNELS", x) < 0)
2124 goto error;
2125 Py_DECREF(x);
2126#endif
2127#ifdef AL_BAD_CONFIG
2128 x = PyInt_FromLong((long) AL_BAD_CONFIG);
2129 if (x == NULL || PyDict_SetItemString(d, "BAD_CONFIG", x) < 0)
2130 goto error;
2131 Py_DECREF(x);
2132#endif
2133#ifdef AL_BAD_COUNT_NEG
2134 x = PyInt_FromLong((long) AL_BAD_COUNT_NEG);
2135 if (x == NULL || PyDict_SetItemString(d, "BAD_COUNT_NEG", x) < 0)
2136 goto error;
2137 Py_DECREF(x);
2138#endif
2139#ifdef AL_BAD_DEVICE
2140 x = PyInt_FromLong((long) AL_BAD_DEVICE);
2141 if (x == NULL || PyDict_SetItemString(d, "BAD_DEVICE", x) < 0)
2142 goto error;
2143 Py_DECREF(x);
2144#endif
2145#ifdef AL_BAD_DEVICE_ACCESS
2146 x = PyInt_FromLong((long) AL_BAD_DEVICE_ACCESS);
2147 if (x == NULL || PyDict_SetItemString(d, "BAD_DEVICE_ACCESS", x) < 0)
2148 goto error;
2149 Py_DECREF(x);
2150#endif
2151#ifdef AL_BAD_DIRECTION
2152 x = PyInt_FromLong((long) AL_BAD_DIRECTION);
2153 if (x == NULL || PyDict_SetItemString(d, "BAD_DIRECTION", x) < 0)
2154 goto error;
2155 Py_DECREF(x);
2156#endif
2157#ifdef AL_BAD_FILLPOINT
2158 x = PyInt_FromLong((long) AL_BAD_FILLPOINT);
2159 if (x == NULL || PyDict_SetItemString(d, "BAD_FILLPOINT", x) < 0)
2160 goto error;
2161 Py_DECREF(x);
2162#endif
2163#ifdef AL_BAD_FLOATMAX
2164 x = PyInt_FromLong((long) AL_BAD_FLOATMAX);
2165 if (x == NULL || PyDict_SetItemString(d, "BAD_FLOATMAX", x) < 0)
2166 goto error;
2167 Py_DECREF(x);
2168#endif
2169#ifdef AL_BAD_ILLEGAL_STATE
2170 x = PyInt_FromLong((long) AL_BAD_ILLEGAL_STATE);
2171 if (x == NULL || PyDict_SetItemString(d, "BAD_ILLEGAL_STATE", x) < 0)
2172 goto error;
2173 Py_DECREF(x);
2174#endif
2175#ifdef AL_BAD_NO_PORTS
2176 x = PyInt_FromLong((long) AL_BAD_NO_PORTS);
2177 if (x == NULL || PyDict_SetItemString(d, "BAD_NO_PORTS", x) < 0)
2178 goto error;
2179 Py_DECREF(x);
2180#endif
2181#ifdef AL_BAD_NOT_FOUND
2182 x = PyInt_FromLong((long) AL_BAD_NOT_FOUND);
2183 if (x == NULL || PyDict_SetItemString(d, "BAD_NOT_FOUND", x) < 0)
2184 goto error;
2185 Py_DECREF(x);
2186#endif
2187#ifdef AL_BAD_NOT_IMPLEMENTED
2188 x = PyInt_FromLong((long) AL_BAD_NOT_IMPLEMENTED);
2189 if (x == NULL || PyDict_SetItemString(d, "BAD_NOT_IMPLEMENTED", x) < 0)
2190 goto error;
2191 Py_DECREF(x);
2192#endif
2193#ifdef AL_BAD_OUT_OF_MEM
2194 x = PyInt_FromLong((long) AL_BAD_OUT_OF_MEM);
2195 if (x == NULL || PyDict_SetItemString(d, "BAD_OUT_OF_MEM", x) < 0)
2196 goto error;
2197 Py_DECREF(x);
2198#endif
2199#ifdef AL_BAD_PARAM
2200 x = PyInt_FromLong((long) AL_BAD_PARAM);
2201 if (x == NULL || PyDict_SetItemString(d, "BAD_PARAM", x) < 0)
2202 goto error;
2203 Py_DECREF(x);
2204#endif
2205#ifdef AL_BAD_PERMISSIONS
2206 x = PyInt_FromLong((long) AL_BAD_PERMISSIONS);
2207 if (x == NULL || PyDict_SetItemString(d, "BAD_PERMISSIONS", x) < 0)
2208 goto error;
2209 Py_DECREF(x);
2210#endif
2211#ifdef AL_BAD_PORT
2212 x = PyInt_FromLong((long) AL_BAD_PORT);
2213 if (x == NULL || PyDict_SetItemString(d, "BAD_PORT", x) < 0)
2214 goto error;
2215 Py_DECREF(x);
2216#endif
2217#ifdef AL_BAD_PORTSTYLE
2218 x = PyInt_FromLong((long) AL_BAD_PORTSTYLE);
2219 if (x == NULL || PyDict_SetItemString(d, "BAD_PORTSTYLE", x) < 0)
2220 goto error;
2221 Py_DECREF(x);
2222#endif
2223#ifdef AL_BAD_PVBUFFER
2224 x = PyInt_FromLong((long) AL_BAD_PVBUFFER);
2225 if (x == NULL || PyDict_SetItemString(d, "BAD_PVBUFFER", x) < 0)
2226 goto error;
2227 Py_DECREF(x);
2228#endif
2229#ifdef AL_BAD_QSIZE
2230 x = PyInt_FromLong((long) AL_BAD_QSIZE);
2231 if (x == NULL || PyDict_SetItemString(d, "BAD_QSIZE", x) < 0)
2232 goto error;
2233 Py_DECREF(x);
2234#endif
2235#ifdef AL_BAD_RATE
2236 x = PyInt_FromLong((long) AL_BAD_RATE);
2237 if (x == NULL || PyDict_SetItemString(d, "BAD_RATE", x) < 0)
2238 goto error;
2239 Py_DECREF(x);
2240#endif
2241#ifdef AL_BAD_RESOURCE
2242 x = PyInt_FromLong((long) AL_BAD_RESOURCE);
2243 if (x == NULL || PyDict_SetItemString(d, "BAD_RESOURCE", x) < 0)
2244 goto error;
2245 Py_DECREF(x);
2246#endif
2247#ifdef AL_BAD_SAMPFMT
2248 x = PyInt_FromLong((long) AL_BAD_SAMPFMT);
2249 if (x == NULL || PyDict_SetItemString(d, "BAD_SAMPFMT", x) < 0)
2250 goto error;
2251 Py_DECREF(x);
2252#endif
2253#ifdef AL_BAD_TRANSFER_SIZE
2254 x = PyInt_FromLong((long) AL_BAD_TRANSFER_SIZE);
2255 if (x == NULL || PyDict_SetItemString(d, "BAD_TRANSFER_SIZE", x) < 0)
2256 goto error;
2257 Py_DECREF(x);
2258#endif
2259#ifdef AL_BAD_WIDTH
2260 x = PyInt_FromLong((long) AL_BAD_WIDTH);
2261 if (x == NULL || PyDict_SetItemString(d, "BAD_WIDTH", x) < 0)
2262 goto error;
2263 Py_DECREF(x);
2264#endif
2265#ifdef AL_CHANNEL_MODE
2266 x = PyInt_FromLong((long) AL_CHANNEL_MODE);
2267 if (x == NULL || PyDict_SetItemString(d, "CHANNEL_MODE", x) < 0)
2268 goto error;
2269 Py_DECREF(x);
2270#endif
2271#ifdef AL_CHANNELS
2272 x = PyInt_FromLong((long) AL_CHANNELS);
2273 if (x == NULL || PyDict_SetItemString(d, "CHANNELS", x) < 0)
2274 goto error;
2275 Py_DECREF(x);
2276#endif
2277#ifdef AL_CHAR_ELEM
2278 x = PyInt_FromLong((long) AL_CHAR_ELEM);
2279 if (x == NULL || PyDict_SetItemString(d, "CHAR_ELEM", x) < 0)
2280 goto error;
2281 Py_DECREF(x);
2282#endif
2283#ifdef AL_CLOCK_GEN
2284 x = PyInt_FromLong((long) AL_CLOCK_GEN);
2285 if (x == NULL || PyDict_SetItemString(d, "CLOCK_GEN", x) < 0)
2286 goto error;
2287 Py_DECREF(x);
2288#endif
2289#ifdef AL_CLOCKGEN_TYPE
2290 x = PyInt_FromLong((long) AL_CLOCKGEN_TYPE);
2291 if (x == NULL || PyDict_SetItemString(d, "CLOCKGEN_TYPE", x) < 0)
2292 goto error;
2293 Py_DECREF(x);
2294#endif
2295#ifdef AL_CONNECT
2296 x = PyInt_FromLong((long) AL_CONNECT);
2297 if (x == NULL || PyDict_SetItemString(d, "CONNECT", x) < 0)
2298 goto error;
2299 Py_DECREF(x);
2300#endif
2301#ifdef AL_CONNECTION_TYPE
2302 x = PyInt_FromLong((long) AL_CONNECTION_TYPE);
2303 if (x == NULL || PyDict_SetItemString(d, "CONNECTION_TYPE", x) < 0)
2304 goto error;
2305 Py_DECREF(x);
2306#endif
2307#ifdef AL_CONNECTIONS
2308 x = PyInt_FromLong((long) AL_CONNECTIONS);
2309 if (x == NULL || PyDict_SetItemString(d, "CONNECTIONS", x) < 0)
2310 goto error;
2311 Py_DECREF(x);
2312#endif
2313#ifdef AL_CRYSTAL_MCLK_TYPE
2314 x = PyInt_FromLong((long) AL_CRYSTAL_MCLK_TYPE);
2315 if (x == NULL || PyDict_SetItemString(d, "CRYSTAL_MCLK_TYPE", x) < 0)
2316 goto error;
2317 Py_DECREF(x);
2318#endif
2319#ifdef AL_DEFAULT_DEVICE
2320 x = PyInt_FromLong((long) AL_DEFAULT_DEVICE);
2321 if (x == NULL || PyDict_SetItemString(d, "DEFAULT_DEVICE", x) < 0)
2322 goto error;
2323 Py_DECREF(x);
2324#endif
2325#ifdef AL_DEFAULT_INPUT
2326 x = PyInt_FromLong((long) AL_DEFAULT_INPUT);
2327 if (x == NULL || PyDict_SetItemString(d, "DEFAULT_INPUT", x) < 0)
2328 goto error;
2329 Py_DECREF(x);
2330#endif
2331#ifdef AL_DEFAULT_OUTPUT
2332 x = PyInt_FromLong((long) AL_DEFAULT_OUTPUT);
2333 if (x == NULL || PyDict_SetItemString(d, "DEFAULT_OUTPUT", x) < 0)
2334 goto error;
2335 Py_DECREF(x);
2336#endif
2337#ifdef AL_DEST
2338 x = PyInt_FromLong((long) AL_DEST);
2339 if (x == NULL || PyDict_SetItemString(d, "DEST", x) < 0)
2340 goto error;
2341 Py_DECREF(x);
2342#endif
2343#ifdef AL_DEVICE_TYPE
2344 x = PyInt_FromLong((long) AL_DEVICE_TYPE);
2345 if (x == NULL || PyDict_SetItemString(d, "DEVICE_TYPE", x) < 0)
2346 goto error;
2347 Py_DECREF(x);
2348#endif
2349#ifdef AL_DEVICES
2350 x = PyInt_FromLong((long) AL_DEVICES);
2351 if (x == NULL || PyDict_SetItemString(d, "DEVICES", x) < 0)
2352 goto error;
2353 Py_DECREF(x);
2354#endif
2355#ifdef AL_DIGITAL_IF_TYPE
2356 x = PyInt_FromLong((long) AL_DIGITAL_IF_TYPE);
2357 if (x == NULL || PyDict_SetItemString(d, "DIGITAL_IF_TYPE", x) < 0)
2358 goto error;
2359 Py_DECREF(x);
2360#endif
2361#ifdef AL_DIGITAL_INPUT_RATE
2362 x = PyInt_FromLong((long) AL_DIGITAL_INPUT_RATE);
2363 if (x == NULL || PyDict_SetItemString(d, "DIGITAL_INPUT_RATE", x) < 0)
2364 goto error;
2365 Py_DECREF(x);
2366#endif
2367#ifdef AL_DISCONNECT
2368 x = PyInt_FromLong((long) AL_DISCONNECT);
2369 if (x == NULL || PyDict_SetItemString(d, "DISCONNECT", x) < 0)
2370 goto error;
2371 Py_DECREF(x);
2372#endif
2373#ifdef AL_ENUM_ELEM
2374 x = PyInt_FromLong((long) AL_ENUM_ELEM);
2375 if (x == NULL || PyDict_SetItemString(d, "ENUM_ELEM", x) < 0)
2376 goto error;
2377 Py_DECREF(x);
2378#endif
2379#ifdef AL_ENUM_VALUE
2380 x = PyInt_FromLong((long) AL_ENUM_VALUE);
2381 if (x == NULL || PyDict_SetItemString(d, "ENUM_VALUE", x) < 0)
2382 goto error;
2383 Py_DECREF(x);
2384#endif
2385#ifdef AL_ERROR_INPUT_OVERFLOW
2386 x = PyInt_FromLong((long) AL_ERROR_INPUT_OVERFLOW);
2387 if (x == NULL || PyDict_SetItemString(d, "ERROR_INPUT_OVERFLOW", x) < 0)
2388 goto error;
2389 Py_DECREF(x);
2390#endif
2391#ifdef AL_ERROR_LENGTH
2392 x = PyInt_FromLong((long) AL_ERROR_LENGTH);
2393 if (x == NULL || PyDict_SetItemString(d, "ERROR_LENGTH", x) < 0)
2394 goto error;
2395 Py_DECREF(x);
2396#endif
2397#ifdef AL_ERROR_LOCATION_LSP
2398 x = PyInt_FromLong((long) AL_ERROR_LOCATION_LSP);
2399 if (x == NULL || PyDict_SetItemString(d, "ERROR_LOCATION_LSP", x) < 0)
2400 goto error;
2401 Py_DECREF(x);
2402#endif
2403#ifdef AL_ERROR_LOCATION_MSP
2404 x = PyInt_FromLong((long) AL_ERROR_LOCATION_MSP);
2405 if (x == NULL || PyDict_SetItemString(d, "ERROR_LOCATION_MSP", x) < 0)
2406 goto error;
2407 Py_DECREF(x);
2408#endif
2409#ifdef AL_ERROR_NUMBER
2410 x = PyInt_FromLong((long) AL_ERROR_NUMBER);
2411 if (x == NULL || PyDict_SetItemString(d, "ERROR_NUMBER", x) < 0)
2412 goto error;
2413 Py_DECREF(x);
2414#endif
2415#ifdef AL_ERROR_OUTPUT_UNDERFLOW
2416 x = PyInt_FromLong((long) AL_ERROR_OUTPUT_UNDERFLOW);
2417 if (x == NULL || PyDict_SetItemString(d, "ERROR_OUTPUT_UNDERFLOW", x) < 0)
2418 goto error;
2419 Py_DECREF(x);
2420#endif
2421#ifdef AL_ERROR_TYPE
2422 x = PyInt_FromLong((long) AL_ERROR_TYPE);
2423 if (x == NULL || PyDict_SetItemString(d, "ERROR_TYPE", x) < 0)
2424 goto error;
2425 Py_DECREF(x);
2426#endif
2427#ifdef AL_FIXED_ELEM
2428 x = PyInt_FromLong((long) AL_FIXED_ELEM);
2429 if (x == NULL || PyDict_SetItemString(d, "FIXED_ELEM", x) < 0)
2430 goto error;
2431 Py_DECREF(x);
2432#endif
2433#ifdef AL_FIXED_MCLK_TYPE
2434 x = PyInt_FromLong((long) AL_FIXED_MCLK_TYPE);
2435 if (x == NULL || PyDict_SetItemString(d, "FIXED_MCLK_TYPE", x) < 0)
2436 goto error;
2437 Py_DECREF(x);
2438#endif
2439#ifdef AL_GAIN
2440 x = PyInt_FromLong((long) AL_GAIN);
2441 if (x == NULL || PyDict_SetItemString(d, "GAIN", x) < 0)
2442 goto error;
2443 Py_DECREF(x);
2444#endif
2445#ifdef AL_GAIN_REF
2446 x = PyInt_FromLong((long) AL_GAIN_REF);
2447 if (x == NULL || PyDict_SetItemString(d, "GAIN_REF", x) < 0)
2448 goto error;
2449 Py_DECREF(x);
2450#endif
2451#ifdef AL_HRB_TYPE
2452 x = PyInt_FromLong((long) AL_HRB_TYPE);
2453 if (x == NULL || PyDict_SetItemString(d, "HRB_TYPE", x) < 0)
2454 goto error;
2455 Py_DECREF(x);
2456#endif
2457#ifdef AL_INPUT_COUNT
2458 x = PyInt_FromLong((long) AL_INPUT_COUNT);
2459 if (x == NULL || PyDict_SetItemString(d, "INPUT_COUNT", x) < 0)
2460 goto error;
2461 Py_DECREF(x);
2462#endif
2463#ifdef AL_INPUT_DEVICE_TYPE
2464 x = PyInt_FromLong((long) AL_INPUT_DEVICE_TYPE);
2465 if (x == NULL || PyDict_SetItemString(d, "INPUT_DEVICE_TYPE", x) < 0)
2466 goto error;
2467 Py_DECREF(x);
2468#endif
2469#ifdef AL_INPUT_DIGITAL
2470 x = PyInt_FromLong((long) AL_INPUT_DIGITAL);
2471 if (x == NULL || PyDict_SetItemString(d, "INPUT_DIGITAL", x) < 0)
2472 goto error;
2473 Py_DECREF(x);
2474#endif
2475#ifdef AL_INPUT_HRB_TYPE
2476 x = PyInt_FromLong((long) AL_INPUT_HRB_TYPE);
2477 if (x == NULL || PyDict_SetItemString(d, "INPUT_HRB_TYPE", x) < 0)
2478 goto error;
2479 Py_DECREF(x);
2480#endif
2481#ifdef AL_INPUT_LINE
2482 x = PyInt_FromLong((long) AL_INPUT_LINE);
2483 if (x == NULL || PyDict_SetItemString(d, "INPUT_LINE", x) < 0)
2484 goto error;
2485 Py_DECREF(x);
2486#endif
2487#ifdef AL_INPUT_MIC
2488 x = PyInt_FromLong((long) AL_INPUT_MIC);
2489 if (x == NULL || PyDict_SetItemString(d, "INPUT_MIC", x) < 0)
2490 goto error;
2491 Py_DECREF(x);
2492#endif
2493#ifdef AL_INPUT_PORT_TYPE
2494 x = PyInt_FromLong((long) AL_INPUT_PORT_TYPE);
2495 if (x == NULL || PyDict_SetItemString(d, "INPUT_PORT_TYPE", x) < 0)
2496 goto error;
2497 Py_DECREF(x);
2498#endif
2499#ifdef AL_INPUT_RATE
2500 x = PyInt_FromLong((long) AL_INPUT_RATE);
2501 if (x == NULL || PyDict_SetItemString(d, "INPUT_RATE", x) < 0)
2502 goto error;
2503 Py_DECREF(x);
2504#endif
2505#ifdef AL_INPUT_SOURCE
2506 x = PyInt_FromLong((long) AL_INPUT_SOURCE);
2507 if (x == NULL || PyDict_SetItemString(d, "INPUT_SOURCE", x) < 0)
2508 goto error;
2509 Py_DECREF(x);
2510#endif
2511#ifdef AL_INT32_ELEM
2512 x = PyInt_FromLong((long) AL_INT32_ELEM);
2513 if (x == NULL || PyDict_SetItemString(d, "INT32_ELEM", x) < 0)
2514 goto error;
2515 Py_DECREF(x);
2516#endif
2517#ifdef AL_INT64_ELEM
2518 x = PyInt_FromLong((long) AL_INT64_ELEM);
2519 if (x == NULL || PyDict_SetItemString(d, "INT64_ELEM", x) < 0)
2520 goto error;
2521 Py_DECREF(x);
2522#endif
2523#ifdef AL_INTERFACE
2524 x = PyInt_FromLong((long) AL_INTERFACE);
2525 if (x == NULL || PyDict_SetItemString(d, "INTERFACE", x) < 0)
2526 goto error;
2527 Py_DECREF(x);
2528#endif
2529#ifdef AL_INTERFACE_TYPE
2530 x = PyInt_FromLong((long) AL_INTERFACE_TYPE);
2531 if (x == NULL || PyDict_SetItemString(d, "INTERFACE_TYPE", x) < 0)
2532 goto error;
2533 Py_DECREF(x);
2534#endif
2535#ifdef AL_INVALID_PARAM
2536 x = PyInt_FromLong((long) AL_INVALID_PARAM);
2537 if (x == NULL || PyDict_SetItemString(d, "INVALID_PARAM", x) < 0)
2538 goto error;
2539 Py_DECREF(x);
2540#endif
2541#ifdef AL_INVALID_VALUE
2542 x = PyInt_FromLong((long) AL_INVALID_VALUE);
2543 if (x == NULL || PyDict_SetItemString(d, "INVALID_VALUE", x) < 0)
2544 goto error;
2545 Py_DECREF(x);
2546#endif
2547#ifdef AL_JITTER
2548 x = PyInt_FromLong((long) AL_JITTER);
2549 if (x == NULL || PyDict_SetItemString(d, "JITTER", x) < 0)
2550 goto error;
2551 Py_DECREF(x);
2552#endif
2553#ifdef AL_LABEL
2554 x = PyInt_FromLong((long) AL_LABEL);
2555 if (x == NULL || PyDict_SetItemString(d, "LABEL", x) < 0)
2556 goto error;
2557 Py_DECREF(x);
2558#endif
2559#ifdef AL_LEFT_INPUT_ATTEN
2560 x = PyInt_FromLong((long) AL_LEFT_INPUT_ATTEN);
2561 if (x == NULL || PyDict_SetItemString(d, "LEFT_INPUT_ATTEN", x) < 0)
2562 goto error;
2563 Py_DECREF(x);
2564#endif
2565#ifdef AL_LEFT_MONITOR_ATTEN
2566 x = PyInt_FromLong((long) AL_LEFT_MONITOR_ATTEN);
2567 if (x == NULL || PyDict_SetItemString(d, "LEFT_MONITOR_ATTEN", x) < 0)
2568 goto error;
2569 Py_DECREF(x);
2570#endif
2571#ifdef AL_LEFT_SPEAKER_GAIN
2572 x = PyInt_FromLong((long) AL_LEFT_SPEAKER_GAIN);
2573 if (x == NULL || PyDict_SetItemString(d, "LEFT_SPEAKER_GAIN", x) < 0)
2574 goto error;
2575 Py_DECREF(x);
2576#endif
2577#ifdef AL_LEFT1_INPUT_ATTEN
2578 x = PyInt_FromLong((long) AL_LEFT1_INPUT_ATTEN);
2579 if (x == NULL || PyDict_SetItemString(d, "LEFT1_INPUT_ATTEN", x) < 0)
2580 goto error;
2581 Py_DECREF(x);
2582#endif
2583#ifdef AL_LEFT2_INPUT_ATTEN
2584 x = PyInt_FromLong((long) AL_LEFT2_INPUT_ATTEN);
2585 if (x == NULL || PyDict_SetItemString(d, "LEFT2_INPUT_ATTEN", x) < 0)
2586 goto error;
2587 Py_DECREF(x);
2588#endif
2589#ifdef AL_LINE_IF_TYPE
2590 x = PyInt_FromLong((long) AL_LINE_IF_TYPE);
2591 if (x == NULL || PyDict_SetItemString(d, "LINE_IF_TYPE", x) < 0)
2592 goto error;
2593 Py_DECREF(x);
2594#endif
2595#ifdef AL_MASTER_CLOCK
2596 x = PyInt_FromLong((long) AL_MASTER_CLOCK);
2597 if (x == NULL || PyDict_SetItemString(d, "MASTER_CLOCK", x) < 0)
2598 goto error;
2599 Py_DECREF(x);
2600#endif
2601#ifdef AL_MATRIX_VAL
2602 x = PyInt_FromLong((long) AL_MATRIX_VAL);
2603 if (x == NULL || PyDict_SetItemString(d, "MATRIX_VAL", x) < 0)
2604 goto error;
2605 Py_DECREF(x);
2606#endif
2607#ifdef AL_MAX_ERROR
2608 x = PyInt_FromLong((long) AL_MAX_ERROR);
2609 if (x == NULL || PyDict_SetItemString(d, "MAX_ERROR", x) < 0)
2610 goto error;
2611 Py_DECREF(x);
2612#endif
2613#ifdef AL_MAX_EVENT_PARAM
2614 x = PyInt_FromLong((long) AL_MAX_EVENT_PARAM);
2615 if (x == NULL || PyDict_SetItemString(d, "MAX_EVENT_PARAM", x) < 0)
2616 goto error;
2617 Py_DECREF(x);
2618#endif
2619#ifdef AL_MAX_PBUFSIZE
2620 x = PyInt_FromLong((long) AL_MAX_PBUFSIZE);
2621 if (x == NULL || PyDict_SetItemString(d, "MAX_PBUFSIZE", x) < 0)
2622 goto error;
2623 Py_DECREF(x);
2624#endif
2625#ifdef AL_MAX_PORTS
2626 x = PyInt_FromLong((long) AL_MAX_PORTS);
2627 if (x == NULL || PyDict_SetItemString(d, "MAX_PORTS", x) < 0)
2628 goto error;
2629 Py_DECREF(x);
2630#endif
2631#ifdef AL_MAX_RESOURCE_ID
2632 x = PyInt_FromLong((long) AL_MAX_RESOURCE_ID);
2633 if (x == NULL || PyDict_SetItemString(d, "MAX_RESOURCE_ID", x) < 0)
2634 goto error;
2635 Py_DECREF(x);
2636#endif
2637#ifdef AL_MAX_SETSIZE
2638 x = PyInt_FromLong((long) AL_MAX_SETSIZE);
2639 if (x == NULL || PyDict_SetItemString(d, "MAX_SETSIZE", x) < 0)
2640 goto error;
2641 Py_DECREF(x);
2642#endif
2643#ifdef AL_MAX_STRLEN
2644 x = PyInt_FromLong((long) AL_MAX_STRLEN);
2645 if (x == NULL || PyDict_SetItemString(d, "MAX_STRLEN", x) < 0)
2646 goto error;
2647 Py_DECREF(x);
2648#endif
2649#ifdef AL_MCLK_TYPE
2650 x = PyInt_FromLong((long) AL_MCLK_TYPE);
2651 if (x == NULL || PyDict_SetItemString(d, "MCLK_TYPE", x) < 0)
2652 goto error;
2653 Py_DECREF(x);
2654#endif
2655#ifdef AL_MIC_IF_TYPE
2656 x = PyInt_FromLong((long) AL_MIC_IF_TYPE);
2657 if (x == NULL || PyDict_SetItemString(d, "MIC_IF_TYPE", x) < 0)
2658 goto error;
2659 Py_DECREF(x);
2660#endif
2661#ifdef AL_MONITOR_CTL
2662 x = PyInt_FromLong((long) AL_MONITOR_CTL);
2663 if (x == NULL || PyDict_SetItemString(d, "MONITOR_CTL", x) < 0)
2664 goto error;
2665 Py_DECREF(x);
2666#endif
2667#ifdef AL_MONITOR_OFF
2668 x = PyInt_FromLong((long) AL_MONITOR_OFF);
2669 if (x == NULL || PyDict_SetItemString(d, "MONITOR_OFF", x) < 0)
2670 goto error;
2671 Py_DECREF(x);
2672#endif
2673#ifdef AL_MONITOR_ON
2674 x = PyInt_FromLong((long) AL_MONITOR_ON);
2675 if (x == NULL || PyDict_SetItemString(d, "MONITOR_ON", x) < 0)
2676 goto error;
2677 Py_DECREF(x);
2678#endif
2679#ifdef AL_MONO
2680 x = PyInt_FromLong((long) AL_MONO);
2681 if (x == NULL || PyDict_SetItemString(d, "MONO", x) < 0)
2682 goto error;
2683 Py_DECREF(x);
2684#endif
2685#ifdef AL_MUTE
2686 x = PyInt_FromLong((long) AL_MUTE);
2687 if (x == NULL || PyDict_SetItemString(d, "MUTE", x) < 0)
2688 goto error;
2689 Py_DECREF(x);
2690#endif
2691#ifdef AL_NAME
2692 x = PyInt_FromLong((long) AL_NAME);
2693 if (x == NULL || PyDict_SetItemString(d, "NAME", x) < 0)
2694 goto error;
2695 Py_DECREF(x);
2696#endif
2697#ifdef AL_NEG_INFINITY
2698 x = PyInt_FromLong((long) AL_NEG_INFINITY);
2699 if (x == NULL || PyDict_SetItemString(d, "NEG_INFINITY", x) < 0)
2700 goto error;
2701 Py_DECREF(x);
2702#endif
2703#ifdef AL_NEG_INFINITY_BIT
2704 x = PyInt_FromLong((long) AL_NEG_INFINITY_BIT);
2705 if (x == NULL || PyDict_SetItemString(d, "NEG_INFINITY_BIT", x) < 0)
2706 goto error;
2707 Py_DECREF(x);
2708#endif
2709#ifdef AL_NO_CHANGE
2710 x = PyInt_FromLong((long) AL_NO_CHANGE);
2711 if (x == NULL || PyDict_SetItemString(d, "NO_CHANGE", x) < 0)
2712 goto error;
2713 Py_DECREF(x);
2714#endif
2715#ifdef AL_NO_CHANGE_BIT
2716 x = PyInt_FromLong((long) AL_NO_CHANGE_BIT);
2717 if (x == NULL || PyDict_SetItemString(d, "NO_CHANGE_BIT", x) < 0)
2718 goto error;
2719 Py_DECREF(x);
2720#endif
2721#ifdef AL_NO_ELEM
2722 x = PyInt_FromLong((long) AL_NO_ELEM);
2723 if (x == NULL || PyDict_SetItemString(d, "NO_ELEM", x) < 0)
2724 goto error;
2725 Py_DECREF(x);
2726#endif
2727#ifdef AL_NO_ERRORS
2728 x = PyInt_FromLong((long) AL_NO_ERRORS);
2729 if (x == NULL || PyDict_SetItemString(d, "NO_ERRORS", x) < 0)
2730 goto error;
2731 Py_DECREF(x);
2732#endif
2733#ifdef AL_NO_OP
2734 x = PyInt_FromLong((long) AL_NO_OP);
2735 if (x == NULL || PyDict_SetItemString(d, "NO_OP", x) < 0)
2736 goto error;
2737 Py_DECREF(x);
2738#endif
2739#ifdef AL_NO_VAL
2740 x = PyInt_FromLong((long) AL_NO_VAL);
2741 if (x == NULL || PyDict_SetItemString(d, "NO_VAL", x) < 0)
2742 goto error;
2743 Py_DECREF(x);
2744#endif
2745#ifdef AL_NULL_RESOURCE
2746 x = PyInt_FromLong((long) AL_NULL_RESOURCE);
2747 if (x == NULL || PyDict_SetItemString(d, "NULL_RESOURCE", x) < 0)
2748 goto error;
2749 Py_DECREF(x);
2750#endif
2751#ifdef AL_OUTPUT_COUNT
2752 x = PyInt_FromLong((long) AL_OUTPUT_COUNT);
2753 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_COUNT", x) < 0)
2754 goto error;
2755 Py_DECREF(x);
2756#endif
2757#ifdef AL_OUTPUT_DEVICE_TYPE
2758 x = PyInt_FromLong((long) AL_OUTPUT_DEVICE_TYPE);
2759 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_DEVICE_TYPE", x) < 0)
2760 goto error;
2761 Py_DECREF(x);
2762#endif
2763#ifdef AL_OUTPUT_HRB_TYPE
2764 x = PyInt_FromLong((long) AL_OUTPUT_HRB_TYPE);
2765 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_HRB_TYPE", x) < 0)
2766 goto error;
2767 Py_DECREF(x);
2768#endif
2769#ifdef AL_OUTPUT_PORT_TYPE
2770 x = PyInt_FromLong((long) AL_OUTPUT_PORT_TYPE);
2771 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_PORT_TYPE", x) < 0)
2772 goto error;
2773 Py_DECREF(x);
2774#endif
2775#ifdef AL_OUTPUT_RATE
2776 x = PyInt_FromLong((long) AL_OUTPUT_RATE);
2777 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_RATE", x) < 0)
2778 goto error;
2779 Py_DECREF(x);
2780#endif
2781#ifdef AL_PARAM_BIT
2782 x = PyInt_FromLong((long) AL_PARAM_BIT);
2783 if (x == NULL || PyDict_SetItemString(d, "PARAM_BIT", x) < 0)
2784 goto error;
2785 Py_DECREF(x);
2786#endif
2787#ifdef AL_PARAMS
2788 x = PyInt_FromLong((long) AL_PARAMS);
2789 if (x == NULL || PyDict_SetItemString(d, "PARAMS", x) < 0)
2790 goto error;
2791 Py_DECREF(x);
2792#endif
2793#ifdef AL_PORT_COUNT
2794 x = PyInt_FromLong((long) AL_PORT_COUNT);
2795 if (x == NULL || PyDict_SetItemString(d, "PORT_COUNT", x) < 0)
2796 goto error;
2797 Py_DECREF(x);
2798#endif
2799#ifdef AL_PORT_TYPE
2800 x = PyInt_FromLong((long) AL_PORT_TYPE);
2801 if (x == NULL || PyDict_SetItemString(d, "PORT_TYPE", x) < 0)
2802 goto error;
2803 Py_DECREF(x);
2804#endif
2805#ifdef AL_PORTS
2806 x = PyInt_FromLong((long) AL_PORTS);
2807 if (x == NULL || PyDict_SetItemString(d, "PORTS", x) < 0)
2808 goto error;
2809 Py_DECREF(x);
2810#endif
2811#ifdef AL_PORTSTYLE_DIRECT
2812 x = PyInt_FromLong((long) AL_PORTSTYLE_DIRECT);
2813 if (x == NULL || PyDict_SetItemString(d, "PORTSTYLE_DIRECT", x) < 0)
2814 goto error;
2815 Py_DECREF(x);
2816#endif
2817#ifdef AL_PORTSTYLE_SERIAL
2818 x = PyInt_FromLong((long) AL_PORTSTYLE_SERIAL);
2819 if (x == NULL || PyDict_SetItemString(d, "PORTSTYLE_SERIAL", x) < 0)
2820 goto error;
2821 Py_DECREF(x);
2822#endif
2823#ifdef AL_PRINT_ERRORS
2824 x = PyInt_FromLong((long) AL_PRINT_ERRORS);
2825 if (x == NULL || PyDict_SetItemString(d, "PRINT_ERRORS", x) < 0)
2826 goto error;
2827 Py_DECREF(x);
2828#endif
2829#ifdef AL_PTR_ELEM
2830 x = PyInt_FromLong((long) AL_PTR_ELEM);
2831 if (x == NULL || PyDict_SetItemString(d, "PTR_ELEM", x) < 0)
2832 goto error;
2833 Py_DECREF(x);
2834#endif
2835#ifdef AL_RANGE_VALUE
2836 x = PyInt_FromLong((long) AL_RANGE_VALUE);
2837 if (x == NULL || PyDict_SetItemString(d, "RANGE_VALUE", x) < 0)
2838 goto error;
2839 Py_DECREF(x);
2840#endif
2841#ifdef AL_RATE
2842 x = PyInt_FromLong((long) AL_RATE);
2843 if (x == NULL || PyDict_SetItemString(d, "RATE", x) < 0)
2844 goto error;
2845 Py_DECREF(x);
2846#endif
2847#ifdef AL_RATE_11025
2848 x = PyInt_FromLong((long) AL_RATE_11025);
2849 if (x == NULL || PyDict_SetItemString(d, "RATE_11025", x) < 0)
2850 goto error;
2851 Py_DECREF(x);
2852#endif
2853#ifdef AL_RATE_16000
2854 x = PyInt_FromLong((long) AL_RATE_16000);
2855 if (x == NULL || PyDict_SetItemString(d, "RATE_16000", x) < 0)
2856 goto error;
2857 Py_DECREF(x);
2858#endif
2859#ifdef AL_RATE_22050
2860 x = PyInt_FromLong((long) AL_RATE_22050);
2861 if (x == NULL || PyDict_SetItemString(d, "RATE_22050", x) < 0)
2862 goto error;
2863 Py_DECREF(x);
2864#endif
2865#ifdef AL_RATE_32000
2866 x = PyInt_FromLong((long) AL_RATE_32000);
2867 if (x == NULL || PyDict_SetItemString(d, "RATE_32000", x) < 0)
2868 goto error;
2869 Py_DECREF(x);
2870#endif
2871#ifdef AL_RATE_44100
2872 x = PyInt_FromLong((long) AL_RATE_44100);
2873 if (x == NULL || PyDict_SetItemString(d, "RATE_44100", x) < 0)
2874 goto error;
2875 Py_DECREF(x);
2876#endif
2877#ifdef AL_RATE_48000
2878 x = PyInt_FromLong((long) AL_RATE_48000);
2879 if (x == NULL || PyDict_SetItemString(d, "RATE_48000", x) < 0)
2880 goto error;
2881 Py_DECREF(x);
2882#endif
2883#ifdef AL_RATE_8000
2884 x = PyInt_FromLong((long) AL_RATE_8000);
2885 if (x == NULL || PyDict_SetItemString(d, "RATE_8000", x) < 0)
2886 goto error;
2887 Py_DECREF(x);
2888#endif
2889#ifdef AL_RATE_AES_1
2890 x = PyInt_FromLong((long) AL_RATE_AES_1);
2891 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_1", x) < 0)
2892 goto error;
2893 Py_DECREF(x);
2894#endif
2895#ifdef AL_RATE_AES_1s
2896 x = PyInt_FromLong((long) AL_RATE_AES_1s);
2897 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_1s", x) < 0)
2898 goto error;
2899 Py_DECREF(x);
2900#endif
2901#ifdef AL_RATE_AES_2
2902 x = PyInt_FromLong((long) AL_RATE_AES_2);
2903 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_2", x) < 0)
2904 goto error;
2905 Py_DECREF(x);
2906#endif
2907#ifdef AL_RATE_AES_3
2908 x = PyInt_FromLong((long) AL_RATE_AES_3);
2909 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_3", x) < 0)
2910 goto error;
2911 Py_DECREF(x);
2912#endif
2913#ifdef AL_RATE_AES_4
2914 x = PyInt_FromLong((long) AL_RATE_AES_4);
2915 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_4", x) < 0)
2916 goto error;
2917 Py_DECREF(x);
2918#endif
2919#ifdef AL_RATE_AES_6
2920 x = PyInt_FromLong((long) AL_RATE_AES_6);
2921 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_6", x) < 0)
2922 goto error;
2923 Py_DECREF(x);
2924#endif
2925#ifdef AL_RATE_FRACTION_D
2926 x = PyInt_FromLong((long) AL_RATE_FRACTION_D);
2927 if (x == NULL || PyDict_SetItemString(d, "RATE_FRACTION_D", x) < 0)
2928 goto error;
2929 Py_DECREF(x);
2930#endif
2931#ifdef AL_RATE_FRACTION_N
2932 x = PyInt_FromLong((long) AL_RATE_FRACTION_N);
2933 if (x == NULL || PyDict_SetItemString(d, "RATE_FRACTION_N", x) < 0)
2934 goto error;
2935 Py_DECREF(x);
2936#endif
2937#ifdef AL_RATE_INPUTRATE
2938 x = PyInt_FromLong((long) AL_RATE_INPUTRATE);
2939 if (x == NULL || PyDict_SetItemString(d, "RATE_INPUTRATE", x) < 0)
2940 goto error;
2941 Py_DECREF(x);
2942#endif
2943#ifdef AL_RATE_NO_DIGITAL_INPUT
2944 x = PyInt_FromLong((long) AL_RATE_NO_DIGITAL_INPUT);
2945 if (x == NULL || PyDict_SetItemString(d, "RATE_NO_DIGITAL_INPUT", x) < 0)
2946 goto error;
2947 Py_DECREF(x);
2948#endif
2949#ifdef AL_RATE_UNACQUIRED
2950 x = PyInt_FromLong((long) AL_RATE_UNACQUIRED);
2951 if (x == NULL || PyDict_SetItemString(d, "RATE_UNACQUIRED", x) < 0)
2952 goto error;
2953 Py_DECREF(x);
2954#endif
2955#ifdef AL_RATE_UNDEFINED
2956 x = PyInt_FromLong((long) AL_RATE_UNDEFINED);
2957 if (x == NULL || PyDict_SetItemString(d, "RATE_UNDEFINED", x) < 0)
2958 goto error;
2959 Py_DECREF(x);
2960#endif
2961#ifdef AL_REF_0DBV
2962 x = PyInt_FromLong((long) AL_REF_0DBV);
2963 if (x == NULL || PyDict_SetItemString(d, "REF_0DBV", x) < 0)
2964 goto error;
2965 Py_DECREF(x);
2966#endif
2967#ifdef AL_REF_NONE
2968 x = PyInt_FromLong((long) AL_REF_NONE);
2969 if (x == NULL || PyDict_SetItemString(d, "REF_NONE", x) < 0)
2970 goto error;
2971 Py_DECREF(x);
2972#endif
2973#ifdef AL_RESERVED1_TYPE
2974 x = PyInt_FromLong((long) AL_RESERVED1_TYPE);
2975 if (x == NULL || PyDict_SetItemString(d, "RESERVED1_TYPE", x) < 0)
2976 goto error;
2977 Py_DECREF(x);
2978#endif
2979#ifdef AL_RESERVED2_TYPE
2980 x = PyInt_FromLong((long) AL_RESERVED2_TYPE);
2981 if (x == NULL || PyDict_SetItemString(d, "RESERVED2_TYPE", x) < 0)
2982 goto error;
2983 Py_DECREF(x);
2984#endif
2985#ifdef AL_RESERVED3_TYPE
2986 x = PyInt_FromLong((long) AL_RESERVED3_TYPE);
2987 if (x == NULL || PyDict_SetItemString(d, "RESERVED3_TYPE", x) < 0)
2988 goto error;
2989 Py_DECREF(x);
2990#endif
2991#ifdef AL_RESERVED4_TYPE
2992 x = PyInt_FromLong((long) AL_RESERVED4_TYPE);
2993 if (x == NULL || PyDict_SetItemString(d, "RESERVED4_TYPE", x) < 0)
2994 goto error;
2995 Py_DECREF(x);
2996#endif
2997#ifdef AL_RESOURCE
2998 x = PyInt_FromLong((long) AL_RESOURCE);
2999 if (x == NULL || PyDict_SetItemString(d, "RESOURCE", x) < 0)
3000 goto error;
3001 Py_DECREF(x);
3002#endif
3003#ifdef AL_RESOURCE_ELEM
3004 x = PyInt_FromLong((long) AL_RESOURCE_ELEM);
3005 if (x == NULL || PyDict_SetItemString(d, "RESOURCE_ELEM", x) < 0)
3006 goto error;
3007 Py_DECREF(x);
3008#endif
3009#ifdef AL_RESOURCE_TYPE
3010 x = PyInt_FromLong((long) AL_RESOURCE_TYPE);
3011 if (x == NULL || PyDict_SetItemString(d, "RESOURCE_TYPE", x) < 0)
3012 goto error;
3013 Py_DECREF(x);
3014#endif
3015#ifdef AL_RIGHT_INPUT_ATTEN
3016 x = PyInt_FromLong((long) AL_RIGHT_INPUT_ATTEN);
3017 if (x == NULL || PyDict_SetItemString(d, "RIGHT_INPUT_ATTEN", x) < 0)
3018 goto error;
3019 Py_DECREF(x);
3020#endif
3021#ifdef AL_RIGHT_MONITOR_ATTEN
3022 x = PyInt_FromLong((long) AL_RIGHT_MONITOR_ATTEN);
3023 if (x == NULL || PyDict_SetItemString(d, "RIGHT_MONITOR_ATTEN", x) < 0)
3024 goto error;
3025 Py_DECREF(x);
3026#endif
3027#ifdef AL_RIGHT_SPEAKER_GAIN
3028 x = PyInt_FromLong((long) AL_RIGHT_SPEAKER_GAIN);
3029 if (x == NULL || PyDict_SetItemString(d, "RIGHT_SPEAKER_GAIN", x) < 0)
3030 goto error;
3031 Py_DECREF(x);
3032#endif
3033#ifdef AL_RIGHT1_INPUT_ATTEN
3034 x = PyInt_FromLong((long) AL_RIGHT1_INPUT_ATTEN);
3035 if (x == NULL || PyDict_SetItemString(d, "RIGHT1_INPUT_ATTEN", x) < 0)
3036 goto error;
3037 Py_DECREF(x);
3038#endif
3039#ifdef AL_RIGHT2_INPUT_ATTEN
3040 x = PyInt_FromLong((long) AL_RIGHT2_INPUT_ATTEN);
3041 if (x == NULL || PyDict_SetItemString(d, "RIGHT2_INPUT_ATTEN", x) < 0)
3042 goto error;
3043 Py_DECREF(x);
3044#endif
3045#ifdef AL_SAMPFMT_DOUBLE
3046 x = PyInt_FromLong((long) AL_SAMPFMT_DOUBLE);
3047 if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_DOUBLE", x) < 0)
3048 goto error;
3049 Py_DECREF(x);
3050#endif
3051#ifdef AL_SAMPFMT_FLOAT
3052 x = PyInt_FromLong((long) AL_SAMPFMT_FLOAT);
3053 if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_FLOAT", x) < 0)
3054 goto error;
3055 Py_DECREF(x);
3056#endif
3057#ifdef AL_SAMPFMT_TWOSCOMP
3058 x = PyInt_FromLong((long) AL_SAMPFMT_TWOSCOMP);
3059 if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_TWOSCOMP", x) < 0)
3060 goto error;
3061 Py_DECREF(x);
3062#endif
3063#ifdef AL_SAMPLE_16
3064 x = PyInt_FromLong((long) AL_SAMPLE_16);
3065 if (x == NULL || PyDict_SetItemString(d, "SAMPLE_16", x) < 0)
3066 goto error;
3067 Py_DECREF(x);
3068#endif
3069#ifdef AL_SAMPLE_24
3070 x = PyInt_FromLong((long) AL_SAMPLE_24);
3071 if (x == NULL || PyDict_SetItemString(d, "SAMPLE_24", x) < 0)
3072 goto error;
3073 Py_DECREF(x);
3074#endif
3075#ifdef AL_SAMPLE_8
3076 x = PyInt_FromLong((long) AL_SAMPLE_8);
3077 if (x == NULL || PyDict_SetItemString(d, "SAMPLE_8", x) < 0)
3078 goto error;
3079 Py_DECREF(x);
3080#endif
3081#ifdef AL_SCALAR_VAL
3082 x = PyInt_FromLong((long) AL_SCALAR_VAL);
3083 if (x == NULL || PyDict_SetItemString(d, "SCALAR_VAL", x) < 0)
3084 goto error;
3085 Py_DECREF(x);
3086#endif
3087#ifdef AL_SET_VAL
3088 x = PyInt_FromLong((long) AL_SET_VAL);
3089 if (x == NULL || PyDict_SetItemString(d, "SET_VAL", x) < 0)
3090 goto error;
3091 Py_DECREF(x);
3092#endif
3093#ifdef AL_SHORT_NAME
3094 x = PyInt_FromLong((long) AL_SHORT_NAME);
3095 if (x == NULL || PyDict_SetItemString(d, "SHORT_NAME", x) < 0)
3096 goto error;
3097 Py_DECREF(x);
3098#endif
3099#ifdef AL_SOURCE
3100 x = PyInt_FromLong((long) AL_SOURCE);
3101 if (x == NULL || PyDict_SetItemString(d, "SOURCE", x) < 0)
3102 goto error;
3103 Py_DECREF(x);
3104#endif
3105#ifdef AL_SPEAKER_IF_TYPE
3106 x = PyInt_FromLong((long) AL_SPEAKER_IF_TYPE);
3107 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_IF_TYPE", x) < 0)
3108 goto error;
3109 Py_DECREF(x);
3110#endif
3111#ifdef AL_SPEAKER_MUTE_CTL
3112 x = PyInt_FromLong((long) AL_SPEAKER_MUTE_CTL);
3113 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_CTL", x) < 0)
3114 goto error;
3115 Py_DECREF(x);
3116#endif
3117#ifdef AL_SPEAKER_MUTE_OFF
3118 x = PyInt_FromLong((long) AL_SPEAKER_MUTE_OFF);
3119 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_OFF", x) < 0)
3120 goto error;
3121 Py_DECREF(x);
3122#endif
3123#ifdef AL_SPEAKER_MUTE_ON
3124 x = PyInt_FromLong((long) AL_SPEAKER_MUTE_ON);
3125 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_ON", x) < 0)
3126 goto error;
3127 Py_DECREF(x);
3128#endif
3129#ifdef AL_SPEAKER_PLUS_LINE_IF_TYPE
3130 x = PyInt_FromLong((long) AL_SPEAKER_PLUS_LINE_IF_TYPE);
3131 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_PLUS_LINE_IF_TYPE", x) < 0)
3132 goto error;
3133 Py_DECREF(x);
3134#endif
3135#ifdef AL_STEREO
3136 x = PyInt_FromLong((long) AL_STEREO);
3137 if (x == NULL || PyDict_SetItemString(d, "STEREO", x) < 0)
3138 goto error;
3139 Py_DECREF(x);
3140#endif
3141#ifdef AL_STRING_VAL
3142 x = PyInt_FromLong((long) AL_STRING_VAL);
3143 if (x == NULL || PyDict_SetItemString(d, "STRING_VAL", x) < 0)
3144 goto error;
3145 Py_DECREF(x);
3146#endif
3147#ifdef AL_SUBSYSTEM
3148 x = PyInt_FromLong((long) AL_SUBSYSTEM);
3149 if (x == NULL || PyDict_SetItemString(d, "SUBSYSTEM", x) < 0)
3150 goto error;
3151 Py_DECREF(x);
3152#endif
3153#ifdef AL_SUBSYSTEM_TYPE
3154 x = PyInt_FromLong((long) AL_SUBSYSTEM_TYPE);
3155 if (x == NULL || PyDict_SetItemString(d, "SUBSYSTEM_TYPE", x) < 0)
3156 goto error;
3157 Py_DECREF(x);
3158#endif
3159#ifdef AL_SYNC_INPUT_TO_AES
3160 x = PyInt_FromLong((long) AL_SYNC_INPUT_TO_AES);
3161 if (x == NULL || PyDict_SetItemString(d, "SYNC_INPUT_TO_AES", x) < 0)
3162 goto error;
3163 Py_DECREF(x);
3164#endif
3165#ifdef AL_SYNC_OUTPUT_TO_AES
3166 x = PyInt_FromLong((long) AL_SYNC_OUTPUT_TO_AES);
3167 if (x == NULL || PyDict_SetItemString(d, "SYNC_OUTPUT_TO_AES", x) < 0)
3168 goto error;
3169 Py_DECREF(x);
3170#endif
3171#ifdef AL_SYSTEM
3172 x = PyInt_FromLong((long) AL_SYSTEM);
3173 if (x == NULL || PyDict_SetItemString(d, "SYSTEM", x) < 0)
3174 goto error;
3175 Py_DECREF(x);
3176#endif
3177#ifdef AL_SYSTEM_TYPE
3178 x = PyInt_FromLong((long) AL_SYSTEM_TYPE);
3179 if (x == NULL || PyDict_SetItemString(d, "SYSTEM_TYPE", x) < 0)
3180 goto error;
3181 Py_DECREF(x);
3182#endif
3183#ifdef AL_TEST_IF_TYPE
3184 x = PyInt_FromLong((long) AL_TEST_IF_TYPE);
3185 if (x == NULL || PyDict_SetItemString(d, "TEST_IF_TYPE", x) < 0)
3186 goto error;
3187 Py_DECREF(x);
3188#endif
3189#ifdef AL_TYPE
3190 x = PyInt_FromLong((long) AL_TYPE);
3191 if (x == NULL || PyDict_SetItemString(d, "TYPE", x) < 0)
3192 goto error;
3193 Py_DECREF(x);
3194#endif
3195#ifdef AL_TYPE_BIT
3196 x = PyInt_FromLong((long) AL_TYPE_BIT);
3197 if (x == NULL || PyDict_SetItemString(d, "TYPE_BIT", x) < 0)
3198 goto error;
3199 Py_DECREF(x);
3200#endif
3201#ifdef AL_UNUSED_COUNT
3202 x = PyInt_FromLong((long) AL_UNUSED_COUNT);
3203 if (x == NULL || PyDict_SetItemString(d, "UNUSED_COUNT", x) < 0)
3204 goto error;
3205 Py_DECREF(x);
3206#endif
3207#ifdef AL_UNUSED_PORTS
3208 x = PyInt_FromLong((long) AL_UNUSED_PORTS);
3209 if (x == NULL || PyDict_SetItemString(d, "UNUSED_PORTS", x) < 0)
3210 goto error;
3211 Py_DECREF(x);
3212#endif
3213#ifdef AL_VARIABLE_MCLK_TYPE
3214 x = PyInt_FromLong((long) AL_VARIABLE_MCLK_TYPE);
3215 if (x == NULL || PyDict_SetItemString(d, "VARIABLE_MCLK_TYPE", x) < 0)
3216 goto error;
3217 Py_DECREF(x);
3218#endif
3219#ifdef AL_VECTOR_VAL
3220 x = PyInt_FromLong((long) AL_VECTOR_VAL);
3221 if (x == NULL || PyDict_SetItemString(d, "VECTOR_VAL", x) < 0)
3222 goto error;
3223 Py_DECREF(x);
3224#endif
3225#ifdef AL_VIDEO_MCLK_TYPE
3226 x = PyInt_FromLong((long) AL_VIDEO_MCLK_TYPE);
3227 if (x == NULL || PyDict_SetItemString(d, "VIDEO_MCLK_TYPE", x) < 0)
3228 goto error;
3229 Py_DECREF(x);
3230#endif
3231#ifdef AL_WORDSIZE
3232 x = PyInt_FromLong((long) AL_WORDSIZE);
3233 if (x == NULL || PyDict_SetItemString(d, "WORDSIZE", x) < 0)
3234 goto error;
3235 Py_DECREF(x);
3236#endif
3237
3238#ifdef AL_NO_ELEM /* IRIX 6 */
3239 (void) alSetErrorHandler(ErrorHandler);
3240#endif /* AL_NO_ELEM */
3241#ifdef OLD_INTERFACE
3242 (void) ALseterrorhandler(ErrorHandler);
3243#endif /* OLD_INTERFACE */
Guido van Rossume3db8621991-09-09 23:33:34 +00003244
Guido van Rossumd641d671997-04-03 17:06:32 +00003245 /* Check for errors */
3246 if (PyErr_Occurred()) {
3247 error:
3248 Py_FatalError("can't initialize module al");
3249 }
Guido van Rossume3db8621991-09-09 23:33:34 +00003250}