blob: 6621b9c024f31763f82dd5042738fac9441b5088 [file] [log] [blame]
Guido van Rossume3db8621991-09-09 23:33:34 +00001
Guido van Rossumd641d671997-04-03 17:06:32 +00002#define OLD_INTERFACE /* define for pre-Irix 6 interface */
Jack Jansene8a3c281993-02-10 14:10:56 +00003
Roger E. Massea2a8b271997-01-03 22:40:34 +00004#include "Python.h"
Guido van Rossumd641d671997-04-03 17:06:32 +00005#include "stringobject.h"
6#include <audio.h>
7#include <stdarg.h>
Guido van Rossume3db8621991-09-09 23:33:34 +00008
Guido van Rossumd641d671997-04-03 17:06:32 +00009#ifndef AL_NO_ELEM
10#ifndef OLD_INTERFACE
11#define OLD_INTERFACE
12#endif /* OLD_INTERFACE */
13#endif /* AL_NO_ELEM */
14
15static PyObject *ErrorObject;
16
17/* ----------------------------------------------------- */
18
19/* Declarations for objects of type port */
Guido van Rossume3db8621991-09-09 23:33:34 +000020
21typedef struct {
Roger E. Massea2a8b271997-01-03 22:40:34 +000022 PyObject_HEAD
Guido van Rossumd641d671997-04-03 17:06:32 +000023 /* XXXX Add your own stuff here */
24 ALport port;
25} alpobject;
Guido van Rossume3db8621991-09-09 23:33:34 +000026
Guido van Rossumd641d671997-04-03 17:06:32 +000027staticforward PyTypeObject Alptype;
Guido van Rossume3db8621991-09-09 23:33:34 +000028
Guido van Rossume3db8621991-09-09 23:33:34 +000029
Guido van Rossumd641d671997-04-03 17:06:32 +000030
31/* ---------------------------------------------------------------- */
32
33/* Declarations for objects of type config */
34
35typedef struct {
36 PyObject_HEAD
37 /* XXXX Add your own stuff here */
38 ALconfig config;
39} alcobject;
40
41staticforward PyTypeObject Alctype;
42
43
44static void
45ErrorHandler(long code, const char *fmt, ...)
46{
47 va_list args;
48 char buf[128];
49
50 va_start(args, fmt);
51 vsprintf(buf, fmt, args);
52 va_end(args);
53 PyErr_SetString(ErrorObject, buf);
54}
55
56#ifdef AL_NO_ELEM /* IRIX 6 */
Guido van Rossumfc58e581992-01-27 16:45:55 +000057
Roger E. Massea2a8b271997-01-03 22:40:34 +000058static PyObject *
Guido van Rossumd641d671997-04-03 17:06:32 +000059param2python(int resource, int param, ALvalue value, ALparamInfo *pinfo)
60{
61 ALparamInfo info;
62 PyObject *v;
63
64 if (pinfo == NULL) {
65 pinfo = &info;
66 if (alGetParamInfo(resource, param, &info) < 0)
67 return NULL;
68 }
69 switch (pinfo->elementType) {
70 case AL_PTR_ELEM:
71 /* XXXX don't know how to handle this */
72 case AL_NO_ELEM:
73 Py_INCREF(Py_None);
74 return Py_None;
75 case AL_INT32_ELEM:
76 case AL_RESOURCE_ELEM:
77 case AL_ENUM_ELEM:
78 return PyInt_FromLong((long) value.i);
79 case AL_INT64_ELEM:
80 return PyLong_FromLongLong(value.ll);
81 case AL_FIXED_ELEM:
82 return PyFloat_FromDouble(alFixedToDouble(value.ll));
83 case AL_CHAR_ELEM:
84 if (value.ptr == NULL) {
85 Py_INCREF(Py_None);
86 return Py_None;
87 }
88 return PyString_FromString((char *) value.ptr);
89 default:
90 PyErr_SetString(ErrorObject, "unknown element type");
91 return NULL;
92 }
93}
94
95static int
96python2elem(PyObject *item, void *ptr, int elementType)
97{
98 switch (elementType) {
99 case AL_INT32_ELEM:
100 case AL_RESOURCE_ELEM:
101 case AL_ENUM_ELEM:
102 if (!PyInt_Check(item)) {
103 PyErr_BadArgument();
104 return -1;
105 }
106 *((int *) ptr) = PyInt_AsLong(item);
107 break;
108 case AL_INT64_ELEM:
109 if (PyInt_Check(item))
110 *((long long *) ptr) = PyInt_AsLong(item);
111 else if (PyLong_Check(item))
112 *((long long *) ptr) = PyLong_AsLongLong(item);
113 else {
114 PyErr_BadArgument();
115 return -1;
116 }
117 break;
118 case AL_FIXED_ELEM:
119 if (PyInt_Check(item))
120 *((long long *) ptr) = alDoubleToFixed((double) PyInt_AsLong(item));
121 else if (PyFloat_Check(item))
122 *((long long *) ptr) = alDoubleToFixed(PyFloat_AsDouble(item));
123 else {
124 PyErr_BadArgument();
125 return -1;
126 }
127 break;
128 default:
129 PyErr_SetString(ErrorObject, "unknown element type");
130 return -1;
131 }
132 return 0;
133}
134
135static int
136python2param(int resource, ALpv *param, PyObject *value, ALparamInfo *pinfo)
137{
138 ALparamInfo info;
139 int i, stepsize;
140 PyObject *item;
141
142 if (pinfo == NULL) {
143 pinfo = &info;
144 if (alGetParamInfo(resource, param->param, &info) < 0)
145 return -1;
146 }
147 switch (pinfo->valueType) {
148 case AL_STRING_VAL:
149 if (pinfo->elementType != AL_CHAR_ELEM) {
150 PyErr_SetString(ErrorObject, "unknown element type");
151 return -1;
152 }
153 if (!PyString_Check(value)) {
154 PyErr_BadArgument();
155 return -1;
156 }
157 param->value.ptr = PyString_AS_STRING(value);
158 param->sizeIn = PyString_GET_SIZE(value)+1; /*account for NUL*/
159 break;
160 case AL_SET_VAL:
161 case AL_VECTOR_VAL:
162 if (!PyList_Check(value) && !PyTuple_Check(value)) {
163 PyErr_BadArgument();
164 return -1;
165 }
166 switch (pinfo->elementType) {
167 case AL_INT32_ELEM:
168 case AL_RESOURCE_ELEM:
169 case AL_ENUM_ELEM:
Jeremy Hylton03657cf2000-07-12 13:05:33 +0000170 param->sizeIn = PySequence_Size(value);
Guido van Rossumd641d671997-04-03 17:06:32 +0000171 param->value.ptr = PyMem_NEW(int, param->sizeIn);
172 stepsize = sizeof(int);
173 break;
174 case AL_INT64_ELEM:
175 case AL_FIXED_ELEM:
Jeremy Hylton03657cf2000-07-12 13:05:33 +0000176 param->sizeIn = PySequence_Size(value);
Guido van Rossumd641d671997-04-03 17:06:32 +0000177 param->value.ptr = PyMem_NEW(long long, param->sizeIn);
178 stepsize = sizeof(long long);
179 break;
180 }
181 for (i = 0; i < param->sizeIn; i++) {
182 item = PySequence_GetItem(value, i);
183 if (python2elem(item, (void *) ((char *) param->value.ptr + i*stepsize), pinfo->elementType) < 0) {
184 PyMem_DEL(param->value.ptr);
185 return -1;
186 }
187 }
188 break;
189 case AL_SCALAR_VAL:
190 switch (pinfo->elementType) {
191 case AL_INT32_ELEM:
192 case AL_RESOURCE_ELEM:
193 case AL_ENUM_ELEM:
194 return python2elem(value, (void *) &param->value.i,
195 pinfo->elementType);
Guido van Rossumd641d671997-04-03 17:06:32 +0000196 case AL_INT64_ELEM:
197 case AL_FIXED_ELEM:
198 return python2elem(value, (void *) &param->value.ll,
199 pinfo->elementType);
Guido van Rossumd641d671997-04-03 17:06:32 +0000200 default:
201 PyErr_SetString(ErrorObject, "unknown element type");
202 return -1;
203 }
204 }
205 return 0;
206}
207
208static int
209python2params(int resource1, int resource2, PyObject *list, ALpv **pvsp, ALparamInfo **pinfop)
210{
211 PyObject *item;
212 ALpv *pvs;
213 ALparamInfo *pinfo;
214 int npvs, i;
215
216 npvs = PyList_Size(list);
217 pvs = PyMem_NEW(ALpv, npvs);
218 pinfo = PyMem_NEW(ALparamInfo, npvs);
219 for (i = 0; i < npvs; i++) {
220 item = PyList_GetItem(list, i);
221 if (!PyArg_ParseTuple(item, "iO", &pvs[i].param, &item))
222 goto error;
223 if (alGetParamInfo(resource1, pvs[i].param, &pinfo[i]) < 0 &&
224 alGetParamInfo(resource2, pvs[i].param, &pinfo[i]) < 0)
225 goto error;
226 if (python2param(resource1, &pvs[i], item, &pinfo[i]) < 0)
227 goto error;
228 }
229
230 *pvsp = pvs;
231 *pinfop = pinfo;
232 return npvs;
233
234 error:
235 /* XXXX we should clean up everything */
236 if (pvs)
237 PyMem_DEL(pvs);
238 if (pinfo)
239 PyMem_DEL(pinfo);
240 return -1;
241}
242
243/* -------------------------------------------------------- */
244
245
246static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000247SetConfig(alcobject *self, PyObject *args, int (*func)(ALconfig, int))
Guido van Rossumd641d671997-04-03 17:06:32 +0000248{
249 int par;
250
Guido van Rossum43713e52000-02-29 13:59:29 +0000251 if (!PyArg_ParseTuple(args, "i:SetConfig", &par))
Guido van Rossumd641d671997-04-03 17:06:32 +0000252 return NULL;
253
254 if ((*func)(self->config, par) == -1)
255 return NULL;
256
257 Py_INCREF(Py_None);
Roger E. Massea2a8b271997-01-03 22:40:34 +0000258 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +0000259}
260
Roger E. Massea2a8b271997-01-03 22:40:34 +0000261static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000262GetConfig(alcobject *self, PyObject *args, int (*func)(ALconfig))
Guido van Rossumd641d671997-04-03 17:06:32 +0000263{
264 int par;
265
Guido van Rossum43713e52000-02-29 13:59:29 +0000266 if (!PyArg_ParseTuple(args, ":GetConfig"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000267 return NULL;
268
269 if ((par = (*func)(self->config)) == -1)
270 return NULL;
271
272 return PyInt_FromLong((long) par);
273}
274
275static char alc_SetWidth__doc__[] =
276"alSetWidth: set the wordsize for integer audio data."
277;
278
279static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000280alc_SetWidth(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000281{
282 return SetConfig(self, args, alSetWidth);
283}
284
285
286static char alc_GetWidth__doc__[] =
287"alGetWidth: get the wordsize for integer audio data."
288;
289
290static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000291alc_GetWidth(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000292{
293 return GetConfig(self, args, alGetWidth);
294}
295
296
297static char alc_SetSampFmt__doc__[] =
298"alSetSampFmt: set the sample format setting in an audio ALconfig structure."
299;
300
301static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000302alc_SetSampFmt(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000303{
304 return SetConfig(self, args, alSetSampFmt);
305}
306
307
308static char alc_GetSampFmt__doc__[] =
309"alGetSampFmt: get the sample format setting in an audio ALconfig structure."
310;
311
312static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000313alc_GetSampFmt(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000314{
315 return GetConfig(self, args, alGetSampFmt);
316}
317
318
319static char alc_SetChannels__doc__[] =
320"alSetChannels: set the channel settings in an audio ALconfig."
321;
322
323static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000324alc_SetChannels(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000325{
326 return SetConfig(self, args, alSetChannels);
327}
328
329
330static char alc_GetChannels__doc__[] =
331"alGetChannels: get the channel settings in an audio ALconfig."
332;
333
334static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000335alc_GetChannels(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000336{
337 return GetConfig(self, args, alGetChannels);
338}
339
340
341static char alc_SetFloatMax__doc__[] =
342"alSetFloatMax: set the maximum value of floating point sample data."
343;
344
345static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000346alc_SetFloatMax(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000347{
348 double maximum_value;
349
Guido van Rossum43713e52000-02-29 13:59:29 +0000350 if (!PyArg_ParseTuple(args, "d:SetFloatMax", &maximum_value))
Guido van Rossumd641d671997-04-03 17:06:32 +0000351 return NULL;
352 if (alSetFloatMax(self->config, maximum_value) < 0)
353 return NULL;
354 Py_INCREF(Py_None);
355 return Py_None;
356}
357
358
359static char alc_GetFloatMax__doc__[] =
360"alGetFloatMax: get the maximum value of floating point sample data."
361;
362
363static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000364alc_GetFloatMax(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000365{
366 double maximum_value;
367
Guido van Rossum43713e52000-02-29 13:59:29 +0000368 if (!PyArg_ParseTuple(args, ":GetFloatMax"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000369 return NULL;
370 if ((maximum_value = alGetFloatMax(self->config)) == 0)
371 return NULL;
372 return PyFloat_FromDouble(maximum_value);
373}
374
375
376static char alc_SetDevice__doc__[] =
377"alSetDevice: set the device setting in an audio ALconfig structure."
378;
379
380static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000381alc_SetDevice(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000382{
383 return SetConfig(self, args, alSetDevice);
384}
385
386
387static char alc_GetDevice__doc__[] =
388"alGetDevice: get the device setting in an audio ALconfig structure."
389;
390
391static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000392alc_GetDevice(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000393{
394 return GetConfig(self, args, alGetDevice);
395}
396
397
398static char alc_SetQueueSize__doc__[] =
399"alSetQueueSize: set audio port buffer size."
400;
401
402static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000403alc_SetQueueSize(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000404{
405 return SetConfig(self, args, alSetQueueSize);
406}
407
408
409static char alc_GetQueueSize__doc__[] =
410"alGetQueueSize: get audio port buffer size."
411;
412
413static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000414alc_GetQueueSize(alcobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000415{
416 return GetConfig(self, args, alGetQueueSize);
417}
418
419#endif /* AL_NO_ELEM */
420
421static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000422setconfig(alcobject *self, PyObject *args, int (*func)(ALconfig, long))
Guido van Rossumd641d671997-04-03 17:06:32 +0000423{
424 long par;
425
Guido van Rossum43713e52000-02-29 13:59:29 +0000426 if (!PyArg_ParseTuple(args, "l:SetConfig", &par))
Guido van Rossumd641d671997-04-03 17:06:32 +0000427 return NULL;
428
429 if ((*func)(self->config, par) == -1)
430 return NULL;
431
432 Py_INCREF(Py_None);
433 return Py_None;
434}
435
436static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000437getconfig(alcobject *self, PyObject *args, long (*func)(ALconfig))
Guido van Rossume3db8621991-09-09 23:33:34 +0000438{
439 long par;
440
Guido van Rossum43713e52000-02-29 13:59:29 +0000441 if (!PyArg_ParseTuple(args, ":GetConfig"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000442 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000443
Guido van Rossumd641d671997-04-03 17:06:32 +0000444 if ((par = (*func)(self->config)) == -1)
445 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000446
Guido van Rossumd641d671997-04-03 17:06:32 +0000447 return PyInt_FromLong((long) par);
Guido van Rossume3db8621991-09-09 23:33:34 +0000448}
449
Roger E. Massea2a8b271997-01-03 22:40:34 +0000450static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000451alc_setqueuesize (alcobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000452{
Guido van Rossumd641d671997-04-03 17:06:32 +0000453 return setconfig(self, args, ALsetqueuesize);
Guido van Rossume3db8621991-09-09 23:33:34 +0000454}
455
Roger E. Massea2a8b271997-01-03 22:40:34 +0000456static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000457alc_getqueuesize (alcobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000458{
Guido van Rossumd641d671997-04-03 17:06:32 +0000459 return getconfig(self, args, ALgetqueuesize);
Guido van Rossume3db8621991-09-09 23:33:34 +0000460}
461
Roger E. Massea2a8b271997-01-03 22:40:34 +0000462static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000463alc_setwidth (alcobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000464{
Guido van Rossumd641d671997-04-03 17:06:32 +0000465 return setconfig(self, args, ALsetwidth);
Guido van Rossume3db8621991-09-09 23:33:34 +0000466}
467
Roger E. Massea2a8b271997-01-03 22:40:34 +0000468static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000469alc_getwidth (alcobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000470{
Guido van Rossumd641d671997-04-03 17:06:32 +0000471 return getconfig(self, args, ALgetwidth);
Guido van Rossume3db8621991-09-09 23:33:34 +0000472}
473
Roger E. Massea2a8b271997-01-03 22:40:34 +0000474static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000475alc_getchannels (alcobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000476{
Guido van Rossumd641d671997-04-03 17:06:32 +0000477 return getconfig(self, args, ALgetchannels);
Guido van Rossume3db8621991-09-09 23:33:34 +0000478}
479
Roger E. Massea2a8b271997-01-03 22:40:34 +0000480static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000481alc_setchannels (alcobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000482{
Guido van Rossumd641d671997-04-03 17:06:32 +0000483 return setconfig(self, args, ALsetchannels);
Guido van Rossume3db8621991-09-09 23:33:34 +0000484}
485
Jack Jansene8a3c281993-02-10 14:10:56 +0000486#ifdef AL_405
487
Roger E. Massea2a8b271997-01-03 22:40:34 +0000488static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000489alc_getsampfmt (alcobject *self, PyObject *args)
Jack Jansene8a3c281993-02-10 14:10:56 +0000490{
Guido van Rossumd641d671997-04-03 17:06:32 +0000491 return getconfig(self, args, ALgetsampfmt);
Jack Jansene8a3c281993-02-10 14:10:56 +0000492}
493
Roger E. Massea2a8b271997-01-03 22:40:34 +0000494static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000495alc_setsampfmt (alcobject *self, PyObject *args)
Jack Jansene8a3c281993-02-10 14:10:56 +0000496{
Guido van Rossumd641d671997-04-03 17:06:32 +0000497 return setconfig(self, args, ALsetsampfmt);
Jack Jansene8a3c281993-02-10 14:10:56 +0000498}
499
Roger E. Massea2a8b271997-01-03 22:40:34 +0000500static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000501alc_getfloatmax(alcobject *self, PyObject *args)
Jack Jansene8a3c281993-02-10 14:10:56 +0000502{
503 double arg;
504
Guido van Rossum43713e52000-02-29 13:59:29 +0000505 if (!PyArg_ParseTuple(args, ":GetFloatMax"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000506 return 0;
507 if ((arg = ALgetfloatmax(self->config)) == 0)
508 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000509 return PyFloat_FromDouble(arg);
Jack Jansene8a3c281993-02-10 14:10:56 +0000510}
511
Roger E. Massea2a8b271997-01-03 22:40:34 +0000512static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000513alc_setfloatmax(alcobject *self, PyObject *args)
Jack Jansene8a3c281993-02-10 14:10:56 +0000514{
515 double arg;
516
Guido van Rossum43713e52000-02-29 13:59:29 +0000517 if (!PyArg_ParseTuple(args, "d:SetFloatMax", &arg))
Guido van Rossumd641d671997-04-03 17:06:32 +0000518 return 0;
519 if (ALsetfloatmax(self->config, arg) == -1)
520 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +0000521 Py_INCREF(Py_None);
522 return Py_None;
Jack Jansene8a3c281993-02-10 14:10:56 +0000523}
524#endif /* AL_405 */
525
Guido van Rossumd641d671997-04-03 17:06:32 +0000526static struct PyMethodDef alc_methods[] = {
527#ifdef AL_NO_ELEM /* IRIX 6 */
528 {"SetWidth", (PyCFunction)alc_SetWidth, METH_VARARGS, alc_SetWidth__doc__},
529 {"GetWidth", (PyCFunction)alc_GetWidth, METH_VARARGS, alc_GetWidth__doc__},
530 {"SetSampFmt", (PyCFunction)alc_SetSampFmt, METH_VARARGS, alc_SetSampFmt__doc__},
531 {"GetSampFmt", (PyCFunction)alc_GetSampFmt, METH_VARARGS, alc_GetSampFmt__doc__},
532 {"SetChannels", (PyCFunction)alc_SetChannels, METH_VARARGS, alc_SetChannels__doc__},
533 {"GetChannels", (PyCFunction)alc_GetChannels, METH_VARARGS, alc_GetChannels__doc__},
534 {"SetFloatMax", (PyCFunction)alc_SetFloatMax, METH_VARARGS, alc_SetFloatMax__doc__},
535 {"GetFloatMax", (PyCFunction)alc_GetFloatMax, METH_VARARGS, alc_GetFloatMax__doc__},
536 {"SetDevice", (PyCFunction)alc_SetDevice, METH_VARARGS, alc_SetDevice__doc__},
537 {"GetDevice", (PyCFunction)alc_GetDevice, METH_VARARGS, alc_GetDevice__doc__},
538 {"SetQueueSize", (PyCFunction)alc_SetQueueSize, METH_VARARGS, alc_SetQueueSize__doc__},
539 {"GetQueueSize", (PyCFunction)alc_GetQueueSize, METH_VARARGS, alc_GetQueueSize__doc__},
540#endif /* AL_NO_ELEM */
541 {"getqueuesize", (PyCFunction)alc_getqueuesize, METH_VARARGS},
542 {"setqueuesize", (PyCFunction)alc_setqueuesize, METH_VARARGS},
543 {"getwidth", (PyCFunction)alc_getwidth, METH_VARARGS},
544 {"setwidth", (PyCFunction)alc_setwidth, METH_VARARGS},
545 {"getchannels", (PyCFunction)alc_getchannels, METH_VARARGS},
546 {"setchannels", (PyCFunction)alc_setchannels, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +0000547#ifdef AL_405
Guido van Rossumd641d671997-04-03 17:06:32 +0000548 {"getsampfmt", (PyCFunction)alc_getsampfmt, METH_VARARGS},
549 {"setsampfmt", (PyCFunction)alc_setsampfmt, METH_VARARGS},
550 {"getfloatmax", (PyCFunction)alc_getfloatmax, METH_VARARGS},
551 {"setfloatmax", (PyCFunction)alc_setfloatmax, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +0000552#endif /* AL_405 */
Guido van Rossumd641d671997-04-03 17:06:32 +0000553
554 {NULL, NULL} /* sentinel */
Guido van Rossume3db8621991-09-09 23:33:34 +0000555};
556
Guido van Rossumd641d671997-04-03 17:06:32 +0000557/* ---------- */
558
559
560static PyObject *
561newalcobject(ALconfig config)
Guido van Rossume3db8621991-09-09 23:33:34 +0000562{
Guido van Rossumd641d671997-04-03 17:06:32 +0000563 alcobject *self;
564
Guido van Rossumb18618d2000-05-03 23:44:39 +0000565 self = PyObject_New(alcobject, &Alctype);
Guido van Rossumd641d671997-04-03 17:06:32 +0000566 if (self == NULL)
567 return NULL;
568 /* XXXX Add your own initializers here */
569 self->config = config;
570 return (PyObject *) self;
571}
572
573
574static void
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000575alc_dealloc(alcobject *self)
Guido van Rossumd641d671997-04-03 17:06:32 +0000576{
577 /* XXXX Add your own cleanup code here */
578#ifdef AL_NO_ELEM /* IRIX 6 */
579 (void) alFreeConfig(self->config); /* ignore errors */
580#else
581 (void) ALfreeconfig(self->config); /* ignore errors */
582#endif
Guido van Rossumb18618d2000-05-03 23:44:39 +0000583 PyObject_Del(self);
Guido van Rossume3db8621991-09-09 23:33:34 +0000584}
585
Roger E. Massea2a8b271997-01-03 22:40:34 +0000586static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000587alc_getattr(alcobject *self, char *name)
Guido van Rossume3db8621991-09-09 23:33:34 +0000588{
Guido van Rossumd641d671997-04-03 17:06:32 +0000589 /* XXXX Add your own getattr code here */
590 return Py_FindMethod(alc_methods, (PyObject *)self, name);
Guido van Rossume3db8621991-09-09 23:33:34 +0000591}
592
Guido van Rossumd641d671997-04-03 17:06:32 +0000593static char Alctype__doc__[] =
594""
595;
596
597static PyTypeObject Alctype = {
Roger E. Massea2a8b271997-01-03 22:40:34 +0000598 PyObject_HEAD_INIT(&PyType_Type)
Guido van Rossumd641d671997-04-03 17:06:32 +0000599 0, /*ob_size*/
600 "config", /*tp_name*/
601 sizeof(alcobject), /*tp_basicsize*/
602 0, /*tp_itemsize*/
Guido van Rossume3db8621991-09-09 23:33:34 +0000603 /* methods */
Guido van Rossumd641d671997-04-03 17:06:32 +0000604 (destructor)alc_dealloc, /*tp_dealloc*/
605 (printfunc)0, /*tp_print*/
606 (getattrfunc)alc_getattr, /*tp_getattr*/
607 (setattrfunc)0, /*tp_setattr*/
608 (cmpfunc)0, /*tp_compare*/
609 (reprfunc)0, /*tp_repr*/
610 0, /*tp_as_number*/
611 0, /*tp_as_sequence*/
612 0, /*tp_as_mapping*/
613 (hashfunc)0, /*tp_hash*/
614 (ternaryfunc)0, /*tp_call*/
615 (reprfunc)0, /*tp_str*/
616
617 /* Space for future expansion */
618 0L,0L,0L,0L,
619 Alctype__doc__ /* Documentation string */
Guido van Rossume3db8621991-09-09 23:33:34 +0000620};
621
Guido van Rossumd641d671997-04-03 17:06:32 +0000622/* End of code for config objects */
623/* ---------------------------------------------------------------- */
Guido van Rossume3db8621991-09-09 23:33:34 +0000624
Guido van Rossumd641d671997-04-03 17:06:32 +0000625#ifdef AL_NO_ELEM /* IRIX 6 */
Guido van Rossume3db8621991-09-09 23:33:34 +0000626
Guido van Rossumd641d671997-04-03 17:06:32 +0000627static char alp_SetConfig__doc__[] =
628"alSetConfig: set the ALconfig of an audio ALport."
629;
Guido van Rossume3db8621991-09-09 23:33:34 +0000630
Roger E. Massea2a8b271997-01-03 22:40:34 +0000631static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000632alp_SetConfig(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000633{
Guido van Rossumd641d671997-04-03 17:06:32 +0000634 alcobject *config;
Guido van Rossum43713e52000-02-29 13:59:29 +0000635 if (!PyArg_ParseTuple(args, "O!:SetConfig", &Alctype, &config))
Guido van Rossumd641d671997-04-03 17:06:32 +0000636 return NULL;
637 if (alSetConfig(self->port, config->config) < 0)
638 return NULL;
639 Py_INCREF(Py_None);
Roger E. Massea2a8b271997-01-03 22:40:34 +0000640 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +0000641}
642
Guido van Rossumd641d671997-04-03 17:06:32 +0000643
644static char alp_GetConfig__doc__[] =
645"alGetConfig: get the ALconfig of an audio ALport."
646;
647
Roger E. Massea2a8b271997-01-03 22:40:34 +0000648static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000649alp_GetConfig(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000650{
651 ALconfig config;
Guido van Rossum43713e52000-02-29 13:59:29 +0000652 if (!PyArg_ParseTuple(args, ":GetConfig"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000653 return NULL;
654 if ((config = alGetConfig(self->port)) == NULL)
655 return NULL;
656 return newalcobject(config);
657}
658
659
660static char alp_GetResource__doc__[] =
661"alGetResource: get the resource associated with an audio port."
662;
663
664static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000665alp_GetResource(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000666{
667 int resource;
668
Guido van Rossum43713e52000-02-29 13:59:29 +0000669 if (!PyArg_ParseTuple(args, ":GetResource"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000670 return NULL;
671 if ((resource = alGetResource(self->port)) == 0)
672 return NULL;
673 return PyInt_FromLong((long) resource);
674}
675
676
677static char alp_GetFD__doc__[] =
678"alGetFD: get the file descriptor for an audio port."
679;
680
681static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000682alp_GetFD(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +0000683{
684 int fd;
685
Guido van Rossum43713e52000-02-29 13:59:29 +0000686 if (!PyArg_ParseTuple(args, ":GetFD"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000687 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000688
Guido van Rossumd641d671997-04-03 17:06:32 +0000689 if ((fd = alGetFD(self->port)) < 0)
690 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +0000691
Guido van Rossumd641d671997-04-03 17:06:32 +0000692 return PyInt_FromLong((long) fd);
693}
694
695
696static char alp_GetFilled__doc__[] =
697"alGetFilled: return the number of filled sample frames in an audio port."
698;
699
700static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000701alp_GetFilled(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000702{
703 int filled;
704
Guido van Rossum43713e52000-02-29 13:59:29 +0000705 if (!PyArg_ParseTuple(args, ":GetFilled"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000706 return NULL;
707 if ((filled = alGetFilled(self->port)) < 0)
708 return NULL;
709 return PyInt_FromLong((long) filled);
710}
711
712
713static char alp_GetFillable__doc__[] =
714"alGetFillable: report the number of unfilled sample frames in an audio port."
715;
716
717static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000718alp_GetFillable(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000719{
720 int fillable;
721
Guido van Rossum43713e52000-02-29 13:59:29 +0000722 if (!PyArg_ParseTuple(args, ":GetFillable"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000723 return NULL;
724 if ((fillable = alGetFillable(self->port)) < 0)
725 return NULL;
726 return PyInt_FromLong((long) fillable);
727}
728
729
730static char alp_ReadFrames__doc__[] =
731"alReadFrames: read sample frames from an audio port."
732;
733
734static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000735alp_ReadFrames(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000736{
737 void *samples;
738 int framecount;
739 PyObject *v;
740 int size;
741 int ch;
742 ALconfig c;
743
Guido van Rossum43713e52000-02-29 13:59:29 +0000744 if (!PyArg_ParseTuple(args, "i:ReadFrames", &framecount))
Guido van Rossumd641d671997-04-03 17:06:32 +0000745 return NULL;
746 if (framecount < 0) {
747 PyErr_SetString(ErrorObject, "negative framecount");
748 return NULL;
749 }
750 c = alGetConfig(self->port);
751 switch (alGetSampFmt(c)) {
752 case AL_SAMPFMT_TWOSCOMP:
753 switch (alGetWidth(c)) {
754 case AL_SAMPLE_8:
755 size = 1;
756 break;
757 case AL_SAMPLE_16:
758 size = 2;
759 break;
760 case AL_SAMPLE_24:
761 size = 4;
762 break;
763 default:
764 PyErr_SetString(ErrorObject, "can't determine width");
765 alFreeConfig(c);
766 return NULL;
767 }
768 break;
769 case AL_SAMPFMT_FLOAT:
770 size = 4;
771 break;
772 case AL_SAMPFMT_DOUBLE:
773 size = 8;
774 break;
775 default:
776 PyErr_SetString(ErrorObject, "can't determine format");
777 alFreeConfig(c);
778 return NULL;
779 }
780 ch = alGetChannels(c);
781 alFreeConfig(c);
782 if (ch < 0) {
783 PyErr_SetString(ErrorObject, "can't determine # of channels");
784 return NULL;
785 }
786 size *= ch;
787 v = PyString_FromStringAndSize((char *) NULL, size * framecount);
788 if (v == NULL)
789 return NULL;
790
791 Py_BEGIN_ALLOW_THREADS
792 alReadFrames(self->port, (void *) PyString_AS_STRING(v), framecount);
793 Py_END_ALLOW_THREADS
794
795 return v;
796}
797
798
799static char alp_DiscardFrames__doc__[] =
800"alDiscardFrames: discard audio from an audio port."
801;
802
803static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000804alp_DiscardFrames(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000805{
806 int framecount;
807
Guido van Rossum43713e52000-02-29 13:59:29 +0000808 if (!PyArg_ParseTuple(args, "i:DiscardFrames", &framecount))
Guido van Rossumd641d671997-04-03 17:06:32 +0000809 return NULL;
810
811 Py_BEGIN_ALLOW_THREADS
812 framecount = alDiscardFrames(self->port, framecount);
813 Py_END_ALLOW_THREADS
814
815 if (framecount < 0)
816 return NULL;
817
818 return PyInt_FromLong((long) framecount);
819}
820
821
822static char alp_ZeroFrames__doc__[] =
823"alZeroFrames: write zero-valued sample frames to an audio port."
824;
825
826static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000827alp_ZeroFrames(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000828{
829 int framecount;
830
Guido van Rossum43713e52000-02-29 13:59:29 +0000831 if (!PyArg_ParseTuple(args, "i:ZeroFrames", &framecount))
Guido van Rossumd641d671997-04-03 17:06:32 +0000832 return NULL;
833
834 if (framecount < 0) {
835 PyErr_SetString(ErrorObject, "negative framecount");
836 return NULL;
837 }
838
839 Py_BEGIN_ALLOW_THREADS
840 alZeroFrames(self->port, framecount);
841 Py_END_ALLOW_THREADS
842
843 Py_INCREF(Py_None);
844 return Py_None;
845}
846
847
848static char alp_SetFillPoint__doc__[] =
849"alSetFillPoint: set low- or high-water mark for an audio port."
850;
851
852static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000853alp_SetFillPoint(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000854{
855 int fillpoint;
856
Guido van Rossum43713e52000-02-29 13:59:29 +0000857 if (!PyArg_ParseTuple(args, "i:SetFillPoint", &fillpoint))
Guido van Rossumd641d671997-04-03 17:06:32 +0000858 return NULL;
859
860 if (alSetFillPoint(self->port, fillpoint) < 0)
861 return NULL;
862
863 Py_INCREF(Py_None);
864 return Py_None;
865}
866
867
868static char alp_GetFillPoint__doc__[] =
869"alGetFillPoint: get low- or high-water mark for an audio port."
870;
871
872static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000873alp_GetFillPoint(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000874{
875 int fillpoint;
876
Guido van Rossum43713e52000-02-29 13:59:29 +0000877 if (!PyArg_ParseTuple(args, ":GetFillPoint"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000878 return NULL;
879
880 if ((fillpoint = alGetFillPoint(self->port)) < 0)
881 return NULL;
882
883 return PyInt_FromLong((long) fillpoint);
884}
885
886
887static char alp_GetFrameNumber__doc__[] =
888"alGetFrameNumber: get the absolute sample frame number associated with a port."
889;
890
891static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000892alp_GetFrameNumber(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000893{
894 stamp_t fnum;
895
Guido van Rossum43713e52000-02-29 13:59:29 +0000896 if (!PyArg_ParseTuple(args, ":GetFrameNumber"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000897 return NULL;
898
899 if (alGetFrameNumber(self->port, &fnum) < 0)
900 return NULL;
901
902 return PyLong_FromLongLong((long long) fnum);
903}
904
905
906static char alp_GetFrameTime__doc__[] =
907"alGetFrameTime: get the time at which a sample frame came in or will go out."
908;
909
910static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000911alp_GetFrameTime(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000912{
913 stamp_t fnum, time;
914 PyObject *ret, *v0, *v1;
915
Guido van Rossum43713e52000-02-29 13:59:29 +0000916 if (!PyArg_ParseTuple(args, ":GetFrameTime"))
Guido van Rossumd641d671997-04-03 17:06:32 +0000917 return NULL;
918 if (alGetFrameTime(self->port, &fnum, &time) < 0)
919 return NULL;
920 v0 = PyLong_FromLongLong((long long) fnum);
921 v1 = PyLong_FromLongLong((long long) time);
922 if (PyErr_Occurred()) {
923 Py_XDECREF(v0);
924 Py_XDECREF(v1);
925 return NULL;
926 }
927 ret = Py_BuildValue("(OO)", v0, v1);
928 Py_DECREF(v0);
929 Py_DECREF(v1);
930 return ret;
931}
932
933
934static char alp_WriteFrames__doc__[] =
935"alWriteFrames: write sample frames to an audio port."
936;
937
938static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000939alp_WriteFrames(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +0000940{
941 char *samples;
942 int length;
943 int size, ch;
944 ALconfig c;
945
Guido van Rossum43713e52000-02-29 13:59:29 +0000946 if (!PyArg_ParseTuple(args, "s#:WriteFrames", &samples, &length))
Guido van Rossumd641d671997-04-03 17:06:32 +0000947 return NULL;
948 c = alGetConfig(self->port);
949 switch (alGetSampFmt(c)) {
950 case AL_SAMPFMT_TWOSCOMP:
951 switch (alGetWidth(c)) {
952 case AL_SAMPLE_8:
953 size = 1;
954 break;
955 case AL_SAMPLE_16:
956 size = 2;
957 break;
958 case AL_SAMPLE_24:
959 size = 4;
960 break;
961 default:
962 PyErr_SetString(ErrorObject, "can't determine width");
963 alFreeConfig(c);
964 return NULL;
965 }
966 break;
967 case AL_SAMPFMT_FLOAT:
968 size = 4;
969 break;
970 case AL_SAMPFMT_DOUBLE:
971 size = 8;
972 break;
973 default:
974 PyErr_SetString(ErrorObject, "can't determine format");
975 alFreeConfig(c);
976 return NULL;
977 }
978 ch = alGetChannels(c);
979 alFreeConfig(c);
980 if (ch < 0) {
981 PyErr_SetString(ErrorObject, "can't determine # of channels");
982 return NULL;
983 }
984 size *= ch;
985 if (length % size != 0) {
986 PyErr_SetString(ErrorObject,
987 "buffer length not whole number of frames");
988 return NULL;
989 }
990
991 Py_BEGIN_ALLOW_THREADS
992 alWriteFrames(self->port, (void *) samples, length / size);
993 Py_END_ALLOW_THREADS
994
995 Py_INCREF(Py_None);
996 return Py_None;
997}
998
999
1000static char alp_ClosePort__doc__[] =
1001"alClosePort: close an audio port."
1002;
1003
1004static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001005alp_ClosePort(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001006{
Guido van Rossum43713e52000-02-29 13:59:29 +00001007 if (!PyArg_ParseTuple(args, ":ClosePort"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001008 return NULL;
1009 if (alClosePort(self->port) < 0)
1010 return NULL;
1011 self->port = NULL;
1012 Py_INCREF(Py_None);
1013 return Py_None;
1014}
1015
1016#endif /* AL_NO_ELEM */
1017
1018#ifdef OLD_INTERFACE
1019static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001020alp_closeport(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001021{
Guido van Rossum43713e52000-02-29 13:59:29 +00001022 if (!PyArg_ParseTuple(args, ":ClosePort"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001023 return NULL;
1024 if (ALcloseport(self->port) < 0)
1025 return NULL;
1026 self->port = NULL;
1027 Py_INCREF(Py_None);
1028 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +00001029}
1030
Roger E. Massea2a8b271997-01-03 22:40:34 +00001031static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001032alp_getfd(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001033{
1034 int fd;
1035
Guido van Rossum43713e52000-02-29 13:59:29 +00001036 if (!PyArg_ParseTuple(args, ":GetFD"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001037 return NULL;
1038 if ((fd = ALgetfd(self-> port)) == -1)
1039 return NULL;
1040 return PyInt_FromLong(fd);
1041}
1042
1043static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001044alp_getfilled(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001045{
1046 long count;
1047
Guido van Rossum43713e52000-02-29 13:59:29 +00001048 if (!PyArg_ParseTuple(args, ":GetFilled"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001049 return NULL;
1050 if ((count = ALgetfilled(self-> port)) == -1)
1051 return NULL;
1052 return PyInt_FromLong(count);
Guido van Rossume3db8621991-09-09 23:33:34 +00001053}
1054
Roger E. Massea2a8b271997-01-03 22:40:34 +00001055static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001056alp_getfillable(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001057{
1058 long count;
1059
Guido van Rossum43713e52000-02-29 13:59:29 +00001060 if (!PyArg_ParseTuple(args, ":GetFillable"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001061 return NULL;
1062 if ((count = ALgetfillable(self-> port)) == -1)
1063 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001064 return PyInt_FromLong (count);
Guido van Rossume3db8621991-09-09 23:33:34 +00001065}
1066
Roger E. Massea2a8b271997-01-03 22:40:34 +00001067static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001068alp_readsamps(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001069{
1070 long count;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001071 PyObject *v;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001072 ALconfig c;
Guido van Rossume3db8621991-09-09 23:33:34 +00001073 int width;
Guido van Rossumd641d671997-04-03 17:06:32 +00001074 int ret;
Guido van Rossume3db8621991-09-09 23:33:34 +00001075
Guido van Rossum43713e52000-02-29 13:59:29 +00001076 if (!PyArg_ParseTuple(args, "l:readsamps", &count))
Guido van Rossumd641d671997-04-03 17:06:32 +00001077 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001078
Guido van Rossumd641d671997-04-03 17:06:32 +00001079 if (count <= 0) {
1080 PyErr_SetString(ErrorObject, "al.readsamps : arg <= 0");
Guido van Rossume3db8621991-09-09 23:33:34 +00001081 return NULL;
1082 }
1083
Guido van Rossumd641d671997-04-03 17:06:32 +00001084 c = ALgetconfig(self->port);
Jack Jansene8a3c281993-02-10 14:10:56 +00001085#ifdef AL_405
1086 width = ALgetsampfmt(c);
Guido van Rossumd641d671997-04-03 17:06:32 +00001087 if (width == AL_SAMPFMT_FLOAT)
1088 width = sizeof(float);
1089 else if (width == AL_SAMPFMT_DOUBLE)
1090 width = sizeof(double);
Jack Jansene8a3c281993-02-10 14:10:56 +00001091 else
Guido van Rossumd641d671997-04-03 17:06:32 +00001092 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001093#else
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001094 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001095#endif /* AL_405 */
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001096 ALfreeconfig(c);
Guido van Rossumd641d671997-04-03 17:06:32 +00001097 v = PyString_FromStringAndSize((char *)NULL, width * count);
1098 if (v == NULL)
1099 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001100
Roger E. Massea2a8b271997-01-03 22:40:34 +00001101 Py_BEGIN_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001102 ret = ALreadsamps(self->port, (void *) PyString_AsString(v), count);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001103 Py_END_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001104 if (ret == -1) {
1105 Py_DECREF(v);
1106 return NULL;
1107 }
Guido van Rossume3db8621991-09-09 23:33:34 +00001108
1109 return (v);
1110}
1111
Roger E. Massea2a8b271997-01-03 22:40:34 +00001112static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001113alp_writesamps(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001114{
Guido van Rossumfc58e581992-01-27 16:45:55 +00001115 char *buf;
1116 int size, width;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001117 ALconfig c;
Guido van Rossumd641d671997-04-03 17:06:32 +00001118 int ret;
Guido van Rossume3db8621991-09-09 23:33:34 +00001119
Guido van Rossum43713e52000-02-29 13:59:29 +00001120 if (!PyArg_ParseTuple(args, "s#:writesamps", &buf, &size))
Guido van Rossumd641d671997-04-03 17:06:32 +00001121 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001122
Guido van Rossumd641d671997-04-03 17:06:32 +00001123 c = ALgetconfig(self->port);
Jack Jansene8a3c281993-02-10 14:10:56 +00001124#ifdef AL_405
1125 width = ALgetsampfmt(c);
Guido van Rossumd641d671997-04-03 17:06:32 +00001126 if (width == AL_SAMPFMT_FLOAT)
1127 width = sizeof(float);
1128 else if (width == AL_SAMPFMT_DOUBLE)
1129 width = sizeof(double);
Jack Jansene8a3c281993-02-10 14:10:56 +00001130 else
Guido van Rossumd641d671997-04-03 17:06:32 +00001131 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001132#else
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001133 width = ALgetwidth(c);
Jack Jansene8a3c281993-02-10 14:10:56 +00001134#endif /* AL_405 */
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001135 ALfreeconfig(c);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001136 Py_BEGIN_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001137 ret = ALwritesamps (self->port, (void *) buf, (long) size / width);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001138 Py_END_ALLOW_THREADS
Guido van Rossumd641d671997-04-03 17:06:32 +00001139 if (ret == -1)
1140 return NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001141
Guido van Rossumd641d671997-04-03 17:06:32 +00001142 Py_INCREF(Py_None);
Roger E. Massea2a8b271997-01-03 22:40:34 +00001143 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +00001144}
1145
Roger E. Massea2a8b271997-01-03 22:40:34 +00001146static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001147alp_getfillpoint(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001148{
1149 long count;
1150
Guido van Rossum43713e52000-02-29 13:59:29 +00001151 if (!PyArg_ParseTuple(args, ":GetFillPoint"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001152 return NULL;
1153 if ((count = ALgetfillpoint(self->port)) == -1)
1154 return NULL;
1155 return PyInt_FromLong(count);
Guido van Rossume3db8621991-09-09 23:33:34 +00001156}
1157
Roger E. Massea2a8b271997-01-03 22:40:34 +00001158static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001159alp_setfillpoint(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001160{
1161 long count;
1162
Guido van Rossum43713e52000-02-29 13:59:29 +00001163 if (!PyArg_ParseTuple(args, "l:SetFillPoint", &count))
Guido van Rossumd641d671997-04-03 17:06:32 +00001164 return NULL;
1165 if (ALsetfillpoint(self->port, count) == -1)
1166 return NULL;
1167 Py_INCREF(Py_None);
1168 return Py_None;
Guido van Rossume3db8621991-09-09 23:33:34 +00001169}
1170
Roger E. Massea2a8b271997-01-03 22:40:34 +00001171static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001172alp_setconfig(alpobject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001173{
1174 alcobject *config;
1175
Guido van Rossum43713e52000-02-29 13:59:29 +00001176 if (!PyArg_ParseTuple(args, "O!:SetConfig", &Alctype, &config))
Guido van Rossumd641d671997-04-03 17:06:32 +00001177 return NULL;
1178 if (ALsetconfig(self->port, config->config) == -1)
1179 return NULL;
1180 Py_INCREF(Py_None);
1181 return Py_None;
1182}
1183
1184static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001185alp_getconfig(alpobject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001186{
1187 ALconfig config;
1188
Guido van Rossum43713e52000-02-29 13:59:29 +00001189 if (!PyArg_ParseTuple(args, ":GetConfig"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001190 return NULL;
1191 config = ALgetconfig(self->port);
1192 if (config == NULL)
1193 return NULL;
1194 return newalcobject(config);
Guido van Rossume3db8621991-09-09 23:33:34 +00001195}
1196
Jack Jansene8a3c281993-02-10 14:10:56 +00001197#ifdef AL_405
Roger E. Massea2a8b271997-01-03 22:40:34 +00001198static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001199alp_getstatus(alpobject *self, PyObject *args)
Jack Jansene8a3c281993-02-10 14:10:56 +00001200{
Roger E. Massea2a8b271997-01-03 22:40:34 +00001201 PyObject *list, *v;
Jack Jansene8a3c281993-02-10 14:10:56 +00001202 long *PVbuffer;
1203 long length;
1204 int i;
1205
Guido van Rossumd641d671997-04-03 17:06:32 +00001206 if (!PyArg_Parse(args, "O!", &PyList_Type, &list))
Jack Jansene8a3c281993-02-10 14:10:56 +00001207 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001208 length = PyList_Size(list);
1209 PVbuffer = PyMem_NEW(long, length);
Jack Jansene8a3c281993-02-10 14:10:56 +00001210 if (PVbuffer == NULL)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001211 return PyErr_NoMemory();
Jack Jansene8a3c281993-02-10 14:10:56 +00001212 for (i = 0; i < length; i++) {
Roger E. Massea2a8b271997-01-03 22:40:34 +00001213 v = PyList_GetItem(list, i);
1214 if (!PyInt_Check(v)) {
1215 PyMem_DEL(PVbuffer);
1216 PyErr_BadArgument();
Jack Jansene8a3c281993-02-10 14:10:56 +00001217 return NULL;
1218 }
Roger E. Massea2a8b271997-01-03 22:40:34 +00001219 PVbuffer[i] = PyInt_AsLong(v);
Jack Jansene8a3c281993-02-10 14:10:56 +00001220 }
1221
Guido van Rossumd641d671997-04-03 17:06:32 +00001222 if (ALgetstatus(self->port, PVbuffer, length) == -1)
1223 return NULL;
Jack Jansene8a3c281993-02-10 14:10:56 +00001224
1225 for (i = 0; i < length; i++)
Guido van Rossumd641d671997-04-03 17:06:32 +00001226 PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i]));
Jack Jansene8a3c281993-02-10 14:10:56 +00001227
Roger E. Massea2a8b271997-01-03 22:40:34 +00001228 PyMem_DEL(PVbuffer);
Jack Jansene8a3c281993-02-10 14:10:56 +00001229
Roger E. Massea2a8b271997-01-03 22:40:34 +00001230 Py_INCREF(Py_None);
1231 return Py_None;
Jack Jansene8a3c281993-02-10 14:10:56 +00001232}
1233#endif /* AL_405 */
1234
Guido van Rossumd641d671997-04-03 17:06:32 +00001235#endif /* OLD_INTERFACE */
1236
1237static struct PyMethodDef alp_methods[] = {
1238#ifdef AL_NO_ELEM /* IRIX 6 */
1239 {"SetConfig", (PyCFunction)alp_SetConfig, METH_VARARGS, alp_SetConfig__doc__},
1240 {"GetConfig", (PyCFunction)alp_GetConfig, METH_VARARGS, alp_GetConfig__doc__},
1241 {"GetResource", (PyCFunction)alp_GetResource, METH_VARARGS, alp_GetResource__doc__},
1242 {"GetFD", (PyCFunction)alp_GetFD, METH_VARARGS, alp_GetFD__doc__},
1243 {"GetFilled", (PyCFunction)alp_GetFilled, METH_VARARGS, alp_GetFilled__doc__},
1244 {"GetFillable", (PyCFunction)alp_GetFillable, METH_VARARGS, alp_GetFillable__doc__},
1245 {"ReadFrames", (PyCFunction)alp_ReadFrames, METH_VARARGS, alp_ReadFrames__doc__},
1246 {"DiscardFrames", (PyCFunction)alp_DiscardFrames, METH_VARARGS, alp_DiscardFrames__doc__},
1247 {"ZeroFrames", (PyCFunction)alp_ZeroFrames, METH_VARARGS, alp_ZeroFrames__doc__},
1248 {"SetFillPoint", (PyCFunction)alp_SetFillPoint, METH_VARARGS, alp_SetFillPoint__doc__},
1249 {"GetFillPoint", (PyCFunction)alp_GetFillPoint, METH_VARARGS, alp_GetFillPoint__doc__},
1250 {"GetFrameNumber", (PyCFunction)alp_GetFrameNumber, METH_VARARGS, alp_GetFrameNumber__doc__},
1251 {"GetFrameTime", (PyCFunction)alp_GetFrameTime, METH_VARARGS, alp_GetFrameTime__doc__},
1252 {"WriteFrames", (PyCFunction)alp_WriteFrames, METH_VARARGS, alp_WriteFrames__doc__},
1253 {"ClosePort", (PyCFunction)alp_ClosePort, METH_VARARGS, alp_ClosePort__doc__},
1254#endif /* AL_NO_ELEM */
1255#ifdef OLD_INTERFACE
1256 {"closeport", (PyCFunction)alp_closeport, METH_VARARGS},
1257 {"getfd", (PyCFunction)alp_getfd, METH_VARARGS},
1258 {"fileno", (PyCFunction)alp_getfd, METH_VARARGS},
1259 {"getfilled", (PyCFunction)alp_getfilled, METH_VARARGS},
1260 {"getfillable", (PyCFunction)alp_getfillable, METH_VARARGS},
1261 {"readsamps", (PyCFunction)alp_readsamps, METH_VARARGS},
1262 {"writesamps", (PyCFunction)alp_writesamps, METH_VARARGS},
1263 {"setfillpoint", (PyCFunction)alp_setfillpoint, METH_VARARGS},
1264 {"getfillpoint", (PyCFunction)alp_getfillpoint, METH_VARARGS},
1265 {"setconfig", (PyCFunction)alp_setconfig, METH_VARARGS},
1266 {"getconfig", (PyCFunction)alp_getconfig, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +00001267#ifdef AL_405
Guido van Rossumd641d671997-04-03 17:06:32 +00001268 {"getstatus", (PyCFunction)alp_getstatus, METH_VARARGS},
Jack Jansene8a3c281993-02-10 14:10:56 +00001269#endif /* AL_405 */
Guido van Rossumd641d671997-04-03 17:06:32 +00001270#endif /* OLD_INTERFACE */
1271
1272 {NULL, NULL} /* sentinel */
Guido van Rossume3db8621991-09-09 23:33:34 +00001273};
1274
Guido van Rossumd641d671997-04-03 17:06:32 +00001275/* ---------- */
1276
1277
1278static PyObject *
1279newalpobject(ALport port)
1280{
1281 alpobject *self;
1282
Guido van Rossumb18618d2000-05-03 23:44:39 +00001283 self = PyObject_New(alpobject, &Alptype);
Guido van Rossumd641d671997-04-03 17:06:32 +00001284 if (self == NULL)
1285 return NULL;
1286 /* XXXX Add your own initializers here */
1287 self->port = port;
1288 return (PyObject *) self;
1289}
1290
1291
Guido van Rossume3db8621991-09-09 23:33:34 +00001292static void
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001293alp_dealloc(alpobject *self)
Guido van Rossume3db8621991-09-09 23:33:34 +00001294{
Guido van Rossumd641d671997-04-03 17:06:32 +00001295 /* XXXX Add your own cleanup code here */
1296 if (self->port) {
1297#ifdef AL_NO_ELEM /* IRIX 6 */
1298 alClosePort(self->port);
1299#else
1300 ALcloseport(self->port);
1301#endif
1302 }
Guido van Rossumb18618d2000-05-03 23:44:39 +00001303 PyObject_Del(self);
Guido van Rossume3db8621991-09-09 23:33:34 +00001304}
1305
Roger E. Massea2a8b271997-01-03 22:40:34 +00001306static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001307alp_getattr(alpobject *self, char *name)
Guido van Rossume3db8621991-09-09 23:33:34 +00001308{
Guido van Rossumd641d671997-04-03 17:06:32 +00001309 /* XXXX Add your own getattr code here */
1310 if (self->port == NULL) {
1311 PyErr_SetString(ErrorObject, "port already closed");
1312 return NULL;
1313 }
1314 return Py_FindMethod(alp_methods, (PyObject *)self, name);
Guido van Rossume3db8621991-09-09 23:33:34 +00001315}
1316
Guido van Rossumd641d671997-04-03 17:06:32 +00001317static char Alptype__doc__[] =
1318""
1319;
1320
1321static PyTypeObject Alptype = {
Roger E. Massea2a8b271997-01-03 22:40:34 +00001322 PyObject_HEAD_INIT(&PyType_Type)
Guido van Rossumd641d671997-04-03 17:06:32 +00001323 0, /*ob_size*/
Guido van Rossume3db8621991-09-09 23:33:34 +00001324 "port", /*tp_name*/
Guido van Rossumd641d671997-04-03 17:06:32 +00001325 sizeof(alpobject), /*tp_basicsize*/
1326 0, /*tp_itemsize*/
Guido van Rossume3db8621991-09-09 23:33:34 +00001327 /* methods */
Guido van Rossumd641d671997-04-03 17:06:32 +00001328 (destructor)alp_dealloc, /*tp_dealloc*/
1329 (printfunc)0, /*tp_print*/
1330 (getattrfunc)alp_getattr, /*tp_getattr*/
1331 (setattrfunc)0, /*tp_setattr*/
1332 (cmpfunc)0, /*tp_compare*/
1333 (reprfunc)0, /*tp_repr*/
1334 0, /*tp_as_number*/
1335 0, /*tp_as_sequence*/
1336 0, /*tp_as_mapping*/
1337 (hashfunc)0, /*tp_hash*/
1338 (ternaryfunc)0, /*tp_call*/
1339 (reprfunc)0, /*tp_str*/
1340
1341 /* Space for future expansion */
1342 0L,0L,0L,0L,
1343 Alptype__doc__ /* Documentation string */
Guido van Rossume3db8621991-09-09 23:33:34 +00001344};
1345
Guido van Rossumd641d671997-04-03 17:06:32 +00001346/* End of code for port objects */
1347/* -------------------------------------------------------- */
1348
1349
1350#ifdef AL_NO_ELEM /* IRIX 6 */
1351
1352static char al_NewConfig__doc__[] =
1353"alNewConfig: create and initialize an audio ALconfig structure."
1354;
1355
Roger E. Massea2a8b271997-01-03 22:40:34 +00001356static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001357al_NewConfig(PyObject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001358{
Guido van Rossumd641d671997-04-03 17:06:32 +00001359 ALconfig config;
1360
Guido van Rossum43713e52000-02-29 13:59:29 +00001361 if (!PyArg_ParseTuple(args, ":NewConfig"))
Guido van Rossume3db8621991-09-09 23:33:34 +00001362 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001363 if ((config = alNewConfig()) == NULL)
1364 return NULL;
1365 return newalcobject(config);
Guido van Rossume3db8621991-09-09 23:33:34 +00001366}
1367
Guido van Rossumd641d671997-04-03 17:06:32 +00001368static char al_OpenPort__doc__[] =
1369"alOpenPort: open an audio port."
1370;
Guido van Rossume3db8621991-09-09 23:33:34 +00001371
Roger E. Massea2a8b271997-01-03 22:40:34 +00001372static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001373al_OpenPort(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001374{
1375 ALport port;
1376 char *name, *dir;
1377 alcobject *config = NULL;
1378
Guido van Rossum43713e52000-02-29 13:59:29 +00001379 if (!PyArg_ParseTuple(args, "ss|O!:OpenPort", &name, &dir, &Alctype, &config))
Guido van Rossumd641d671997-04-03 17:06:32 +00001380 return NULL;
1381 if ((port = alOpenPort(name, dir, config ? config->config : NULL)) == NULL)
1382 return NULL;
1383 return newalpobject(port);
1384}
1385
1386static char al_Connect__doc__[] =
1387"alConnect: connect two audio I/O resources."
1388;
1389
1390static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001391al_Connect(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001392{
1393 int source, dest, nprops = 0, id, i;
1394 ALpv *props = NULL;
1395 ALparamInfo *propinfo = NULL;
1396 PyObject *propobj = NULL;
1397
Guido van Rossum43713e52000-02-29 13:59:29 +00001398 if (!PyArg_ParseTuple(args, "ii|O!:Connect", &source, &dest, &PyList_Type, &propobj))
Guido van Rossumd641d671997-04-03 17:06:32 +00001399 return NULL;
1400 if (propobj != NULL) {
1401 nprops = python2params(source, dest, propobj, &props, &propinfo);
1402 if (nprops < 0)
1403 return NULL;
1404 }
1405
1406 id = alConnect(source, dest, props, nprops);
1407
1408 if (props) {
1409 for (i = 0; i < nprops; i++) {
1410 switch (propinfo[i].valueType) {
1411 case AL_SET_VAL:
1412 case AL_VECTOR_VAL:
1413 PyMem_DEL(props[i].value.ptr);
1414 break;
1415 }
1416 }
1417 PyMem_DEL(props);
1418 PyMem_DEL(propinfo);
1419 }
1420
1421 if (id < 0)
1422 return NULL;
1423 return PyInt_FromLong((long) id);
1424}
1425
1426static char al_Disconnect__doc__[] =
1427"alDisconnect: delete a connection between two audio I/O resources."
1428;
1429
1430static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001431al_Disconnect(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001432{
1433 int res;
1434
Guido van Rossum43713e52000-02-29 13:59:29 +00001435 if (!PyArg_ParseTuple(args, "i:Disconnect", &res))
Guido van Rossumd641d671997-04-03 17:06:32 +00001436 return NULL;
1437 if (alDisconnect(res) < 0)
1438 return NULL;
1439 Py_INCREF(Py_None);
1440 return Py_None;
1441}
1442
1443static char al_GetParams__doc__[] =
1444"alGetParams: get the values of audio resource parameters."
1445;
1446
1447static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001448al_GetParams(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001449{
1450 int resource;
1451 PyObject *pvslist, *item = NULL, *v = NULL;
1452 ALpv *pvs;
1453 int i, j, npvs;
1454 ALparamInfo *pinfo;
1455
Guido van Rossum43713e52000-02-29 13:59:29 +00001456 if (!PyArg_ParseTuple(args, "iO!:GetParams", &resource, &PyList_Type, &pvslist))
Guido van Rossumd641d671997-04-03 17:06:32 +00001457 return NULL;
1458 npvs = PyList_Size(pvslist);
1459 pvs = PyMem_NEW(ALpv, npvs);
1460 pinfo = PyMem_NEW(ALparamInfo, npvs);
1461 for (i = 0; i < npvs; i++) {
1462 item = PyList_GetItem(pvslist, i);
1463 if (!PyInt_Check(item)) {
1464 item = NULL;
1465 PyErr_SetString(ErrorObject, "list of integers expected");
1466 goto error;
1467 }
1468 pvs[i].param = (int) PyInt_AsLong(item);
1469 item = NULL; /* not needed anymore */
1470 if (alGetParamInfo(resource, pvs[i].param, &pinfo[i]) < 0)
1471 goto error;
1472 switch (pinfo[i].valueType) {
1473 case AL_NO_VAL:
1474 break;
1475 case AL_MATRIX_VAL:
1476 pinfo[i].maxElems *= pinfo[i].maxElems2;
1477 /* fall through */
1478 case AL_STRING_VAL:
1479 case AL_SET_VAL:
1480 case AL_VECTOR_VAL:
1481 switch (pinfo[i].elementType) {
1482 case AL_INT32_ELEM:
1483 case AL_RESOURCE_ELEM:
1484 case AL_ENUM_ELEM:
1485 pvs[i].value.ptr = PyMem_NEW(int, pinfo[i].maxElems);
1486 pvs[i].sizeIn = pinfo[i].maxElems;
1487 break;
1488 case AL_INT64_ELEM:
1489 case AL_FIXED_ELEM:
1490 pvs[i].value.ptr = PyMem_NEW(long long, pinfo[i].maxElems);
1491 pvs[i].sizeIn = pinfo[i].maxElems;
1492 break;
1493 case AL_CHAR_ELEM:
1494 pvs[i].value.ptr = PyMem_NEW(char, 32);
1495 pvs[i].sizeIn = 32;
1496 break;
1497 case AL_NO_ELEM:
1498 case AL_PTR_ELEM:
1499 default:
1500 PyErr_SetString(ErrorObject, "internal error");
1501 goto error;
1502 }
1503 break;
1504 case AL_SCALAR_VAL:
1505 break;
1506 default:
1507 PyErr_SetString(ErrorObject, "internal error");
1508 goto error;
1509 }
1510 if (pinfo[i].valueType == AL_MATRIX_VAL) {
1511 pinfo[i].maxElems /= pinfo[i].maxElems2;
1512 pvs[i].sizeIn /= pinfo[i].maxElems2;
1513 pvs[i].size2In = pinfo[i].maxElems2;
1514 }
1515 }
1516 if (alGetParams(resource, pvs, npvs) < 0)
1517 goto error;
1518 v = PyList_New(npvs);
1519 for (i = 0; i < npvs; i++) {
1520 if (pvs[i].sizeOut < 0) {
1521 char buf[32];
1522 sprintf(buf, "problem with param %d", i);
1523 PyErr_SetString(ErrorObject, buf);
1524 goto error;
1525 }
1526 switch (pinfo[i].valueType) {
1527 case AL_NO_VAL:
1528 item = Py_None;
1529 Py_INCREF(item);
1530 break;
1531 case AL_STRING_VAL:
1532 item = PyString_FromString(pvs[i].value.ptr);
1533 PyMem_DEL(pvs[i].value.ptr);
1534 break;
1535 case AL_MATRIX_VAL:
1536 /* XXXX this is not right */
1537 pvs[i].sizeOut *= pvs[i].size2Out;
1538 /* fall through */
1539 case AL_SET_VAL:
1540 case AL_VECTOR_VAL:
1541 item = PyList_New(pvs[i].sizeOut);
1542 for (j = 0; j < pvs[i].sizeOut; j++) {
1543 switch (pinfo[i].elementType) {
1544 case AL_INT32_ELEM:
1545 case AL_RESOURCE_ELEM:
1546 case AL_ENUM_ELEM:
1547 PyList_SetItem(item, j, PyInt_FromLong((long) ((int *) pvs[i].value.ptr)[j]));
1548 break;
1549 case AL_INT64_ELEM:
1550 PyList_SetItem(item, j, PyLong_FromLongLong(((long long *) pvs[i].value.ptr)[j]));
1551 break;
1552 case AL_FIXED_ELEM:
1553 PyList_SetItem(item, j, PyFloat_FromDouble(alFixedToDouble(((long long *) pvs[i].value.ptr)[j])));
1554 break;
1555 default:
1556 PyErr_SetString(ErrorObject, "internal error");
1557 goto error;
1558 }
1559 }
1560 PyMem_DEL(pvs[i].value.ptr);
1561 break;
1562 case AL_SCALAR_VAL:
1563 item = param2python(resource, pvs[i].param, pvs[i].value, &pinfo[i]);
1564 break;
1565 }
1566 if (PyErr_Occurred() ||
1567 PyList_SetItem(v, i, Py_BuildValue("(iO)", pvs[i].param,
1568 item)) < 0 ||
1569 PyErr_Occurred())
1570 goto error;
1571 Py_DECREF(item);
1572 }
1573 PyMem_DEL(pvs);
1574 PyMem_DEL(pinfo);
1575 return v;
1576
1577 error:
1578 Py_XDECREF(v);
1579 Py_XDECREF(item);
1580 if (pvs)
1581 PyMem_DEL(pvs);
1582 if (pinfo)
1583 PyMem_DEL(pinfo);
1584 return NULL;
1585}
1586
1587static char al_SetParams__doc__[] =
1588"alSetParams: set the values of audio resource parameters."
1589;
1590
1591static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001592al_SetParams(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001593{
1594 int resource;
1595 PyObject *pvslist, *item;
1596 ALpv *pvs;
1597 ALparamInfo *pinfo;
1598 int npvs, i;
1599
Guido van Rossum43713e52000-02-29 13:59:29 +00001600 if (!PyArg_ParseTuple(args, "iO!:SetParams", &resource, &PyList_Type, &pvslist))
Guido van Rossumd641d671997-04-03 17:06:32 +00001601 return NULL;
1602 npvs = python2params(resource, -1, pvslist, &pvs, &pinfo);
1603 if (npvs < 0)
1604 return NULL;
1605
1606 if (alSetParams(resource, pvs, npvs) < 0)
1607 goto error;
1608
1609 /* cleanup */
1610 for (i = 0; i < npvs; i++) {
1611 switch (pinfo[i].valueType) {
1612 case AL_SET_VAL:
1613 case AL_VECTOR_VAL:
1614 PyMem_DEL(pvs[i].value.ptr);
1615 break;
1616 }
1617 }
1618 PyMem_DEL(pvs);
1619 PyMem_DEL(pinfo);
1620
1621 Py_INCREF(Py_None);
1622 return Py_None;
1623
1624 error:
1625 /* XXXX we should clean up everything */
1626 if (pvs)
1627 PyMem_DEL(pvs);
1628 if (pinfo)
1629 PyMem_DEL(pinfo);
1630 return NULL;
1631}
1632
1633static char al_QueryValues__doc__[] =
1634"alQueryValues: get the set of possible values for a parameter."
1635;
1636
1637static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001638al_QueryValues(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001639{
1640 int resource, param;
1641 ALvalue *return_set = NULL;
1642 int setsize = 32, qualsize = 0, nvals, i;
1643 ALpv *quals = NULL;
1644 ALparamInfo pinfo;
1645 ALparamInfo *qualinfo = NULL;
1646 PyObject *qualobj = NULL;
1647 PyObject *res = NULL, *item;
1648
Guido van Rossum43713e52000-02-29 13:59:29 +00001649 if (!PyArg_ParseTuple(args, "ii|O!:QueryValues", &resource, &param,
Guido van Rossumd641d671997-04-03 17:06:32 +00001650 &PyList_Type, &qualobj))
1651 return NULL;
1652 if (qualobj != NULL) {
1653 qualsize = python2params(resource, param, qualobj, &quals, &qualinfo);
1654 if (qualsize < 0)
1655 return NULL;
1656 }
1657 setsize = 32;
1658 return_set = PyMem_NEW(ALvalue, setsize);
1659 if (return_set == NULL) {
1660 PyErr_NoMemory();
1661 goto cleanup;
1662 }
1663
1664 retry:
1665 nvals = alQueryValues(resource, param, return_set, setsize, quals, qualsize);
1666 if (nvals < 0)
1667 goto cleanup;
1668 if (nvals > setsize) {
1669 setsize = nvals;
1670 PyMem_RESIZE(return_set, ALvalue, setsize);
1671 if (return_set == NULL) {
1672 PyErr_NoMemory();
1673 goto cleanup;
1674 }
1675 goto retry;
1676 }
1677
1678 if (alGetParamInfo(resource, param, &pinfo) < 0)
1679 goto cleanup;
1680
1681 res = PyList_New(nvals);
1682 if (res == NULL)
1683 goto cleanup;
1684 for (i = 0; i < nvals; i++) {
1685 item = param2python(resource, param, return_set[i], &pinfo);
1686 if (item == NULL ||
1687 PyList_SetItem(res, i, item) < 0) {
1688 Py_DECREF(res);
1689 res = NULL;
1690 goto cleanup;
1691 }
1692 }
1693
1694 cleanup:
1695 if (return_set)
1696 PyMem_DEL(return_set);
1697 if (quals) {
1698 for (i = 0; i < qualsize; i++) {
1699 switch (qualinfo[i].valueType) {
1700 case AL_SET_VAL:
1701 case AL_VECTOR_VAL:
1702 PyMem_DEL(quals[i].value.ptr);
1703 break;
1704 }
1705 }
1706 PyMem_DEL(quals);
1707 PyMem_DEL(qualinfo);
1708 }
1709
1710 return res;
1711}
1712
1713static char al_GetParamInfo__doc__[] =
1714"alGetParamInfo: get information about a parameter on a particular audio resource."
1715;
1716
1717static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001718al_GetParamInfo(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001719{
1720 int res, param;
1721 ALparamInfo pinfo;
1722 PyObject *v, *item;;
1723
Guido van Rossum43713e52000-02-29 13:59:29 +00001724 if (!PyArg_ParseTuple(args, "ii:GetParamInfo", &res, &param))
Guido van Rossumd641d671997-04-03 17:06:32 +00001725 return NULL;
1726 if (alGetParamInfo(res, param, &pinfo) < 0)
1727 return NULL;
1728 v = PyDict_New();
1729
1730 item = PyInt_FromLong((long) pinfo.resource);
1731 PyDict_SetItemString(v, "resource", item);
1732 Py_DECREF(item);
1733
1734 item = PyInt_FromLong((long) pinfo.param);
1735 PyDict_SetItemString(v, "param", item);
1736 Py_DECREF(item);
1737
1738 item = PyInt_FromLong((long) pinfo.valueType);
1739 PyDict_SetItemString(v, "valueType", item);
1740 Py_DECREF(item);
1741
1742 if (pinfo.valueType != AL_NO_VAL && pinfo.valueType != AL_SCALAR_VAL) {
1743 /* multiple values */
1744 item = PyInt_FromLong((long) pinfo.maxElems);
1745 PyDict_SetItemString(v, "maxElems", item);
1746 Py_DECREF(item);
1747
1748 if (pinfo.valueType == AL_MATRIX_VAL) {
1749 /* 2 dimensional */
1750 item = PyInt_FromLong((long) pinfo.maxElems2);
1751 PyDict_SetItemString(v, "maxElems2", item);
1752 Py_DECREF(item);
1753 }
1754 }
1755
1756 item = PyInt_FromLong((long) pinfo.elementType);
1757 PyDict_SetItemString(v, "elementType", item);
1758 Py_DECREF(item);
1759
1760 item = PyString_FromString(pinfo.name);
1761 PyDict_SetItemString(v, "name", item);
1762 Py_DECREF(item);
1763
1764 item = param2python(res, param, pinfo.initial, &pinfo);
1765 PyDict_SetItemString(v, "initial", item);
1766 Py_DECREF(item);
1767
1768 if (pinfo.elementType != AL_ENUM_ELEM &&
1769 pinfo.elementType != AL_RESOURCE_ELEM &&
1770 pinfo.elementType != AL_CHAR_ELEM) {
1771 /* range param */
1772 item = param2python(res, param, pinfo.min, &pinfo);
1773 PyDict_SetItemString(v, "min", item);
1774 Py_DECREF(item);
1775
1776 item = param2python(res, param, pinfo.max, &pinfo);
1777 PyDict_SetItemString(v, "max", item);
1778 Py_DECREF(item);
1779
1780 item = param2python(res, param, pinfo.minDelta, &pinfo);
1781 PyDict_SetItemString(v, "minDelta", item);
1782 Py_DECREF(item);
1783
1784 item = param2python(res, param, pinfo.maxDelta, &pinfo);
1785 PyDict_SetItemString(v, "maxDelta", item);
1786 Py_DECREF(item);
1787
1788 item = PyInt_FromLong((long) pinfo.specialVals);
1789 PyDict_SetItemString(v, "specialVals", item);
1790 Py_DECREF(item);
1791 }
1792
1793 return v;
1794}
1795
1796static char al_GetResourceByName__doc__[] =
1797"alGetResourceByName: find an audio resource by name."
1798;
1799
1800static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001801al_GetResourceByName(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001802{
1803 int res, start_res, type;
1804 char *name;
1805
Guido van Rossum43713e52000-02-29 13:59:29 +00001806 if (!PyArg_ParseTuple(args, "isi:GetResourceByName", &start_res, &name, &type))
Guido van Rossumd641d671997-04-03 17:06:32 +00001807 return NULL;
1808 if ((res = alGetResourceByName(start_res, name, type)) == 0)
1809 return NULL;
1810 return PyInt_FromLong((long) res);
1811}
1812
1813static char al_IsSubtype__doc__[] =
1814"alIsSubtype: indicate if one resource type is a subtype of another."
1815;
1816
1817static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001818al_IsSubtype(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001819{
1820 int type, subtype;
1821
Guido van Rossum43713e52000-02-29 13:59:29 +00001822 if (!PyArg_ParseTuple(args, "ii:IsSubtype", &type, &subtype))
Guido van Rossumd641d671997-04-03 17:06:32 +00001823 return NULL;
1824 return PyInt_FromLong((long) alIsSubtype(type, subtype));
1825}
1826
1827static char al_SetErrorHandler__doc__[] =
1828""
1829;
1830
1831static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001832al_SetErrorHandler(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001833{
1834
Guido van Rossum43713e52000-02-29 13:59:29 +00001835 if (!PyArg_ParseTuple(args, ":SetErrorHandler"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001836 return NULL;
1837 Py_INCREF(Py_None);
1838 return Py_None;
1839}
1840
1841#endif /* AL_NO_ELEM */
1842
1843#ifdef OLD_INTERFACE
1844
1845static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001846al_openport(PyObject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001847{
Guido van Rossumfc58e581992-01-27 16:45:55 +00001848 char *name, *dir;
Guido van Rossume3db8621991-09-09 23:33:34 +00001849 ALport port;
Guido van Rossumd641d671997-04-03 17:06:32 +00001850 alcobject *config = NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001851
Guido van Rossum43713e52000-02-29 13:59:29 +00001852 if (!PyArg_ParseTuple(args, "ss|O!:OpenPort", &name, &dir, &Alctype, &config))
Guido van Rossumc0aab891991-10-20 20:10:46 +00001853 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001854 if ((port = ALopenport(name, dir, config ? config->config : NULL)) == NULL)
Guido van Rossume3db8621991-09-09 23:33:34 +00001855 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001856 return newalpobject(port);
Guido van Rossume3db8621991-09-09 23:33:34 +00001857}
1858
Roger E. Massea2a8b271997-01-03 22:40:34 +00001859static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001860al_newconfig(PyObject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001861{
1862 ALconfig config;
1863
Guido van Rossum43713e52000-02-29 13:59:29 +00001864 if (!PyArg_ParseTuple(args, ":NewConfig"))
Guido van Rossumc0aab891991-10-20 20:10:46 +00001865 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001866 if ((config = ALnewconfig ()) == NULL)
1867 return NULL;
1868 return newalcobject(config);
Guido van Rossume3db8621991-09-09 23:33:34 +00001869}
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001870
Roger E. Massea2a8b271997-01-03 22:40:34 +00001871static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001872al_queryparams(PyObject *self, PyObject *args)
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001873{
1874 long device;
1875 long length;
1876 long *PVbuffer;
1877 long PVdummy[2];
Guido van Rossumd641d671997-04-03 17:06:32 +00001878 PyObject *v = NULL;
1879 int i;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001880
Guido van Rossum43713e52000-02-29 13:59:29 +00001881 if (!PyArg_ParseTuple(args, "l:queryparams", &device))
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001882 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001883 if ((length = ALqueryparams(device, PVdummy, 2L)) == -1)
1884 return NULL;
1885 if ((PVbuffer = PyMem_NEW(long, length)) == NULL)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001886 return PyErr_NoMemory();
Guido van Rossumd641d671997-04-03 17:06:32 +00001887 if (ALqueryparams(device, PVbuffer, length) >= 0 &&
1888 (v = PyList_New((int)length)) != NULL) {
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001889 for (i = 0; i < length; i++)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001890 PyList_SetItem(v, i, PyInt_FromLong(PVbuffer[i]));
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001891 }
Roger E. Massea2a8b271997-01-03 22:40:34 +00001892 PyMem_DEL(PVbuffer);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001893 return v;
1894}
1895
Roger E. Massea2a8b271997-01-03 22:40:34 +00001896static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001897doParams(PyObject *args, int (*func)(long, long *, long), int modified)
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001898{
1899 long device;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001900 PyObject *list, *v;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001901 long *PVbuffer;
1902 long length;
1903 int i;
Guido van Rossume3db8621991-09-09 23:33:34 +00001904
Guido van Rossumd641d671997-04-03 17:06:32 +00001905 if (!PyArg_ParseTuple(args, "lO!", &device, &PyList_Type, &list))
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001906 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001907 length = PyList_Size(list);
1908 PVbuffer = PyMem_NEW(long, length);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001909 if (PVbuffer == NULL)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001910 return PyErr_NoMemory();
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001911 for (i = 0; i < length; i++) {
Roger E. Massea2a8b271997-01-03 22:40:34 +00001912 v = PyList_GetItem(list, i);
1913 if (!PyInt_Check(v)) {
1914 PyMem_DEL(PVbuffer);
1915 PyErr_BadArgument();
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001916 return NULL;
1917 }
Roger E. Massea2a8b271997-01-03 22:40:34 +00001918 PVbuffer[i] = PyInt_AsLong(v);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001919 }
1920
Guido van Rossumd641d671997-04-03 17:06:32 +00001921 if ((*func)(device, PVbuffer, length) == -1) {
1922 PyMem_DEL(PVbuffer);
1923 return NULL;
1924 }
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001925
1926 if (modified) {
1927 for (i = 0; i < length; i++)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001928 PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i]));
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001929 }
1930
Roger E. Massea2a8b271997-01-03 22:40:34 +00001931 PyMem_DEL(PVbuffer);
Guido van Rossumc0aab891991-10-20 20:10:46 +00001932
Roger E. Massea2a8b271997-01-03 22:40:34 +00001933 Py_INCREF(Py_None);
1934 return Py_None;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001935}
1936
Roger E. Massea2a8b271997-01-03 22:40:34 +00001937static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001938al_getparams(PyObject *self, PyObject *args)
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001939{
1940 return doParams(args, ALgetparams, 1);
1941}
1942
Roger E. Massea2a8b271997-01-03 22:40:34 +00001943static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001944al_setparams(PyObject *self, PyObject *args)
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001945{
1946 return doParams(args, ALsetparams, 0);
1947}
1948
Roger E. Massea2a8b271997-01-03 22:40:34 +00001949static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001950al_getname(PyObject *self, PyObject *args)
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001951{
1952 long device, descriptor;
1953 char *name;
Guido van Rossumd641d671997-04-03 17:06:32 +00001954
Guido van Rossum43713e52000-02-29 13:59:29 +00001955 if (!PyArg_ParseTuple(args, "ll:getname", &device, &descriptor))
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001956 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001957 if ((name = ALgetname(device, descriptor)) == NULL)
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001958 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001959 return PyString_FromString(name);
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001960}
1961
Roger E. Massea2a8b271997-01-03 22:40:34 +00001962static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001963al_getdefault(PyObject *self, PyObject *args)
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001964{
1965 long device, descriptor, value;
Guido van Rossumd641d671997-04-03 17:06:32 +00001966
Guido van Rossum43713e52000-02-29 13:59:29 +00001967 if (!PyArg_ParseTuple(args, "ll:getdefault", &device, &descriptor))
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001968 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001969 if ((value = ALgetdefault(device, descriptor)) == -1)
1970 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001971 return PyLong_FromLong(value);
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001972}
1973
Roger E. Massea2a8b271997-01-03 22:40:34 +00001974static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001975al_getminmax(PyObject *self, PyObject *args)
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001976{
1977 long device, descriptor, min, max;
Guido van Rossumd641d671997-04-03 17:06:32 +00001978
Guido van Rossum43713e52000-02-29 13:59:29 +00001979 if (!PyArg_ParseTuple(args, "ll:getminmax", &device, &descriptor))
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001980 return NULL;
1981 min = -1;
1982 max = -1;
Guido van Rossumd641d671997-04-03 17:06:32 +00001983 if (ALgetminmax(device, descriptor, &min, &max) == -1)
1984 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001985 return Py_BuildValue("ll", min, max);
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001986}
1987
Guido van Rossumd641d671997-04-03 17:06:32 +00001988#endif /* OLD_INTERFACE */
1989
1990/* List of methods defined in the module */
1991
1992static struct PyMethodDef al_methods[] = {
1993#ifdef AL_NO_ELEM /* IRIX 6 */
1994 {"NewConfig", (PyCFunction)al_NewConfig, METH_VARARGS, al_NewConfig__doc__},
1995 {"OpenPort", (PyCFunction)al_OpenPort, METH_VARARGS, al_OpenPort__doc__},
1996 {"Connect", (PyCFunction)al_Connect, METH_VARARGS, al_Connect__doc__},
1997 {"Disconnect", (PyCFunction)al_Disconnect, METH_VARARGS, al_Disconnect__doc__},
1998 {"GetParams", (PyCFunction)al_GetParams, METH_VARARGS, al_GetParams__doc__},
1999 {"SetParams", (PyCFunction)al_SetParams, METH_VARARGS, al_SetParams__doc__},
2000 {"QueryValues", (PyCFunction)al_QueryValues, METH_VARARGS, al_QueryValues__doc__},
2001 {"GetParamInfo", (PyCFunction)al_GetParamInfo, METH_VARARGS, al_GetParamInfo__doc__},
2002 {"GetResourceByName", (PyCFunction)al_GetResourceByName, METH_VARARGS, al_GetResourceByName__doc__},
2003 {"IsSubtype", (PyCFunction)al_IsSubtype, METH_VARARGS, al_IsSubtype__doc__},
2004#if 0
2005 /* this one not supported */
2006 {"SetErrorHandler", (PyCFunction)al_SetErrorHandler, METH_VARARGS, al_SetErrorHandler__doc__},
2007#endif
2008#endif /* AL_NO_ELEM */
2009#ifdef OLD_INTERFACE
2010 {"openport", (PyCFunction)al_openport, METH_VARARGS},
2011 {"newconfig", (PyCFunction)al_newconfig, METH_VARARGS},
2012 {"queryparams", (PyCFunction)al_queryparams, METH_VARARGS},
2013 {"getparams", (PyCFunction)al_getparams, METH_VARARGS},
2014 {"setparams", (PyCFunction)al_setparams, METH_VARARGS},
2015 {"getname", (PyCFunction)al_getname, METH_VARARGS},
2016 {"getdefault", (PyCFunction)al_getdefault, METH_VARARGS},
2017 {"getminmax", (PyCFunction)al_getminmax, METH_VARARGS},
2018#endif /* OLD_INTERFACE */
2019
2020 {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
Guido van Rossume3db8621991-09-09 23:33:34 +00002021};
2022
Guido van Rossumd641d671997-04-03 17:06:32 +00002023
2024/* Initialization function for the module (*must* be called inital) */
2025
2026static char al_module_documentation[] =
2027""
2028;
2029
Guido van Rossume3db8621991-09-09 23:33:34 +00002030void
Thomas Woutersf3f33dc2000-07-21 06:00:07 +00002031inital(void)
Guido van Rossume3db8621991-09-09 23:33:34 +00002032{
Guido van Rossumd641d671997-04-03 17:06:32 +00002033 PyObject *m, *d, *x;
Guido van Rossume3db8621991-09-09 23:33:34 +00002034
Guido van Rossumd641d671997-04-03 17:06:32 +00002035 /* Create the module and add the functions */
2036 m = Py_InitModule4("al", al_methods,
2037 al_module_documentation,
2038 (PyObject*)NULL,PYTHON_API_VERSION);
2039
2040 /* Add some symbolic constants to the module */
2041 d = PyModule_GetDict(m);
Fred Drake589c35b2000-07-06 19:38:49 +00002042 ErrorObject = PyErr_NewException("al.error", NULL, NULL);
Guido van Rossumd641d671997-04-03 17:06:32 +00002043 PyDict_SetItemString(d, "error", ErrorObject);
2044
2045 /* XXXX Add constants here */
2046#ifdef AL_4CHANNEL
2047 x = PyInt_FromLong((long) AL_4CHANNEL);
2048 if (x == NULL || PyDict_SetItemString(d, "FOURCHANNEL", x) < 0)
2049 goto error;
2050 Py_DECREF(x);
2051#endif
2052#ifdef AL_ADAT_IF_TYPE
2053 x = PyInt_FromLong((long) AL_ADAT_IF_TYPE);
2054 if (x == NULL || PyDict_SetItemString(d, "ADAT_IF_TYPE", x) < 0)
2055 goto error;
2056 Py_DECREF(x);
2057#endif
2058#ifdef AL_ADAT_MCLK_TYPE
2059 x = PyInt_FromLong((long) AL_ADAT_MCLK_TYPE);
2060 if (x == NULL || PyDict_SetItemString(d, "ADAT_MCLK_TYPE", x) < 0)
2061 goto error;
2062 Py_DECREF(x);
2063#endif
2064#ifdef AL_AES_IF_TYPE
2065 x = PyInt_FromLong((long) AL_AES_IF_TYPE);
2066 if (x == NULL || PyDict_SetItemString(d, "AES_IF_TYPE", x) < 0)
2067 goto error;
2068 Py_DECREF(x);
2069#endif
2070#ifdef AL_AES_MCLK_TYPE
2071 x = PyInt_FromLong((long) AL_AES_MCLK_TYPE);
2072 if (x == NULL || PyDict_SetItemString(d, "AES_MCLK_TYPE", x) < 0)
2073 goto error;
2074 Py_DECREF(x);
2075#endif
2076#ifdef AL_ANALOG_IF_TYPE
2077 x = PyInt_FromLong((long) AL_ANALOG_IF_TYPE);
2078 if (x == NULL || PyDict_SetItemString(d, "ANALOG_IF_TYPE", x) < 0)
2079 goto error;
2080 Py_DECREF(x);
2081#endif
2082#ifdef AL_ASSOCIATE
2083 x = PyInt_FromLong((long) AL_ASSOCIATE);
2084 if (x == NULL || PyDict_SetItemString(d, "ASSOCIATE", x) < 0)
2085 goto error;
2086 Py_DECREF(x);
2087#endif
2088#ifdef AL_BAD_BUFFER_NULL
2089 x = PyInt_FromLong((long) AL_BAD_BUFFER_NULL);
2090 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFER_NULL", x) < 0)
2091 goto error;
2092 Py_DECREF(x);
2093#endif
2094#ifdef AL_BAD_BUFFERLENGTH
2095 x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH);
2096 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH", x) < 0)
2097 goto error;
2098 Py_DECREF(x);
2099#endif
2100#ifdef AL_BAD_BUFFERLENGTH_NEG
2101 x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH_NEG);
2102 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_NEG", x) < 0)
2103 goto error;
2104 Py_DECREF(x);
2105#endif
2106#ifdef AL_BAD_BUFFERLENGTH_ODD
2107 x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH_ODD);
2108 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_ODD", x) < 0)
2109 goto error;
2110 Py_DECREF(x);
2111#endif
2112#ifdef AL_BAD_CHANNELS
2113 x = PyInt_FromLong((long) AL_BAD_CHANNELS);
2114 if (x == NULL || PyDict_SetItemString(d, "BAD_CHANNELS", x) < 0)
2115 goto error;
2116 Py_DECREF(x);
2117#endif
2118#ifdef AL_BAD_CONFIG
2119 x = PyInt_FromLong((long) AL_BAD_CONFIG);
2120 if (x == NULL || PyDict_SetItemString(d, "BAD_CONFIG", x) < 0)
2121 goto error;
2122 Py_DECREF(x);
2123#endif
2124#ifdef AL_BAD_COUNT_NEG
2125 x = PyInt_FromLong((long) AL_BAD_COUNT_NEG);
2126 if (x == NULL || PyDict_SetItemString(d, "BAD_COUNT_NEG", x) < 0)
2127 goto error;
2128 Py_DECREF(x);
2129#endif
2130#ifdef AL_BAD_DEVICE
2131 x = PyInt_FromLong((long) AL_BAD_DEVICE);
2132 if (x == NULL || PyDict_SetItemString(d, "BAD_DEVICE", x) < 0)
2133 goto error;
2134 Py_DECREF(x);
2135#endif
2136#ifdef AL_BAD_DEVICE_ACCESS
2137 x = PyInt_FromLong((long) AL_BAD_DEVICE_ACCESS);
2138 if (x == NULL || PyDict_SetItemString(d, "BAD_DEVICE_ACCESS", x) < 0)
2139 goto error;
2140 Py_DECREF(x);
2141#endif
2142#ifdef AL_BAD_DIRECTION
2143 x = PyInt_FromLong((long) AL_BAD_DIRECTION);
2144 if (x == NULL || PyDict_SetItemString(d, "BAD_DIRECTION", x) < 0)
2145 goto error;
2146 Py_DECREF(x);
2147#endif
2148#ifdef AL_BAD_FILLPOINT
2149 x = PyInt_FromLong((long) AL_BAD_FILLPOINT);
2150 if (x == NULL || PyDict_SetItemString(d, "BAD_FILLPOINT", x) < 0)
2151 goto error;
2152 Py_DECREF(x);
2153#endif
2154#ifdef AL_BAD_FLOATMAX
2155 x = PyInt_FromLong((long) AL_BAD_FLOATMAX);
2156 if (x == NULL || PyDict_SetItemString(d, "BAD_FLOATMAX", x) < 0)
2157 goto error;
2158 Py_DECREF(x);
2159#endif
2160#ifdef AL_BAD_ILLEGAL_STATE
2161 x = PyInt_FromLong((long) AL_BAD_ILLEGAL_STATE);
2162 if (x == NULL || PyDict_SetItemString(d, "BAD_ILLEGAL_STATE", x) < 0)
2163 goto error;
2164 Py_DECREF(x);
2165#endif
2166#ifdef AL_BAD_NO_PORTS
2167 x = PyInt_FromLong((long) AL_BAD_NO_PORTS);
2168 if (x == NULL || PyDict_SetItemString(d, "BAD_NO_PORTS", x) < 0)
2169 goto error;
2170 Py_DECREF(x);
2171#endif
2172#ifdef AL_BAD_NOT_FOUND
2173 x = PyInt_FromLong((long) AL_BAD_NOT_FOUND);
2174 if (x == NULL || PyDict_SetItemString(d, "BAD_NOT_FOUND", x) < 0)
2175 goto error;
2176 Py_DECREF(x);
2177#endif
2178#ifdef AL_BAD_NOT_IMPLEMENTED
2179 x = PyInt_FromLong((long) AL_BAD_NOT_IMPLEMENTED);
2180 if (x == NULL || PyDict_SetItemString(d, "BAD_NOT_IMPLEMENTED", x) < 0)
2181 goto error;
2182 Py_DECREF(x);
2183#endif
2184#ifdef AL_BAD_OUT_OF_MEM
2185 x = PyInt_FromLong((long) AL_BAD_OUT_OF_MEM);
2186 if (x == NULL || PyDict_SetItemString(d, "BAD_OUT_OF_MEM", x) < 0)
2187 goto error;
2188 Py_DECREF(x);
2189#endif
2190#ifdef AL_BAD_PARAM
2191 x = PyInt_FromLong((long) AL_BAD_PARAM);
2192 if (x == NULL || PyDict_SetItemString(d, "BAD_PARAM", x) < 0)
2193 goto error;
2194 Py_DECREF(x);
2195#endif
2196#ifdef AL_BAD_PERMISSIONS
2197 x = PyInt_FromLong((long) AL_BAD_PERMISSIONS);
2198 if (x == NULL || PyDict_SetItemString(d, "BAD_PERMISSIONS", x) < 0)
2199 goto error;
2200 Py_DECREF(x);
2201#endif
2202#ifdef AL_BAD_PORT
2203 x = PyInt_FromLong((long) AL_BAD_PORT);
2204 if (x == NULL || PyDict_SetItemString(d, "BAD_PORT", x) < 0)
2205 goto error;
2206 Py_DECREF(x);
2207#endif
2208#ifdef AL_BAD_PORTSTYLE
2209 x = PyInt_FromLong((long) AL_BAD_PORTSTYLE);
2210 if (x == NULL || PyDict_SetItemString(d, "BAD_PORTSTYLE", x) < 0)
2211 goto error;
2212 Py_DECREF(x);
2213#endif
2214#ifdef AL_BAD_PVBUFFER
2215 x = PyInt_FromLong((long) AL_BAD_PVBUFFER);
2216 if (x == NULL || PyDict_SetItemString(d, "BAD_PVBUFFER", x) < 0)
2217 goto error;
2218 Py_DECREF(x);
2219#endif
2220#ifdef AL_BAD_QSIZE
2221 x = PyInt_FromLong((long) AL_BAD_QSIZE);
2222 if (x == NULL || PyDict_SetItemString(d, "BAD_QSIZE", x) < 0)
2223 goto error;
2224 Py_DECREF(x);
2225#endif
2226#ifdef AL_BAD_RATE
2227 x = PyInt_FromLong((long) AL_BAD_RATE);
2228 if (x == NULL || PyDict_SetItemString(d, "BAD_RATE", x) < 0)
2229 goto error;
2230 Py_DECREF(x);
2231#endif
2232#ifdef AL_BAD_RESOURCE
2233 x = PyInt_FromLong((long) AL_BAD_RESOURCE);
2234 if (x == NULL || PyDict_SetItemString(d, "BAD_RESOURCE", x) < 0)
2235 goto error;
2236 Py_DECREF(x);
2237#endif
2238#ifdef AL_BAD_SAMPFMT
2239 x = PyInt_FromLong((long) AL_BAD_SAMPFMT);
2240 if (x == NULL || PyDict_SetItemString(d, "BAD_SAMPFMT", x) < 0)
2241 goto error;
2242 Py_DECREF(x);
2243#endif
2244#ifdef AL_BAD_TRANSFER_SIZE
2245 x = PyInt_FromLong((long) AL_BAD_TRANSFER_SIZE);
2246 if (x == NULL || PyDict_SetItemString(d, "BAD_TRANSFER_SIZE", x) < 0)
2247 goto error;
2248 Py_DECREF(x);
2249#endif
2250#ifdef AL_BAD_WIDTH
2251 x = PyInt_FromLong((long) AL_BAD_WIDTH);
2252 if (x == NULL || PyDict_SetItemString(d, "BAD_WIDTH", x) < 0)
2253 goto error;
2254 Py_DECREF(x);
2255#endif
2256#ifdef AL_CHANNEL_MODE
2257 x = PyInt_FromLong((long) AL_CHANNEL_MODE);
2258 if (x == NULL || PyDict_SetItemString(d, "CHANNEL_MODE", x) < 0)
2259 goto error;
2260 Py_DECREF(x);
2261#endif
2262#ifdef AL_CHANNELS
2263 x = PyInt_FromLong((long) AL_CHANNELS);
2264 if (x == NULL || PyDict_SetItemString(d, "CHANNELS", x) < 0)
2265 goto error;
2266 Py_DECREF(x);
2267#endif
2268#ifdef AL_CHAR_ELEM
2269 x = PyInt_FromLong((long) AL_CHAR_ELEM);
2270 if (x == NULL || PyDict_SetItemString(d, "CHAR_ELEM", x) < 0)
2271 goto error;
2272 Py_DECREF(x);
2273#endif
2274#ifdef AL_CLOCK_GEN
2275 x = PyInt_FromLong((long) AL_CLOCK_GEN);
2276 if (x == NULL || PyDict_SetItemString(d, "CLOCK_GEN", x) < 0)
2277 goto error;
2278 Py_DECREF(x);
2279#endif
2280#ifdef AL_CLOCKGEN_TYPE
2281 x = PyInt_FromLong((long) AL_CLOCKGEN_TYPE);
2282 if (x == NULL || PyDict_SetItemString(d, "CLOCKGEN_TYPE", x) < 0)
2283 goto error;
2284 Py_DECREF(x);
2285#endif
2286#ifdef AL_CONNECT
2287 x = PyInt_FromLong((long) AL_CONNECT);
2288 if (x == NULL || PyDict_SetItemString(d, "CONNECT", x) < 0)
2289 goto error;
2290 Py_DECREF(x);
2291#endif
2292#ifdef AL_CONNECTION_TYPE
2293 x = PyInt_FromLong((long) AL_CONNECTION_TYPE);
2294 if (x == NULL || PyDict_SetItemString(d, "CONNECTION_TYPE", x) < 0)
2295 goto error;
2296 Py_DECREF(x);
2297#endif
2298#ifdef AL_CONNECTIONS
2299 x = PyInt_FromLong((long) AL_CONNECTIONS);
2300 if (x == NULL || PyDict_SetItemString(d, "CONNECTIONS", x) < 0)
2301 goto error;
2302 Py_DECREF(x);
2303#endif
2304#ifdef AL_CRYSTAL_MCLK_TYPE
2305 x = PyInt_FromLong((long) AL_CRYSTAL_MCLK_TYPE);
2306 if (x == NULL || PyDict_SetItemString(d, "CRYSTAL_MCLK_TYPE", x) < 0)
2307 goto error;
2308 Py_DECREF(x);
2309#endif
2310#ifdef AL_DEFAULT_DEVICE
2311 x = PyInt_FromLong((long) AL_DEFAULT_DEVICE);
2312 if (x == NULL || PyDict_SetItemString(d, "DEFAULT_DEVICE", x) < 0)
2313 goto error;
2314 Py_DECREF(x);
2315#endif
2316#ifdef AL_DEFAULT_INPUT
2317 x = PyInt_FromLong((long) AL_DEFAULT_INPUT);
2318 if (x == NULL || PyDict_SetItemString(d, "DEFAULT_INPUT", x) < 0)
2319 goto error;
2320 Py_DECREF(x);
2321#endif
2322#ifdef AL_DEFAULT_OUTPUT
2323 x = PyInt_FromLong((long) AL_DEFAULT_OUTPUT);
2324 if (x == NULL || PyDict_SetItemString(d, "DEFAULT_OUTPUT", x) < 0)
2325 goto error;
2326 Py_DECREF(x);
2327#endif
2328#ifdef AL_DEST
2329 x = PyInt_FromLong((long) AL_DEST);
2330 if (x == NULL || PyDict_SetItemString(d, "DEST", x) < 0)
2331 goto error;
2332 Py_DECREF(x);
2333#endif
2334#ifdef AL_DEVICE_TYPE
2335 x = PyInt_FromLong((long) AL_DEVICE_TYPE);
2336 if (x == NULL || PyDict_SetItemString(d, "DEVICE_TYPE", x) < 0)
2337 goto error;
2338 Py_DECREF(x);
2339#endif
2340#ifdef AL_DEVICES
2341 x = PyInt_FromLong((long) AL_DEVICES);
2342 if (x == NULL || PyDict_SetItemString(d, "DEVICES", x) < 0)
2343 goto error;
2344 Py_DECREF(x);
2345#endif
2346#ifdef AL_DIGITAL_IF_TYPE
2347 x = PyInt_FromLong((long) AL_DIGITAL_IF_TYPE);
2348 if (x == NULL || PyDict_SetItemString(d, "DIGITAL_IF_TYPE", x) < 0)
2349 goto error;
2350 Py_DECREF(x);
2351#endif
2352#ifdef AL_DIGITAL_INPUT_RATE
2353 x = PyInt_FromLong((long) AL_DIGITAL_INPUT_RATE);
2354 if (x == NULL || PyDict_SetItemString(d, "DIGITAL_INPUT_RATE", x) < 0)
2355 goto error;
2356 Py_DECREF(x);
2357#endif
2358#ifdef AL_DISCONNECT
2359 x = PyInt_FromLong((long) AL_DISCONNECT);
2360 if (x == NULL || PyDict_SetItemString(d, "DISCONNECT", x) < 0)
2361 goto error;
2362 Py_DECREF(x);
2363#endif
2364#ifdef AL_ENUM_ELEM
2365 x = PyInt_FromLong((long) AL_ENUM_ELEM);
2366 if (x == NULL || PyDict_SetItemString(d, "ENUM_ELEM", x) < 0)
2367 goto error;
2368 Py_DECREF(x);
2369#endif
2370#ifdef AL_ENUM_VALUE
2371 x = PyInt_FromLong((long) AL_ENUM_VALUE);
2372 if (x == NULL || PyDict_SetItemString(d, "ENUM_VALUE", x) < 0)
2373 goto error;
2374 Py_DECREF(x);
2375#endif
2376#ifdef AL_ERROR_INPUT_OVERFLOW
2377 x = PyInt_FromLong((long) AL_ERROR_INPUT_OVERFLOW);
2378 if (x == NULL || PyDict_SetItemString(d, "ERROR_INPUT_OVERFLOW", x) < 0)
2379 goto error;
2380 Py_DECREF(x);
2381#endif
2382#ifdef AL_ERROR_LENGTH
2383 x = PyInt_FromLong((long) AL_ERROR_LENGTH);
2384 if (x == NULL || PyDict_SetItemString(d, "ERROR_LENGTH", x) < 0)
2385 goto error;
2386 Py_DECREF(x);
2387#endif
2388#ifdef AL_ERROR_LOCATION_LSP
2389 x = PyInt_FromLong((long) AL_ERROR_LOCATION_LSP);
2390 if (x == NULL || PyDict_SetItemString(d, "ERROR_LOCATION_LSP", x) < 0)
2391 goto error;
2392 Py_DECREF(x);
2393#endif
2394#ifdef AL_ERROR_LOCATION_MSP
2395 x = PyInt_FromLong((long) AL_ERROR_LOCATION_MSP);
2396 if (x == NULL || PyDict_SetItemString(d, "ERROR_LOCATION_MSP", x) < 0)
2397 goto error;
2398 Py_DECREF(x);
2399#endif
2400#ifdef AL_ERROR_NUMBER
2401 x = PyInt_FromLong((long) AL_ERROR_NUMBER);
2402 if (x == NULL || PyDict_SetItemString(d, "ERROR_NUMBER", x) < 0)
2403 goto error;
2404 Py_DECREF(x);
2405#endif
2406#ifdef AL_ERROR_OUTPUT_UNDERFLOW
2407 x = PyInt_FromLong((long) AL_ERROR_OUTPUT_UNDERFLOW);
2408 if (x == NULL || PyDict_SetItemString(d, "ERROR_OUTPUT_UNDERFLOW", x) < 0)
2409 goto error;
2410 Py_DECREF(x);
2411#endif
2412#ifdef AL_ERROR_TYPE
2413 x = PyInt_FromLong((long) AL_ERROR_TYPE);
2414 if (x == NULL || PyDict_SetItemString(d, "ERROR_TYPE", x) < 0)
2415 goto error;
2416 Py_DECREF(x);
2417#endif
2418#ifdef AL_FIXED_ELEM
2419 x = PyInt_FromLong((long) AL_FIXED_ELEM);
2420 if (x == NULL || PyDict_SetItemString(d, "FIXED_ELEM", x) < 0)
2421 goto error;
2422 Py_DECREF(x);
2423#endif
2424#ifdef AL_FIXED_MCLK_TYPE
2425 x = PyInt_FromLong((long) AL_FIXED_MCLK_TYPE);
2426 if (x == NULL || PyDict_SetItemString(d, "FIXED_MCLK_TYPE", x) < 0)
2427 goto error;
2428 Py_DECREF(x);
2429#endif
2430#ifdef AL_GAIN
2431 x = PyInt_FromLong((long) AL_GAIN);
2432 if (x == NULL || PyDict_SetItemString(d, "GAIN", x) < 0)
2433 goto error;
2434 Py_DECREF(x);
2435#endif
2436#ifdef AL_GAIN_REF
2437 x = PyInt_FromLong((long) AL_GAIN_REF);
2438 if (x == NULL || PyDict_SetItemString(d, "GAIN_REF", x) < 0)
2439 goto error;
2440 Py_DECREF(x);
2441#endif
2442#ifdef AL_HRB_TYPE
2443 x = PyInt_FromLong((long) AL_HRB_TYPE);
2444 if (x == NULL || PyDict_SetItemString(d, "HRB_TYPE", x) < 0)
2445 goto error;
2446 Py_DECREF(x);
2447#endif
2448#ifdef AL_INPUT_COUNT
2449 x = PyInt_FromLong((long) AL_INPUT_COUNT);
2450 if (x == NULL || PyDict_SetItemString(d, "INPUT_COUNT", x) < 0)
2451 goto error;
2452 Py_DECREF(x);
2453#endif
2454#ifdef AL_INPUT_DEVICE_TYPE
2455 x = PyInt_FromLong((long) AL_INPUT_DEVICE_TYPE);
2456 if (x == NULL || PyDict_SetItemString(d, "INPUT_DEVICE_TYPE", x) < 0)
2457 goto error;
2458 Py_DECREF(x);
2459#endif
2460#ifdef AL_INPUT_DIGITAL
2461 x = PyInt_FromLong((long) AL_INPUT_DIGITAL);
2462 if (x == NULL || PyDict_SetItemString(d, "INPUT_DIGITAL", x) < 0)
2463 goto error;
2464 Py_DECREF(x);
2465#endif
2466#ifdef AL_INPUT_HRB_TYPE
2467 x = PyInt_FromLong((long) AL_INPUT_HRB_TYPE);
2468 if (x == NULL || PyDict_SetItemString(d, "INPUT_HRB_TYPE", x) < 0)
2469 goto error;
2470 Py_DECREF(x);
2471#endif
2472#ifdef AL_INPUT_LINE
2473 x = PyInt_FromLong((long) AL_INPUT_LINE);
2474 if (x == NULL || PyDict_SetItemString(d, "INPUT_LINE", x) < 0)
2475 goto error;
2476 Py_DECREF(x);
2477#endif
2478#ifdef AL_INPUT_MIC
2479 x = PyInt_FromLong((long) AL_INPUT_MIC);
2480 if (x == NULL || PyDict_SetItemString(d, "INPUT_MIC", x) < 0)
2481 goto error;
2482 Py_DECREF(x);
2483#endif
2484#ifdef AL_INPUT_PORT_TYPE
2485 x = PyInt_FromLong((long) AL_INPUT_PORT_TYPE);
2486 if (x == NULL || PyDict_SetItemString(d, "INPUT_PORT_TYPE", x) < 0)
2487 goto error;
2488 Py_DECREF(x);
2489#endif
2490#ifdef AL_INPUT_RATE
2491 x = PyInt_FromLong((long) AL_INPUT_RATE);
2492 if (x == NULL || PyDict_SetItemString(d, "INPUT_RATE", x) < 0)
2493 goto error;
2494 Py_DECREF(x);
2495#endif
2496#ifdef AL_INPUT_SOURCE
2497 x = PyInt_FromLong((long) AL_INPUT_SOURCE);
2498 if (x == NULL || PyDict_SetItemString(d, "INPUT_SOURCE", x) < 0)
2499 goto error;
2500 Py_DECREF(x);
2501#endif
2502#ifdef AL_INT32_ELEM
2503 x = PyInt_FromLong((long) AL_INT32_ELEM);
2504 if (x == NULL || PyDict_SetItemString(d, "INT32_ELEM", x) < 0)
2505 goto error;
2506 Py_DECREF(x);
2507#endif
2508#ifdef AL_INT64_ELEM
2509 x = PyInt_FromLong((long) AL_INT64_ELEM);
2510 if (x == NULL || PyDict_SetItemString(d, "INT64_ELEM", x) < 0)
2511 goto error;
2512 Py_DECREF(x);
2513#endif
2514#ifdef AL_INTERFACE
2515 x = PyInt_FromLong((long) AL_INTERFACE);
2516 if (x == NULL || PyDict_SetItemString(d, "INTERFACE", x) < 0)
2517 goto error;
2518 Py_DECREF(x);
2519#endif
2520#ifdef AL_INTERFACE_TYPE
2521 x = PyInt_FromLong((long) AL_INTERFACE_TYPE);
2522 if (x == NULL || PyDict_SetItemString(d, "INTERFACE_TYPE", x) < 0)
2523 goto error;
2524 Py_DECREF(x);
2525#endif
2526#ifdef AL_INVALID_PARAM
2527 x = PyInt_FromLong((long) AL_INVALID_PARAM);
2528 if (x == NULL || PyDict_SetItemString(d, "INVALID_PARAM", x) < 0)
2529 goto error;
2530 Py_DECREF(x);
2531#endif
2532#ifdef AL_INVALID_VALUE
2533 x = PyInt_FromLong((long) AL_INVALID_VALUE);
2534 if (x == NULL || PyDict_SetItemString(d, "INVALID_VALUE", x) < 0)
2535 goto error;
2536 Py_DECREF(x);
2537#endif
2538#ifdef AL_JITTER
2539 x = PyInt_FromLong((long) AL_JITTER);
2540 if (x == NULL || PyDict_SetItemString(d, "JITTER", x) < 0)
2541 goto error;
2542 Py_DECREF(x);
2543#endif
2544#ifdef AL_LABEL
2545 x = PyInt_FromLong((long) AL_LABEL);
2546 if (x == NULL || PyDict_SetItemString(d, "LABEL", x) < 0)
2547 goto error;
2548 Py_DECREF(x);
2549#endif
2550#ifdef AL_LEFT_INPUT_ATTEN
2551 x = PyInt_FromLong((long) AL_LEFT_INPUT_ATTEN);
2552 if (x == NULL || PyDict_SetItemString(d, "LEFT_INPUT_ATTEN", x) < 0)
2553 goto error;
2554 Py_DECREF(x);
2555#endif
2556#ifdef AL_LEFT_MONITOR_ATTEN
2557 x = PyInt_FromLong((long) AL_LEFT_MONITOR_ATTEN);
2558 if (x == NULL || PyDict_SetItemString(d, "LEFT_MONITOR_ATTEN", x) < 0)
2559 goto error;
2560 Py_DECREF(x);
2561#endif
2562#ifdef AL_LEFT_SPEAKER_GAIN
2563 x = PyInt_FromLong((long) AL_LEFT_SPEAKER_GAIN);
2564 if (x == NULL || PyDict_SetItemString(d, "LEFT_SPEAKER_GAIN", x) < 0)
2565 goto error;
2566 Py_DECREF(x);
2567#endif
2568#ifdef AL_LEFT1_INPUT_ATTEN
2569 x = PyInt_FromLong((long) AL_LEFT1_INPUT_ATTEN);
2570 if (x == NULL || PyDict_SetItemString(d, "LEFT1_INPUT_ATTEN", x) < 0)
2571 goto error;
2572 Py_DECREF(x);
2573#endif
2574#ifdef AL_LEFT2_INPUT_ATTEN
2575 x = PyInt_FromLong((long) AL_LEFT2_INPUT_ATTEN);
2576 if (x == NULL || PyDict_SetItemString(d, "LEFT2_INPUT_ATTEN", x) < 0)
2577 goto error;
2578 Py_DECREF(x);
2579#endif
2580#ifdef AL_LINE_IF_TYPE
2581 x = PyInt_FromLong((long) AL_LINE_IF_TYPE);
2582 if (x == NULL || PyDict_SetItemString(d, "LINE_IF_TYPE", x) < 0)
2583 goto error;
2584 Py_DECREF(x);
2585#endif
2586#ifdef AL_MASTER_CLOCK
2587 x = PyInt_FromLong((long) AL_MASTER_CLOCK);
2588 if (x == NULL || PyDict_SetItemString(d, "MASTER_CLOCK", x) < 0)
2589 goto error;
2590 Py_DECREF(x);
2591#endif
2592#ifdef AL_MATRIX_VAL
2593 x = PyInt_FromLong((long) AL_MATRIX_VAL);
2594 if (x == NULL || PyDict_SetItemString(d, "MATRIX_VAL", x) < 0)
2595 goto error;
2596 Py_DECREF(x);
2597#endif
2598#ifdef AL_MAX_ERROR
2599 x = PyInt_FromLong((long) AL_MAX_ERROR);
2600 if (x == NULL || PyDict_SetItemString(d, "MAX_ERROR", x) < 0)
2601 goto error;
2602 Py_DECREF(x);
2603#endif
2604#ifdef AL_MAX_EVENT_PARAM
2605 x = PyInt_FromLong((long) AL_MAX_EVENT_PARAM);
2606 if (x == NULL || PyDict_SetItemString(d, "MAX_EVENT_PARAM", x) < 0)
2607 goto error;
2608 Py_DECREF(x);
2609#endif
2610#ifdef AL_MAX_PBUFSIZE
2611 x = PyInt_FromLong((long) AL_MAX_PBUFSIZE);
2612 if (x == NULL || PyDict_SetItemString(d, "MAX_PBUFSIZE", x) < 0)
2613 goto error;
2614 Py_DECREF(x);
2615#endif
2616#ifdef AL_MAX_PORTS
2617 x = PyInt_FromLong((long) AL_MAX_PORTS);
2618 if (x == NULL || PyDict_SetItemString(d, "MAX_PORTS", x) < 0)
2619 goto error;
2620 Py_DECREF(x);
2621#endif
2622#ifdef AL_MAX_RESOURCE_ID
2623 x = PyInt_FromLong((long) AL_MAX_RESOURCE_ID);
2624 if (x == NULL || PyDict_SetItemString(d, "MAX_RESOURCE_ID", x) < 0)
2625 goto error;
2626 Py_DECREF(x);
2627#endif
2628#ifdef AL_MAX_SETSIZE
2629 x = PyInt_FromLong((long) AL_MAX_SETSIZE);
2630 if (x == NULL || PyDict_SetItemString(d, "MAX_SETSIZE", x) < 0)
2631 goto error;
2632 Py_DECREF(x);
2633#endif
2634#ifdef AL_MAX_STRLEN
2635 x = PyInt_FromLong((long) AL_MAX_STRLEN);
2636 if (x == NULL || PyDict_SetItemString(d, "MAX_STRLEN", x) < 0)
2637 goto error;
2638 Py_DECREF(x);
2639#endif
2640#ifdef AL_MCLK_TYPE
2641 x = PyInt_FromLong((long) AL_MCLK_TYPE);
2642 if (x == NULL || PyDict_SetItemString(d, "MCLK_TYPE", x) < 0)
2643 goto error;
2644 Py_DECREF(x);
2645#endif
2646#ifdef AL_MIC_IF_TYPE
2647 x = PyInt_FromLong((long) AL_MIC_IF_TYPE);
2648 if (x == NULL || PyDict_SetItemString(d, "MIC_IF_TYPE", x) < 0)
2649 goto error;
2650 Py_DECREF(x);
2651#endif
2652#ifdef AL_MONITOR_CTL
2653 x = PyInt_FromLong((long) AL_MONITOR_CTL);
2654 if (x == NULL || PyDict_SetItemString(d, "MONITOR_CTL", x) < 0)
2655 goto error;
2656 Py_DECREF(x);
2657#endif
2658#ifdef AL_MONITOR_OFF
2659 x = PyInt_FromLong((long) AL_MONITOR_OFF);
2660 if (x == NULL || PyDict_SetItemString(d, "MONITOR_OFF", x) < 0)
2661 goto error;
2662 Py_DECREF(x);
2663#endif
2664#ifdef AL_MONITOR_ON
2665 x = PyInt_FromLong((long) AL_MONITOR_ON);
2666 if (x == NULL || PyDict_SetItemString(d, "MONITOR_ON", x) < 0)
2667 goto error;
2668 Py_DECREF(x);
2669#endif
2670#ifdef AL_MONO
2671 x = PyInt_FromLong((long) AL_MONO);
2672 if (x == NULL || PyDict_SetItemString(d, "MONO", x) < 0)
2673 goto error;
2674 Py_DECREF(x);
2675#endif
2676#ifdef AL_MUTE
2677 x = PyInt_FromLong((long) AL_MUTE);
2678 if (x == NULL || PyDict_SetItemString(d, "MUTE", x) < 0)
2679 goto error;
2680 Py_DECREF(x);
2681#endif
2682#ifdef AL_NAME
2683 x = PyInt_FromLong((long) AL_NAME);
2684 if (x == NULL || PyDict_SetItemString(d, "NAME", x) < 0)
2685 goto error;
2686 Py_DECREF(x);
2687#endif
2688#ifdef AL_NEG_INFINITY
2689 x = PyInt_FromLong((long) AL_NEG_INFINITY);
2690 if (x == NULL || PyDict_SetItemString(d, "NEG_INFINITY", x) < 0)
2691 goto error;
2692 Py_DECREF(x);
2693#endif
2694#ifdef AL_NEG_INFINITY_BIT
2695 x = PyInt_FromLong((long) AL_NEG_INFINITY_BIT);
2696 if (x == NULL || PyDict_SetItemString(d, "NEG_INFINITY_BIT", x) < 0)
2697 goto error;
2698 Py_DECREF(x);
2699#endif
2700#ifdef AL_NO_CHANGE
2701 x = PyInt_FromLong((long) AL_NO_CHANGE);
2702 if (x == NULL || PyDict_SetItemString(d, "NO_CHANGE", x) < 0)
2703 goto error;
2704 Py_DECREF(x);
2705#endif
2706#ifdef AL_NO_CHANGE_BIT
2707 x = PyInt_FromLong((long) AL_NO_CHANGE_BIT);
2708 if (x == NULL || PyDict_SetItemString(d, "NO_CHANGE_BIT", x) < 0)
2709 goto error;
2710 Py_DECREF(x);
2711#endif
2712#ifdef AL_NO_ELEM
2713 x = PyInt_FromLong((long) AL_NO_ELEM);
2714 if (x == NULL || PyDict_SetItemString(d, "NO_ELEM", x) < 0)
2715 goto error;
2716 Py_DECREF(x);
2717#endif
2718#ifdef AL_NO_ERRORS
2719 x = PyInt_FromLong((long) AL_NO_ERRORS);
2720 if (x == NULL || PyDict_SetItemString(d, "NO_ERRORS", x) < 0)
2721 goto error;
2722 Py_DECREF(x);
2723#endif
2724#ifdef AL_NO_OP
2725 x = PyInt_FromLong((long) AL_NO_OP);
2726 if (x == NULL || PyDict_SetItemString(d, "NO_OP", x) < 0)
2727 goto error;
2728 Py_DECREF(x);
2729#endif
2730#ifdef AL_NO_VAL
2731 x = PyInt_FromLong((long) AL_NO_VAL);
2732 if (x == NULL || PyDict_SetItemString(d, "NO_VAL", x) < 0)
2733 goto error;
2734 Py_DECREF(x);
2735#endif
2736#ifdef AL_NULL_RESOURCE
2737 x = PyInt_FromLong((long) AL_NULL_RESOURCE);
2738 if (x == NULL || PyDict_SetItemString(d, "NULL_RESOURCE", x) < 0)
2739 goto error;
2740 Py_DECREF(x);
2741#endif
2742#ifdef AL_OUTPUT_COUNT
2743 x = PyInt_FromLong((long) AL_OUTPUT_COUNT);
2744 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_COUNT", x) < 0)
2745 goto error;
2746 Py_DECREF(x);
2747#endif
2748#ifdef AL_OUTPUT_DEVICE_TYPE
2749 x = PyInt_FromLong((long) AL_OUTPUT_DEVICE_TYPE);
2750 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_DEVICE_TYPE", x) < 0)
2751 goto error;
2752 Py_DECREF(x);
2753#endif
2754#ifdef AL_OUTPUT_HRB_TYPE
2755 x = PyInt_FromLong((long) AL_OUTPUT_HRB_TYPE);
2756 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_HRB_TYPE", x) < 0)
2757 goto error;
2758 Py_DECREF(x);
2759#endif
2760#ifdef AL_OUTPUT_PORT_TYPE
2761 x = PyInt_FromLong((long) AL_OUTPUT_PORT_TYPE);
2762 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_PORT_TYPE", x) < 0)
2763 goto error;
2764 Py_DECREF(x);
2765#endif
2766#ifdef AL_OUTPUT_RATE
2767 x = PyInt_FromLong((long) AL_OUTPUT_RATE);
2768 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_RATE", x) < 0)
2769 goto error;
2770 Py_DECREF(x);
2771#endif
2772#ifdef AL_PARAM_BIT
2773 x = PyInt_FromLong((long) AL_PARAM_BIT);
2774 if (x == NULL || PyDict_SetItemString(d, "PARAM_BIT", x) < 0)
2775 goto error;
2776 Py_DECREF(x);
2777#endif
2778#ifdef AL_PARAMS
2779 x = PyInt_FromLong((long) AL_PARAMS);
2780 if (x == NULL || PyDict_SetItemString(d, "PARAMS", x) < 0)
2781 goto error;
2782 Py_DECREF(x);
2783#endif
2784#ifdef AL_PORT_COUNT
2785 x = PyInt_FromLong((long) AL_PORT_COUNT);
2786 if (x == NULL || PyDict_SetItemString(d, "PORT_COUNT", x) < 0)
2787 goto error;
2788 Py_DECREF(x);
2789#endif
2790#ifdef AL_PORT_TYPE
2791 x = PyInt_FromLong((long) AL_PORT_TYPE);
2792 if (x == NULL || PyDict_SetItemString(d, "PORT_TYPE", x) < 0)
2793 goto error;
2794 Py_DECREF(x);
2795#endif
2796#ifdef AL_PORTS
2797 x = PyInt_FromLong((long) AL_PORTS);
2798 if (x == NULL || PyDict_SetItemString(d, "PORTS", x) < 0)
2799 goto error;
2800 Py_DECREF(x);
2801#endif
2802#ifdef AL_PORTSTYLE_DIRECT
2803 x = PyInt_FromLong((long) AL_PORTSTYLE_DIRECT);
2804 if (x == NULL || PyDict_SetItemString(d, "PORTSTYLE_DIRECT", x) < 0)
2805 goto error;
2806 Py_DECREF(x);
2807#endif
2808#ifdef AL_PORTSTYLE_SERIAL
2809 x = PyInt_FromLong((long) AL_PORTSTYLE_SERIAL);
2810 if (x == NULL || PyDict_SetItemString(d, "PORTSTYLE_SERIAL", x) < 0)
2811 goto error;
2812 Py_DECREF(x);
2813#endif
2814#ifdef AL_PRINT_ERRORS
2815 x = PyInt_FromLong((long) AL_PRINT_ERRORS);
2816 if (x == NULL || PyDict_SetItemString(d, "PRINT_ERRORS", x) < 0)
2817 goto error;
2818 Py_DECREF(x);
2819#endif
2820#ifdef AL_PTR_ELEM
2821 x = PyInt_FromLong((long) AL_PTR_ELEM);
2822 if (x == NULL || PyDict_SetItemString(d, "PTR_ELEM", x) < 0)
2823 goto error;
2824 Py_DECREF(x);
2825#endif
2826#ifdef AL_RANGE_VALUE
2827 x = PyInt_FromLong((long) AL_RANGE_VALUE);
2828 if (x == NULL || PyDict_SetItemString(d, "RANGE_VALUE", x) < 0)
2829 goto error;
2830 Py_DECREF(x);
2831#endif
2832#ifdef AL_RATE
2833 x = PyInt_FromLong((long) AL_RATE);
2834 if (x == NULL || PyDict_SetItemString(d, "RATE", x) < 0)
2835 goto error;
2836 Py_DECREF(x);
2837#endif
2838#ifdef AL_RATE_11025
2839 x = PyInt_FromLong((long) AL_RATE_11025);
2840 if (x == NULL || PyDict_SetItemString(d, "RATE_11025", x) < 0)
2841 goto error;
2842 Py_DECREF(x);
2843#endif
2844#ifdef AL_RATE_16000
2845 x = PyInt_FromLong((long) AL_RATE_16000);
2846 if (x == NULL || PyDict_SetItemString(d, "RATE_16000", x) < 0)
2847 goto error;
2848 Py_DECREF(x);
2849#endif
2850#ifdef AL_RATE_22050
2851 x = PyInt_FromLong((long) AL_RATE_22050);
2852 if (x == NULL || PyDict_SetItemString(d, "RATE_22050", x) < 0)
2853 goto error;
2854 Py_DECREF(x);
2855#endif
2856#ifdef AL_RATE_32000
2857 x = PyInt_FromLong((long) AL_RATE_32000);
2858 if (x == NULL || PyDict_SetItemString(d, "RATE_32000", x) < 0)
2859 goto error;
2860 Py_DECREF(x);
2861#endif
2862#ifdef AL_RATE_44100
2863 x = PyInt_FromLong((long) AL_RATE_44100);
2864 if (x == NULL || PyDict_SetItemString(d, "RATE_44100", x) < 0)
2865 goto error;
2866 Py_DECREF(x);
2867#endif
2868#ifdef AL_RATE_48000
2869 x = PyInt_FromLong((long) AL_RATE_48000);
2870 if (x == NULL || PyDict_SetItemString(d, "RATE_48000", x) < 0)
2871 goto error;
2872 Py_DECREF(x);
2873#endif
2874#ifdef AL_RATE_8000
2875 x = PyInt_FromLong((long) AL_RATE_8000);
2876 if (x == NULL || PyDict_SetItemString(d, "RATE_8000", x) < 0)
2877 goto error;
2878 Py_DECREF(x);
2879#endif
2880#ifdef AL_RATE_AES_1
2881 x = PyInt_FromLong((long) AL_RATE_AES_1);
2882 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_1", x) < 0)
2883 goto error;
2884 Py_DECREF(x);
2885#endif
2886#ifdef AL_RATE_AES_1s
2887 x = PyInt_FromLong((long) AL_RATE_AES_1s);
2888 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_1s", x) < 0)
2889 goto error;
2890 Py_DECREF(x);
2891#endif
2892#ifdef AL_RATE_AES_2
2893 x = PyInt_FromLong((long) AL_RATE_AES_2);
2894 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_2", x) < 0)
2895 goto error;
2896 Py_DECREF(x);
2897#endif
2898#ifdef AL_RATE_AES_3
2899 x = PyInt_FromLong((long) AL_RATE_AES_3);
2900 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_3", x) < 0)
2901 goto error;
2902 Py_DECREF(x);
2903#endif
2904#ifdef AL_RATE_AES_4
2905 x = PyInt_FromLong((long) AL_RATE_AES_4);
2906 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_4", x) < 0)
2907 goto error;
2908 Py_DECREF(x);
2909#endif
2910#ifdef AL_RATE_AES_6
2911 x = PyInt_FromLong((long) AL_RATE_AES_6);
2912 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_6", x) < 0)
2913 goto error;
2914 Py_DECREF(x);
2915#endif
2916#ifdef AL_RATE_FRACTION_D
2917 x = PyInt_FromLong((long) AL_RATE_FRACTION_D);
2918 if (x == NULL || PyDict_SetItemString(d, "RATE_FRACTION_D", x) < 0)
2919 goto error;
2920 Py_DECREF(x);
2921#endif
2922#ifdef AL_RATE_FRACTION_N
2923 x = PyInt_FromLong((long) AL_RATE_FRACTION_N);
2924 if (x == NULL || PyDict_SetItemString(d, "RATE_FRACTION_N", x) < 0)
2925 goto error;
2926 Py_DECREF(x);
2927#endif
2928#ifdef AL_RATE_INPUTRATE
2929 x = PyInt_FromLong((long) AL_RATE_INPUTRATE);
2930 if (x == NULL || PyDict_SetItemString(d, "RATE_INPUTRATE", x) < 0)
2931 goto error;
2932 Py_DECREF(x);
2933#endif
2934#ifdef AL_RATE_NO_DIGITAL_INPUT
2935 x = PyInt_FromLong((long) AL_RATE_NO_DIGITAL_INPUT);
2936 if (x == NULL || PyDict_SetItemString(d, "RATE_NO_DIGITAL_INPUT", x) < 0)
2937 goto error;
2938 Py_DECREF(x);
2939#endif
2940#ifdef AL_RATE_UNACQUIRED
2941 x = PyInt_FromLong((long) AL_RATE_UNACQUIRED);
2942 if (x == NULL || PyDict_SetItemString(d, "RATE_UNACQUIRED", x) < 0)
2943 goto error;
2944 Py_DECREF(x);
2945#endif
2946#ifdef AL_RATE_UNDEFINED
2947 x = PyInt_FromLong((long) AL_RATE_UNDEFINED);
2948 if (x == NULL || PyDict_SetItemString(d, "RATE_UNDEFINED", x) < 0)
2949 goto error;
2950 Py_DECREF(x);
2951#endif
2952#ifdef AL_REF_0DBV
2953 x = PyInt_FromLong((long) AL_REF_0DBV);
2954 if (x == NULL || PyDict_SetItemString(d, "REF_0DBV", x) < 0)
2955 goto error;
2956 Py_DECREF(x);
2957#endif
2958#ifdef AL_REF_NONE
2959 x = PyInt_FromLong((long) AL_REF_NONE);
2960 if (x == NULL || PyDict_SetItemString(d, "REF_NONE", x) < 0)
2961 goto error;
2962 Py_DECREF(x);
2963#endif
2964#ifdef AL_RESERVED1_TYPE
2965 x = PyInt_FromLong((long) AL_RESERVED1_TYPE);
2966 if (x == NULL || PyDict_SetItemString(d, "RESERVED1_TYPE", x) < 0)
2967 goto error;
2968 Py_DECREF(x);
2969#endif
2970#ifdef AL_RESERVED2_TYPE
2971 x = PyInt_FromLong((long) AL_RESERVED2_TYPE);
2972 if (x == NULL || PyDict_SetItemString(d, "RESERVED2_TYPE", x) < 0)
2973 goto error;
2974 Py_DECREF(x);
2975#endif
2976#ifdef AL_RESERVED3_TYPE
2977 x = PyInt_FromLong((long) AL_RESERVED3_TYPE);
2978 if (x == NULL || PyDict_SetItemString(d, "RESERVED3_TYPE", x) < 0)
2979 goto error;
2980 Py_DECREF(x);
2981#endif
2982#ifdef AL_RESERVED4_TYPE
2983 x = PyInt_FromLong((long) AL_RESERVED4_TYPE);
2984 if (x == NULL || PyDict_SetItemString(d, "RESERVED4_TYPE", x) < 0)
2985 goto error;
2986 Py_DECREF(x);
2987#endif
2988#ifdef AL_RESOURCE
2989 x = PyInt_FromLong((long) AL_RESOURCE);
2990 if (x == NULL || PyDict_SetItemString(d, "RESOURCE", x) < 0)
2991 goto error;
2992 Py_DECREF(x);
2993#endif
2994#ifdef AL_RESOURCE_ELEM
2995 x = PyInt_FromLong((long) AL_RESOURCE_ELEM);
2996 if (x == NULL || PyDict_SetItemString(d, "RESOURCE_ELEM", x) < 0)
2997 goto error;
2998 Py_DECREF(x);
2999#endif
3000#ifdef AL_RESOURCE_TYPE
3001 x = PyInt_FromLong((long) AL_RESOURCE_TYPE);
3002 if (x == NULL || PyDict_SetItemString(d, "RESOURCE_TYPE", x) < 0)
3003 goto error;
3004 Py_DECREF(x);
3005#endif
3006#ifdef AL_RIGHT_INPUT_ATTEN
3007 x = PyInt_FromLong((long) AL_RIGHT_INPUT_ATTEN);
3008 if (x == NULL || PyDict_SetItemString(d, "RIGHT_INPUT_ATTEN", x) < 0)
3009 goto error;
3010 Py_DECREF(x);
3011#endif
3012#ifdef AL_RIGHT_MONITOR_ATTEN
3013 x = PyInt_FromLong((long) AL_RIGHT_MONITOR_ATTEN);
3014 if (x == NULL || PyDict_SetItemString(d, "RIGHT_MONITOR_ATTEN", x) < 0)
3015 goto error;
3016 Py_DECREF(x);
3017#endif
3018#ifdef AL_RIGHT_SPEAKER_GAIN
3019 x = PyInt_FromLong((long) AL_RIGHT_SPEAKER_GAIN);
3020 if (x == NULL || PyDict_SetItemString(d, "RIGHT_SPEAKER_GAIN", x) < 0)
3021 goto error;
3022 Py_DECREF(x);
3023#endif
3024#ifdef AL_RIGHT1_INPUT_ATTEN
3025 x = PyInt_FromLong((long) AL_RIGHT1_INPUT_ATTEN);
3026 if (x == NULL || PyDict_SetItemString(d, "RIGHT1_INPUT_ATTEN", x) < 0)
3027 goto error;
3028 Py_DECREF(x);
3029#endif
3030#ifdef AL_RIGHT2_INPUT_ATTEN
3031 x = PyInt_FromLong((long) AL_RIGHT2_INPUT_ATTEN);
3032 if (x == NULL || PyDict_SetItemString(d, "RIGHT2_INPUT_ATTEN", x) < 0)
3033 goto error;
3034 Py_DECREF(x);
3035#endif
3036#ifdef AL_SAMPFMT_DOUBLE
3037 x = PyInt_FromLong((long) AL_SAMPFMT_DOUBLE);
3038 if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_DOUBLE", x) < 0)
3039 goto error;
3040 Py_DECREF(x);
3041#endif
3042#ifdef AL_SAMPFMT_FLOAT
3043 x = PyInt_FromLong((long) AL_SAMPFMT_FLOAT);
3044 if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_FLOAT", x) < 0)
3045 goto error;
3046 Py_DECREF(x);
3047#endif
3048#ifdef AL_SAMPFMT_TWOSCOMP
3049 x = PyInt_FromLong((long) AL_SAMPFMT_TWOSCOMP);
3050 if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_TWOSCOMP", x) < 0)
3051 goto error;
3052 Py_DECREF(x);
3053#endif
3054#ifdef AL_SAMPLE_16
3055 x = PyInt_FromLong((long) AL_SAMPLE_16);
3056 if (x == NULL || PyDict_SetItemString(d, "SAMPLE_16", x) < 0)
3057 goto error;
3058 Py_DECREF(x);
3059#endif
3060#ifdef AL_SAMPLE_24
3061 x = PyInt_FromLong((long) AL_SAMPLE_24);
3062 if (x == NULL || PyDict_SetItemString(d, "SAMPLE_24", x) < 0)
3063 goto error;
3064 Py_DECREF(x);
3065#endif
3066#ifdef AL_SAMPLE_8
3067 x = PyInt_FromLong((long) AL_SAMPLE_8);
3068 if (x == NULL || PyDict_SetItemString(d, "SAMPLE_8", x) < 0)
3069 goto error;
3070 Py_DECREF(x);
3071#endif
3072#ifdef AL_SCALAR_VAL
3073 x = PyInt_FromLong((long) AL_SCALAR_VAL);
3074 if (x == NULL || PyDict_SetItemString(d, "SCALAR_VAL", x) < 0)
3075 goto error;
3076 Py_DECREF(x);
3077#endif
3078#ifdef AL_SET_VAL
3079 x = PyInt_FromLong((long) AL_SET_VAL);
3080 if (x == NULL || PyDict_SetItemString(d, "SET_VAL", x) < 0)
3081 goto error;
3082 Py_DECREF(x);
3083#endif
3084#ifdef AL_SHORT_NAME
3085 x = PyInt_FromLong((long) AL_SHORT_NAME);
3086 if (x == NULL || PyDict_SetItemString(d, "SHORT_NAME", x) < 0)
3087 goto error;
3088 Py_DECREF(x);
3089#endif
3090#ifdef AL_SOURCE
3091 x = PyInt_FromLong((long) AL_SOURCE);
3092 if (x == NULL || PyDict_SetItemString(d, "SOURCE", x) < 0)
3093 goto error;
3094 Py_DECREF(x);
3095#endif
3096#ifdef AL_SPEAKER_IF_TYPE
3097 x = PyInt_FromLong((long) AL_SPEAKER_IF_TYPE);
3098 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_IF_TYPE", x) < 0)
3099 goto error;
3100 Py_DECREF(x);
3101#endif
3102#ifdef AL_SPEAKER_MUTE_CTL
3103 x = PyInt_FromLong((long) AL_SPEAKER_MUTE_CTL);
3104 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_CTL", x) < 0)
3105 goto error;
3106 Py_DECREF(x);
3107#endif
3108#ifdef AL_SPEAKER_MUTE_OFF
3109 x = PyInt_FromLong((long) AL_SPEAKER_MUTE_OFF);
3110 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_OFF", x) < 0)
3111 goto error;
3112 Py_DECREF(x);
3113#endif
3114#ifdef AL_SPEAKER_MUTE_ON
3115 x = PyInt_FromLong((long) AL_SPEAKER_MUTE_ON);
3116 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_ON", x) < 0)
3117 goto error;
3118 Py_DECREF(x);
3119#endif
3120#ifdef AL_SPEAKER_PLUS_LINE_IF_TYPE
3121 x = PyInt_FromLong((long) AL_SPEAKER_PLUS_LINE_IF_TYPE);
3122 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_PLUS_LINE_IF_TYPE", x) < 0)
3123 goto error;
3124 Py_DECREF(x);
3125#endif
3126#ifdef AL_STEREO
3127 x = PyInt_FromLong((long) AL_STEREO);
3128 if (x == NULL || PyDict_SetItemString(d, "STEREO", x) < 0)
3129 goto error;
3130 Py_DECREF(x);
3131#endif
3132#ifdef AL_STRING_VAL
3133 x = PyInt_FromLong((long) AL_STRING_VAL);
3134 if (x == NULL || PyDict_SetItemString(d, "STRING_VAL", x) < 0)
3135 goto error;
3136 Py_DECREF(x);
3137#endif
3138#ifdef AL_SUBSYSTEM
3139 x = PyInt_FromLong((long) AL_SUBSYSTEM);
3140 if (x == NULL || PyDict_SetItemString(d, "SUBSYSTEM", x) < 0)
3141 goto error;
3142 Py_DECREF(x);
3143#endif
3144#ifdef AL_SUBSYSTEM_TYPE
3145 x = PyInt_FromLong((long) AL_SUBSYSTEM_TYPE);
3146 if (x == NULL || PyDict_SetItemString(d, "SUBSYSTEM_TYPE", x) < 0)
3147 goto error;
3148 Py_DECREF(x);
3149#endif
3150#ifdef AL_SYNC_INPUT_TO_AES
3151 x = PyInt_FromLong((long) AL_SYNC_INPUT_TO_AES);
3152 if (x == NULL || PyDict_SetItemString(d, "SYNC_INPUT_TO_AES", x) < 0)
3153 goto error;
3154 Py_DECREF(x);
3155#endif
3156#ifdef AL_SYNC_OUTPUT_TO_AES
3157 x = PyInt_FromLong((long) AL_SYNC_OUTPUT_TO_AES);
3158 if (x == NULL || PyDict_SetItemString(d, "SYNC_OUTPUT_TO_AES", x) < 0)
3159 goto error;
3160 Py_DECREF(x);
3161#endif
3162#ifdef AL_SYSTEM
3163 x = PyInt_FromLong((long) AL_SYSTEM);
3164 if (x == NULL || PyDict_SetItemString(d, "SYSTEM", x) < 0)
3165 goto error;
3166 Py_DECREF(x);
3167#endif
3168#ifdef AL_SYSTEM_TYPE
3169 x = PyInt_FromLong((long) AL_SYSTEM_TYPE);
3170 if (x == NULL || PyDict_SetItemString(d, "SYSTEM_TYPE", x) < 0)
3171 goto error;
3172 Py_DECREF(x);
3173#endif
3174#ifdef AL_TEST_IF_TYPE
3175 x = PyInt_FromLong((long) AL_TEST_IF_TYPE);
3176 if (x == NULL || PyDict_SetItemString(d, "TEST_IF_TYPE", x) < 0)
3177 goto error;
3178 Py_DECREF(x);
3179#endif
3180#ifdef AL_TYPE
3181 x = PyInt_FromLong((long) AL_TYPE);
3182 if (x == NULL || PyDict_SetItemString(d, "TYPE", x) < 0)
3183 goto error;
3184 Py_DECREF(x);
3185#endif
3186#ifdef AL_TYPE_BIT
3187 x = PyInt_FromLong((long) AL_TYPE_BIT);
3188 if (x == NULL || PyDict_SetItemString(d, "TYPE_BIT", x) < 0)
3189 goto error;
3190 Py_DECREF(x);
3191#endif
3192#ifdef AL_UNUSED_COUNT
3193 x = PyInt_FromLong((long) AL_UNUSED_COUNT);
3194 if (x == NULL || PyDict_SetItemString(d, "UNUSED_COUNT", x) < 0)
3195 goto error;
3196 Py_DECREF(x);
3197#endif
3198#ifdef AL_UNUSED_PORTS
3199 x = PyInt_FromLong((long) AL_UNUSED_PORTS);
3200 if (x == NULL || PyDict_SetItemString(d, "UNUSED_PORTS", x) < 0)
3201 goto error;
3202 Py_DECREF(x);
3203#endif
3204#ifdef AL_VARIABLE_MCLK_TYPE
3205 x = PyInt_FromLong((long) AL_VARIABLE_MCLK_TYPE);
3206 if (x == NULL || PyDict_SetItemString(d, "VARIABLE_MCLK_TYPE", x) < 0)
3207 goto error;
3208 Py_DECREF(x);
3209#endif
3210#ifdef AL_VECTOR_VAL
3211 x = PyInt_FromLong((long) AL_VECTOR_VAL);
3212 if (x == NULL || PyDict_SetItemString(d, "VECTOR_VAL", x) < 0)
3213 goto error;
3214 Py_DECREF(x);
3215#endif
3216#ifdef AL_VIDEO_MCLK_TYPE
3217 x = PyInt_FromLong((long) AL_VIDEO_MCLK_TYPE);
3218 if (x == NULL || PyDict_SetItemString(d, "VIDEO_MCLK_TYPE", x) < 0)
3219 goto error;
3220 Py_DECREF(x);
3221#endif
3222#ifdef AL_WORDSIZE
3223 x = PyInt_FromLong((long) AL_WORDSIZE);
3224 if (x == NULL || PyDict_SetItemString(d, "WORDSIZE", x) < 0)
3225 goto error;
3226 Py_DECREF(x);
3227#endif
3228
3229#ifdef AL_NO_ELEM /* IRIX 6 */
3230 (void) alSetErrorHandler(ErrorHandler);
3231#endif /* AL_NO_ELEM */
3232#ifdef OLD_INTERFACE
3233 (void) ALseterrorhandler(ErrorHandler);
3234#endif /* OLD_INTERFACE */
Guido van Rossume3db8621991-09-09 23:33:34 +00003235
Barry Warsaw9bfd2bf2000-09-01 09:01:32 +00003236 error:
3237 return;
Guido van Rossume3db8621991-09-09 23:33:34 +00003238}