blob: 31af258fb1e3a13a190ee3b4d62ee356b22f72e0 [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*/
Guido van Rossum14648392001-12-08 18:02:58 +0000600 "al.config", /*tp_name*/
Guido van Rossumd641d671997-04-03 17:06:32 +0000601 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
Martin v. Löwis0bd292f2001-11-03 10:48:43 +00001206 if (!PyArg_ParseTuple(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 Rossum14648392001-12-08 18:02:58 +00001324 "al.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];
Tim Peters75cdad52001-11-28 22:07:30 +00001522 PyOS_snprintf(buf, sizeof(buf),
1523 "problem with param %d", i);
Guido van Rossumd641d671997-04-03 17:06:32 +00001524 PyErr_SetString(ErrorObject, buf);
1525 goto error;
1526 }
1527 switch (pinfo[i].valueType) {
1528 case AL_NO_VAL:
1529 item = Py_None;
1530 Py_INCREF(item);
1531 break;
1532 case AL_STRING_VAL:
1533 item = PyString_FromString(pvs[i].value.ptr);
1534 PyMem_DEL(pvs[i].value.ptr);
1535 break;
1536 case AL_MATRIX_VAL:
1537 /* XXXX this is not right */
1538 pvs[i].sizeOut *= pvs[i].size2Out;
1539 /* fall through */
1540 case AL_SET_VAL:
1541 case AL_VECTOR_VAL:
1542 item = PyList_New(pvs[i].sizeOut);
1543 for (j = 0; j < pvs[i].sizeOut; j++) {
1544 switch (pinfo[i].elementType) {
1545 case AL_INT32_ELEM:
1546 case AL_RESOURCE_ELEM:
1547 case AL_ENUM_ELEM:
1548 PyList_SetItem(item, j, PyInt_FromLong((long) ((int *) pvs[i].value.ptr)[j]));
1549 break;
1550 case AL_INT64_ELEM:
1551 PyList_SetItem(item, j, PyLong_FromLongLong(((long long *) pvs[i].value.ptr)[j]));
1552 break;
1553 case AL_FIXED_ELEM:
1554 PyList_SetItem(item, j, PyFloat_FromDouble(alFixedToDouble(((long long *) pvs[i].value.ptr)[j])));
1555 break;
1556 default:
1557 PyErr_SetString(ErrorObject, "internal error");
1558 goto error;
1559 }
1560 }
1561 PyMem_DEL(pvs[i].value.ptr);
1562 break;
1563 case AL_SCALAR_VAL:
1564 item = param2python(resource, pvs[i].param, pvs[i].value, &pinfo[i]);
1565 break;
1566 }
1567 if (PyErr_Occurred() ||
1568 PyList_SetItem(v, i, Py_BuildValue("(iO)", pvs[i].param,
1569 item)) < 0 ||
1570 PyErr_Occurred())
1571 goto error;
1572 Py_DECREF(item);
1573 }
1574 PyMem_DEL(pvs);
1575 PyMem_DEL(pinfo);
1576 return v;
1577
1578 error:
1579 Py_XDECREF(v);
1580 Py_XDECREF(item);
1581 if (pvs)
1582 PyMem_DEL(pvs);
1583 if (pinfo)
1584 PyMem_DEL(pinfo);
1585 return NULL;
1586}
1587
1588static char al_SetParams__doc__[] =
1589"alSetParams: set the values of audio resource parameters."
1590;
1591
1592static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001593al_SetParams(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001594{
1595 int resource;
1596 PyObject *pvslist, *item;
1597 ALpv *pvs;
1598 ALparamInfo *pinfo;
1599 int npvs, i;
1600
Guido van Rossum43713e52000-02-29 13:59:29 +00001601 if (!PyArg_ParseTuple(args, "iO!:SetParams", &resource, &PyList_Type, &pvslist))
Guido van Rossumd641d671997-04-03 17:06:32 +00001602 return NULL;
1603 npvs = python2params(resource, -1, pvslist, &pvs, &pinfo);
1604 if (npvs < 0)
1605 return NULL;
1606
1607 if (alSetParams(resource, pvs, npvs) < 0)
1608 goto error;
1609
1610 /* cleanup */
1611 for (i = 0; i < npvs; i++) {
1612 switch (pinfo[i].valueType) {
1613 case AL_SET_VAL:
1614 case AL_VECTOR_VAL:
1615 PyMem_DEL(pvs[i].value.ptr);
1616 break;
1617 }
1618 }
1619 PyMem_DEL(pvs);
1620 PyMem_DEL(pinfo);
1621
1622 Py_INCREF(Py_None);
1623 return Py_None;
1624
1625 error:
1626 /* XXXX we should clean up everything */
1627 if (pvs)
1628 PyMem_DEL(pvs);
1629 if (pinfo)
1630 PyMem_DEL(pinfo);
1631 return NULL;
1632}
1633
1634static char al_QueryValues__doc__[] =
1635"alQueryValues: get the set of possible values for a parameter."
1636;
1637
1638static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001639al_QueryValues(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001640{
1641 int resource, param;
1642 ALvalue *return_set = NULL;
1643 int setsize = 32, qualsize = 0, nvals, i;
1644 ALpv *quals = NULL;
1645 ALparamInfo pinfo;
1646 ALparamInfo *qualinfo = NULL;
1647 PyObject *qualobj = NULL;
1648 PyObject *res = NULL, *item;
1649
Guido van Rossum43713e52000-02-29 13:59:29 +00001650 if (!PyArg_ParseTuple(args, "ii|O!:QueryValues", &resource, &param,
Guido van Rossumd641d671997-04-03 17:06:32 +00001651 &PyList_Type, &qualobj))
1652 return NULL;
1653 if (qualobj != NULL) {
1654 qualsize = python2params(resource, param, qualobj, &quals, &qualinfo);
1655 if (qualsize < 0)
1656 return NULL;
1657 }
1658 setsize = 32;
1659 return_set = PyMem_NEW(ALvalue, setsize);
1660 if (return_set == NULL) {
1661 PyErr_NoMemory();
1662 goto cleanup;
1663 }
1664
1665 retry:
1666 nvals = alQueryValues(resource, param, return_set, setsize, quals, qualsize);
1667 if (nvals < 0)
1668 goto cleanup;
1669 if (nvals > setsize) {
1670 setsize = nvals;
1671 PyMem_RESIZE(return_set, ALvalue, setsize);
1672 if (return_set == NULL) {
1673 PyErr_NoMemory();
1674 goto cleanup;
1675 }
1676 goto retry;
1677 }
1678
1679 if (alGetParamInfo(resource, param, &pinfo) < 0)
1680 goto cleanup;
1681
1682 res = PyList_New(nvals);
1683 if (res == NULL)
1684 goto cleanup;
1685 for (i = 0; i < nvals; i++) {
1686 item = param2python(resource, param, return_set[i], &pinfo);
1687 if (item == NULL ||
1688 PyList_SetItem(res, i, item) < 0) {
1689 Py_DECREF(res);
1690 res = NULL;
1691 goto cleanup;
1692 }
1693 }
1694
1695 cleanup:
1696 if (return_set)
1697 PyMem_DEL(return_set);
1698 if (quals) {
1699 for (i = 0; i < qualsize; i++) {
1700 switch (qualinfo[i].valueType) {
1701 case AL_SET_VAL:
1702 case AL_VECTOR_VAL:
1703 PyMem_DEL(quals[i].value.ptr);
1704 break;
1705 }
1706 }
1707 PyMem_DEL(quals);
1708 PyMem_DEL(qualinfo);
1709 }
1710
1711 return res;
1712}
1713
1714static char al_GetParamInfo__doc__[] =
1715"alGetParamInfo: get information about a parameter on a particular audio resource."
1716;
1717
1718static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001719al_GetParamInfo(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001720{
1721 int res, param;
1722 ALparamInfo pinfo;
1723 PyObject *v, *item;;
1724
Guido van Rossum43713e52000-02-29 13:59:29 +00001725 if (!PyArg_ParseTuple(args, "ii:GetParamInfo", &res, &param))
Guido van Rossumd641d671997-04-03 17:06:32 +00001726 return NULL;
1727 if (alGetParamInfo(res, param, &pinfo) < 0)
1728 return NULL;
1729 v = PyDict_New();
1730
1731 item = PyInt_FromLong((long) pinfo.resource);
1732 PyDict_SetItemString(v, "resource", item);
1733 Py_DECREF(item);
1734
1735 item = PyInt_FromLong((long) pinfo.param);
1736 PyDict_SetItemString(v, "param", item);
1737 Py_DECREF(item);
1738
1739 item = PyInt_FromLong((long) pinfo.valueType);
1740 PyDict_SetItemString(v, "valueType", item);
1741 Py_DECREF(item);
1742
1743 if (pinfo.valueType != AL_NO_VAL && pinfo.valueType != AL_SCALAR_VAL) {
1744 /* multiple values */
1745 item = PyInt_FromLong((long) pinfo.maxElems);
1746 PyDict_SetItemString(v, "maxElems", item);
1747 Py_DECREF(item);
1748
1749 if (pinfo.valueType == AL_MATRIX_VAL) {
1750 /* 2 dimensional */
1751 item = PyInt_FromLong((long) pinfo.maxElems2);
1752 PyDict_SetItemString(v, "maxElems2", item);
1753 Py_DECREF(item);
1754 }
1755 }
1756
1757 item = PyInt_FromLong((long) pinfo.elementType);
1758 PyDict_SetItemString(v, "elementType", item);
1759 Py_DECREF(item);
1760
1761 item = PyString_FromString(pinfo.name);
1762 PyDict_SetItemString(v, "name", item);
1763 Py_DECREF(item);
1764
1765 item = param2python(res, param, pinfo.initial, &pinfo);
1766 PyDict_SetItemString(v, "initial", item);
1767 Py_DECREF(item);
1768
1769 if (pinfo.elementType != AL_ENUM_ELEM &&
1770 pinfo.elementType != AL_RESOURCE_ELEM &&
1771 pinfo.elementType != AL_CHAR_ELEM) {
1772 /* range param */
1773 item = param2python(res, param, pinfo.min, &pinfo);
1774 PyDict_SetItemString(v, "min", item);
1775 Py_DECREF(item);
1776
1777 item = param2python(res, param, pinfo.max, &pinfo);
1778 PyDict_SetItemString(v, "max", item);
1779 Py_DECREF(item);
1780
1781 item = param2python(res, param, pinfo.minDelta, &pinfo);
1782 PyDict_SetItemString(v, "minDelta", item);
1783 Py_DECREF(item);
1784
1785 item = param2python(res, param, pinfo.maxDelta, &pinfo);
1786 PyDict_SetItemString(v, "maxDelta", item);
1787 Py_DECREF(item);
1788
1789 item = PyInt_FromLong((long) pinfo.specialVals);
1790 PyDict_SetItemString(v, "specialVals", item);
1791 Py_DECREF(item);
1792 }
1793
1794 return v;
1795}
1796
1797static char al_GetResourceByName__doc__[] =
1798"alGetResourceByName: find an audio resource by name."
1799;
1800
1801static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001802al_GetResourceByName(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001803{
1804 int res, start_res, type;
1805 char *name;
1806
Guido van Rossum43713e52000-02-29 13:59:29 +00001807 if (!PyArg_ParseTuple(args, "isi:GetResourceByName", &start_res, &name, &type))
Guido van Rossumd641d671997-04-03 17:06:32 +00001808 return NULL;
1809 if ((res = alGetResourceByName(start_res, name, type)) == 0)
1810 return NULL;
1811 return PyInt_FromLong((long) res);
1812}
1813
1814static char al_IsSubtype__doc__[] =
1815"alIsSubtype: indicate if one resource type is a subtype of another."
1816;
1817
1818static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001819al_IsSubtype(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001820{
1821 int type, subtype;
1822
Guido van Rossum43713e52000-02-29 13:59:29 +00001823 if (!PyArg_ParseTuple(args, "ii:IsSubtype", &type, &subtype))
Guido van Rossumd641d671997-04-03 17:06:32 +00001824 return NULL;
1825 return PyInt_FromLong((long) alIsSubtype(type, subtype));
1826}
1827
1828static char al_SetErrorHandler__doc__[] =
1829""
1830;
1831
1832static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001833al_SetErrorHandler(PyObject *self, PyObject *args)
Guido van Rossumd641d671997-04-03 17:06:32 +00001834{
1835
Guido van Rossum43713e52000-02-29 13:59:29 +00001836 if (!PyArg_ParseTuple(args, ":SetErrorHandler"))
Guido van Rossumd641d671997-04-03 17:06:32 +00001837 return NULL;
1838 Py_INCREF(Py_None);
1839 return Py_None;
1840}
1841
1842#endif /* AL_NO_ELEM */
1843
1844#ifdef OLD_INTERFACE
1845
1846static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001847al_openport(PyObject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001848{
Guido van Rossumfc58e581992-01-27 16:45:55 +00001849 char *name, *dir;
Guido van Rossume3db8621991-09-09 23:33:34 +00001850 ALport port;
Guido van Rossumd641d671997-04-03 17:06:32 +00001851 alcobject *config = NULL;
Guido van Rossume3db8621991-09-09 23:33:34 +00001852
Guido van Rossum43713e52000-02-29 13:59:29 +00001853 if (!PyArg_ParseTuple(args, "ss|O!:OpenPort", &name, &dir, &Alctype, &config))
Guido van Rossumc0aab891991-10-20 20:10:46 +00001854 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001855 if ((port = ALopenport(name, dir, config ? config->config : NULL)) == NULL)
Guido van Rossume3db8621991-09-09 23:33:34 +00001856 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001857 return newalpobject(port);
Guido van Rossume3db8621991-09-09 23:33:34 +00001858}
1859
Roger E. Massea2a8b271997-01-03 22:40:34 +00001860static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001861al_newconfig(PyObject *self, PyObject *args)
Guido van Rossume3db8621991-09-09 23:33:34 +00001862{
1863 ALconfig config;
1864
Guido van Rossum43713e52000-02-29 13:59:29 +00001865 if (!PyArg_ParseTuple(args, ":NewConfig"))
Guido van Rossumc0aab891991-10-20 20:10:46 +00001866 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001867 if ((config = ALnewconfig ()) == NULL)
1868 return NULL;
1869 return newalcobject(config);
Guido van Rossume3db8621991-09-09 23:33:34 +00001870}
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001871
Roger E. Massea2a8b271997-01-03 22:40:34 +00001872static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001873al_queryparams(PyObject *self, PyObject *args)
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001874{
1875 long device;
1876 long length;
1877 long *PVbuffer;
1878 long PVdummy[2];
Guido van Rossumd641d671997-04-03 17:06:32 +00001879 PyObject *v = NULL;
1880 int i;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001881
Guido van Rossum43713e52000-02-29 13:59:29 +00001882 if (!PyArg_ParseTuple(args, "l:queryparams", &device))
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001883 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001884 if ((length = ALqueryparams(device, PVdummy, 2L)) == -1)
1885 return NULL;
1886 if ((PVbuffer = PyMem_NEW(long, length)) == NULL)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001887 return PyErr_NoMemory();
Guido van Rossumd641d671997-04-03 17:06:32 +00001888 if (ALqueryparams(device, PVbuffer, length) >= 0 &&
1889 (v = PyList_New((int)length)) != NULL) {
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001890 for (i = 0; i < length; i++)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001891 PyList_SetItem(v, i, PyInt_FromLong(PVbuffer[i]));
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001892 }
Roger E. Massea2a8b271997-01-03 22:40:34 +00001893 PyMem_DEL(PVbuffer);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001894 return v;
1895}
1896
Roger E. Massea2a8b271997-01-03 22:40:34 +00001897static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001898doParams(PyObject *args, int (*func)(long, long *, long), int modified)
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001899{
1900 long device;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001901 PyObject *list, *v;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001902 long *PVbuffer;
1903 long length;
1904 int i;
Guido van Rossume3db8621991-09-09 23:33:34 +00001905
Guido van Rossumd641d671997-04-03 17:06:32 +00001906 if (!PyArg_ParseTuple(args, "lO!", &device, &PyList_Type, &list))
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001907 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001908 length = PyList_Size(list);
1909 PVbuffer = PyMem_NEW(long, length);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001910 if (PVbuffer == NULL)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001911 return PyErr_NoMemory();
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001912 for (i = 0; i < length; i++) {
Roger E. Massea2a8b271997-01-03 22:40:34 +00001913 v = PyList_GetItem(list, i);
1914 if (!PyInt_Check(v)) {
1915 PyMem_DEL(PVbuffer);
1916 PyErr_BadArgument();
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001917 return NULL;
1918 }
Roger E. Massea2a8b271997-01-03 22:40:34 +00001919 PVbuffer[i] = PyInt_AsLong(v);
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001920 }
1921
Guido van Rossumd641d671997-04-03 17:06:32 +00001922 if ((*func)(device, PVbuffer, length) == -1) {
1923 PyMem_DEL(PVbuffer);
1924 return NULL;
1925 }
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001926
1927 if (modified) {
1928 for (i = 0; i < length; i++)
Roger E. Massea2a8b271997-01-03 22:40:34 +00001929 PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i]));
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001930 }
1931
Roger E. Massea2a8b271997-01-03 22:40:34 +00001932 PyMem_DEL(PVbuffer);
Guido van Rossumc0aab891991-10-20 20:10:46 +00001933
Roger E. Massea2a8b271997-01-03 22:40:34 +00001934 Py_INCREF(Py_None);
1935 return Py_None;
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001936}
1937
Roger E. Massea2a8b271997-01-03 22:40:34 +00001938static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001939al_getparams(PyObject *self, PyObject *args)
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001940{
1941 return doParams(args, ALgetparams, 1);
1942}
1943
Roger E. Massea2a8b271997-01-03 22:40:34 +00001944static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001945al_setparams(PyObject *self, PyObject *args)
Guido van Rossumb3a5b9b1991-09-10 14:54:05 +00001946{
1947 return doParams(args, ALsetparams, 0);
1948}
1949
Roger E. Massea2a8b271997-01-03 22:40:34 +00001950static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001951al_getname(PyObject *self, PyObject *args)
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001952{
1953 long device, descriptor;
1954 char *name;
Guido van Rossumd641d671997-04-03 17:06:32 +00001955
Guido van Rossum43713e52000-02-29 13:59:29 +00001956 if (!PyArg_ParseTuple(args, "ll:getname", &device, &descriptor))
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001957 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001958 if ((name = ALgetname(device, descriptor)) == NULL)
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001959 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001960 return PyString_FromString(name);
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001961}
1962
Roger E. Massea2a8b271997-01-03 22:40:34 +00001963static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001964al_getdefault(PyObject *self, PyObject *args)
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001965{
1966 long device, descriptor, value;
Guido van Rossumd641d671997-04-03 17:06:32 +00001967
Guido van Rossum43713e52000-02-29 13:59:29 +00001968 if (!PyArg_ParseTuple(args, "ll:getdefault", &device, &descriptor))
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001969 return NULL;
Guido van Rossumd641d671997-04-03 17:06:32 +00001970 if ((value = ALgetdefault(device, descriptor)) == -1)
1971 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001972 return PyLong_FromLong(value);
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001973}
1974
Roger E. Massea2a8b271997-01-03 22:40:34 +00001975static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001976al_getminmax(PyObject *self, PyObject *args)
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001977{
1978 long device, descriptor, min, max;
Guido van Rossumd641d671997-04-03 17:06:32 +00001979
Guido van Rossum43713e52000-02-29 13:59:29 +00001980 if (!PyArg_ParseTuple(args, "ll:getminmax", &device, &descriptor))
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001981 return NULL;
1982 min = -1;
1983 max = -1;
Guido van Rossumd641d671997-04-03 17:06:32 +00001984 if (ALgetminmax(device, descriptor, &min, &max) == -1)
1985 return NULL;
Roger E. Massea2a8b271997-01-03 22:40:34 +00001986 return Py_BuildValue("ll", min, max);
Guido van Rossum448f4bf1992-08-19 16:41:15 +00001987}
1988
Guido van Rossumd641d671997-04-03 17:06:32 +00001989#endif /* OLD_INTERFACE */
1990
1991/* List of methods defined in the module */
1992
1993static struct PyMethodDef al_methods[] = {
1994#ifdef AL_NO_ELEM /* IRIX 6 */
1995 {"NewConfig", (PyCFunction)al_NewConfig, METH_VARARGS, al_NewConfig__doc__},
1996 {"OpenPort", (PyCFunction)al_OpenPort, METH_VARARGS, al_OpenPort__doc__},
1997 {"Connect", (PyCFunction)al_Connect, METH_VARARGS, al_Connect__doc__},
1998 {"Disconnect", (PyCFunction)al_Disconnect, METH_VARARGS, al_Disconnect__doc__},
1999 {"GetParams", (PyCFunction)al_GetParams, METH_VARARGS, al_GetParams__doc__},
2000 {"SetParams", (PyCFunction)al_SetParams, METH_VARARGS, al_SetParams__doc__},
2001 {"QueryValues", (PyCFunction)al_QueryValues, METH_VARARGS, al_QueryValues__doc__},
2002 {"GetParamInfo", (PyCFunction)al_GetParamInfo, METH_VARARGS, al_GetParamInfo__doc__},
2003 {"GetResourceByName", (PyCFunction)al_GetResourceByName, METH_VARARGS, al_GetResourceByName__doc__},
2004 {"IsSubtype", (PyCFunction)al_IsSubtype, METH_VARARGS, al_IsSubtype__doc__},
2005#if 0
2006 /* this one not supported */
2007 {"SetErrorHandler", (PyCFunction)al_SetErrorHandler, METH_VARARGS, al_SetErrorHandler__doc__},
2008#endif
2009#endif /* AL_NO_ELEM */
2010#ifdef OLD_INTERFACE
2011 {"openport", (PyCFunction)al_openport, METH_VARARGS},
2012 {"newconfig", (PyCFunction)al_newconfig, METH_VARARGS},
2013 {"queryparams", (PyCFunction)al_queryparams, METH_VARARGS},
2014 {"getparams", (PyCFunction)al_getparams, METH_VARARGS},
2015 {"setparams", (PyCFunction)al_setparams, METH_VARARGS},
2016 {"getname", (PyCFunction)al_getname, METH_VARARGS},
2017 {"getdefault", (PyCFunction)al_getdefault, METH_VARARGS},
2018 {"getminmax", (PyCFunction)al_getminmax, METH_VARARGS},
2019#endif /* OLD_INTERFACE */
2020
2021 {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
Guido van Rossume3db8621991-09-09 23:33:34 +00002022};
2023
Guido van Rossumd641d671997-04-03 17:06:32 +00002024
2025/* Initialization function for the module (*must* be called inital) */
2026
2027static char al_module_documentation[] =
2028""
2029;
2030
Guido van Rossume3db8621991-09-09 23:33:34 +00002031void
Thomas Woutersf3f33dc2000-07-21 06:00:07 +00002032inital(void)
Guido van Rossume3db8621991-09-09 23:33:34 +00002033{
Guido van Rossumd641d671997-04-03 17:06:32 +00002034 PyObject *m, *d, *x;
Guido van Rossume3db8621991-09-09 23:33:34 +00002035
Guido van Rossumd641d671997-04-03 17:06:32 +00002036 /* Create the module and add the functions */
2037 m = Py_InitModule4("al", al_methods,
2038 al_module_documentation,
2039 (PyObject*)NULL,PYTHON_API_VERSION);
2040
2041 /* Add some symbolic constants to the module */
2042 d = PyModule_GetDict(m);
Fred Drake589c35b2000-07-06 19:38:49 +00002043 ErrorObject = PyErr_NewException("al.error", NULL, NULL);
Guido van Rossumd641d671997-04-03 17:06:32 +00002044 PyDict_SetItemString(d, "error", ErrorObject);
2045
2046 /* XXXX Add constants here */
2047#ifdef AL_4CHANNEL
2048 x = PyInt_FromLong((long) AL_4CHANNEL);
2049 if (x == NULL || PyDict_SetItemString(d, "FOURCHANNEL", x) < 0)
2050 goto error;
2051 Py_DECREF(x);
2052#endif
2053#ifdef AL_ADAT_IF_TYPE
2054 x = PyInt_FromLong((long) AL_ADAT_IF_TYPE);
2055 if (x == NULL || PyDict_SetItemString(d, "ADAT_IF_TYPE", x) < 0)
2056 goto error;
2057 Py_DECREF(x);
2058#endif
2059#ifdef AL_ADAT_MCLK_TYPE
2060 x = PyInt_FromLong((long) AL_ADAT_MCLK_TYPE);
2061 if (x == NULL || PyDict_SetItemString(d, "ADAT_MCLK_TYPE", x) < 0)
2062 goto error;
2063 Py_DECREF(x);
2064#endif
2065#ifdef AL_AES_IF_TYPE
2066 x = PyInt_FromLong((long) AL_AES_IF_TYPE);
2067 if (x == NULL || PyDict_SetItemString(d, "AES_IF_TYPE", x) < 0)
2068 goto error;
2069 Py_DECREF(x);
2070#endif
2071#ifdef AL_AES_MCLK_TYPE
2072 x = PyInt_FromLong((long) AL_AES_MCLK_TYPE);
2073 if (x == NULL || PyDict_SetItemString(d, "AES_MCLK_TYPE", x) < 0)
2074 goto error;
2075 Py_DECREF(x);
2076#endif
2077#ifdef AL_ANALOG_IF_TYPE
2078 x = PyInt_FromLong((long) AL_ANALOG_IF_TYPE);
2079 if (x == NULL || PyDict_SetItemString(d, "ANALOG_IF_TYPE", x) < 0)
2080 goto error;
2081 Py_DECREF(x);
2082#endif
2083#ifdef AL_ASSOCIATE
2084 x = PyInt_FromLong((long) AL_ASSOCIATE);
2085 if (x == NULL || PyDict_SetItemString(d, "ASSOCIATE", x) < 0)
2086 goto error;
2087 Py_DECREF(x);
2088#endif
2089#ifdef AL_BAD_BUFFER_NULL
2090 x = PyInt_FromLong((long) AL_BAD_BUFFER_NULL);
2091 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFER_NULL", x) < 0)
2092 goto error;
2093 Py_DECREF(x);
2094#endif
2095#ifdef AL_BAD_BUFFERLENGTH
2096 x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH);
2097 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH", x) < 0)
2098 goto error;
2099 Py_DECREF(x);
2100#endif
2101#ifdef AL_BAD_BUFFERLENGTH_NEG
2102 x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH_NEG);
2103 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_NEG", x) < 0)
2104 goto error;
2105 Py_DECREF(x);
2106#endif
2107#ifdef AL_BAD_BUFFERLENGTH_ODD
2108 x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH_ODD);
2109 if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_ODD", x) < 0)
2110 goto error;
2111 Py_DECREF(x);
2112#endif
2113#ifdef AL_BAD_CHANNELS
2114 x = PyInt_FromLong((long) AL_BAD_CHANNELS);
2115 if (x == NULL || PyDict_SetItemString(d, "BAD_CHANNELS", x) < 0)
2116 goto error;
2117 Py_DECREF(x);
2118#endif
2119#ifdef AL_BAD_CONFIG
2120 x = PyInt_FromLong((long) AL_BAD_CONFIG);
2121 if (x == NULL || PyDict_SetItemString(d, "BAD_CONFIG", x) < 0)
2122 goto error;
2123 Py_DECREF(x);
2124#endif
2125#ifdef AL_BAD_COUNT_NEG
2126 x = PyInt_FromLong((long) AL_BAD_COUNT_NEG);
2127 if (x == NULL || PyDict_SetItemString(d, "BAD_COUNT_NEG", x) < 0)
2128 goto error;
2129 Py_DECREF(x);
2130#endif
2131#ifdef AL_BAD_DEVICE
2132 x = PyInt_FromLong((long) AL_BAD_DEVICE);
2133 if (x == NULL || PyDict_SetItemString(d, "BAD_DEVICE", x) < 0)
2134 goto error;
2135 Py_DECREF(x);
2136#endif
2137#ifdef AL_BAD_DEVICE_ACCESS
2138 x = PyInt_FromLong((long) AL_BAD_DEVICE_ACCESS);
2139 if (x == NULL || PyDict_SetItemString(d, "BAD_DEVICE_ACCESS", x) < 0)
2140 goto error;
2141 Py_DECREF(x);
2142#endif
2143#ifdef AL_BAD_DIRECTION
2144 x = PyInt_FromLong((long) AL_BAD_DIRECTION);
2145 if (x == NULL || PyDict_SetItemString(d, "BAD_DIRECTION", x) < 0)
2146 goto error;
2147 Py_DECREF(x);
2148#endif
2149#ifdef AL_BAD_FILLPOINT
2150 x = PyInt_FromLong((long) AL_BAD_FILLPOINT);
2151 if (x == NULL || PyDict_SetItemString(d, "BAD_FILLPOINT", x) < 0)
2152 goto error;
2153 Py_DECREF(x);
2154#endif
2155#ifdef AL_BAD_FLOATMAX
2156 x = PyInt_FromLong((long) AL_BAD_FLOATMAX);
2157 if (x == NULL || PyDict_SetItemString(d, "BAD_FLOATMAX", x) < 0)
2158 goto error;
2159 Py_DECREF(x);
2160#endif
2161#ifdef AL_BAD_ILLEGAL_STATE
2162 x = PyInt_FromLong((long) AL_BAD_ILLEGAL_STATE);
2163 if (x == NULL || PyDict_SetItemString(d, "BAD_ILLEGAL_STATE", x) < 0)
2164 goto error;
2165 Py_DECREF(x);
2166#endif
2167#ifdef AL_BAD_NO_PORTS
2168 x = PyInt_FromLong((long) AL_BAD_NO_PORTS);
2169 if (x == NULL || PyDict_SetItemString(d, "BAD_NO_PORTS", x) < 0)
2170 goto error;
2171 Py_DECREF(x);
2172#endif
2173#ifdef AL_BAD_NOT_FOUND
2174 x = PyInt_FromLong((long) AL_BAD_NOT_FOUND);
2175 if (x == NULL || PyDict_SetItemString(d, "BAD_NOT_FOUND", x) < 0)
2176 goto error;
2177 Py_DECREF(x);
2178#endif
2179#ifdef AL_BAD_NOT_IMPLEMENTED
2180 x = PyInt_FromLong((long) AL_BAD_NOT_IMPLEMENTED);
2181 if (x == NULL || PyDict_SetItemString(d, "BAD_NOT_IMPLEMENTED", x) < 0)
2182 goto error;
2183 Py_DECREF(x);
2184#endif
2185#ifdef AL_BAD_OUT_OF_MEM
2186 x = PyInt_FromLong((long) AL_BAD_OUT_OF_MEM);
2187 if (x == NULL || PyDict_SetItemString(d, "BAD_OUT_OF_MEM", x) < 0)
2188 goto error;
2189 Py_DECREF(x);
2190#endif
2191#ifdef AL_BAD_PARAM
2192 x = PyInt_FromLong((long) AL_BAD_PARAM);
2193 if (x == NULL || PyDict_SetItemString(d, "BAD_PARAM", x) < 0)
2194 goto error;
2195 Py_DECREF(x);
2196#endif
2197#ifdef AL_BAD_PERMISSIONS
2198 x = PyInt_FromLong((long) AL_BAD_PERMISSIONS);
2199 if (x == NULL || PyDict_SetItemString(d, "BAD_PERMISSIONS", x) < 0)
2200 goto error;
2201 Py_DECREF(x);
2202#endif
2203#ifdef AL_BAD_PORT
2204 x = PyInt_FromLong((long) AL_BAD_PORT);
2205 if (x == NULL || PyDict_SetItemString(d, "BAD_PORT", x) < 0)
2206 goto error;
2207 Py_DECREF(x);
2208#endif
2209#ifdef AL_BAD_PORTSTYLE
2210 x = PyInt_FromLong((long) AL_BAD_PORTSTYLE);
2211 if (x == NULL || PyDict_SetItemString(d, "BAD_PORTSTYLE", x) < 0)
2212 goto error;
2213 Py_DECREF(x);
2214#endif
2215#ifdef AL_BAD_PVBUFFER
2216 x = PyInt_FromLong((long) AL_BAD_PVBUFFER);
2217 if (x == NULL || PyDict_SetItemString(d, "BAD_PVBUFFER", x) < 0)
2218 goto error;
2219 Py_DECREF(x);
2220#endif
2221#ifdef AL_BAD_QSIZE
2222 x = PyInt_FromLong((long) AL_BAD_QSIZE);
2223 if (x == NULL || PyDict_SetItemString(d, "BAD_QSIZE", x) < 0)
2224 goto error;
2225 Py_DECREF(x);
2226#endif
2227#ifdef AL_BAD_RATE
2228 x = PyInt_FromLong((long) AL_BAD_RATE);
2229 if (x == NULL || PyDict_SetItemString(d, "BAD_RATE", x) < 0)
2230 goto error;
2231 Py_DECREF(x);
2232#endif
2233#ifdef AL_BAD_RESOURCE
2234 x = PyInt_FromLong((long) AL_BAD_RESOURCE);
2235 if (x == NULL || PyDict_SetItemString(d, "BAD_RESOURCE", x) < 0)
2236 goto error;
2237 Py_DECREF(x);
2238#endif
2239#ifdef AL_BAD_SAMPFMT
2240 x = PyInt_FromLong((long) AL_BAD_SAMPFMT);
2241 if (x == NULL || PyDict_SetItemString(d, "BAD_SAMPFMT", x) < 0)
2242 goto error;
2243 Py_DECREF(x);
2244#endif
2245#ifdef AL_BAD_TRANSFER_SIZE
2246 x = PyInt_FromLong((long) AL_BAD_TRANSFER_SIZE);
2247 if (x == NULL || PyDict_SetItemString(d, "BAD_TRANSFER_SIZE", x) < 0)
2248 goto error;
2249 Py_DECREF(x);
2250#endif
2251#ifdef AL_BAD_WIDTH
2252 x = PyInt_FromLong((long) AL_BAD_WIDTH);
2253 if (x == NULL || PyDict_SetItemString(d, "BAD_WIDTH", x) < 0)
2254 goto error;
2255 Py_DECREF(x);
2256#endif
2257#ifdef AL_CHANNEL_MODE
2258 x = PyInt_FromLong((long) AL_CHANNEL_MODE);
2259 if (x == NULL || PyDict_SetItemString(d, "CHANNEL_MODE", x) < 0)
2260 goto error;
2261 Py_DECREF(x);
2262#endif
2263#ifdef AL_CHANNELS
2264 x = PyInt_FromLong((long) AL_CHANNELS);
2265 if (x == NULL || PyDict_SetItemString(d, "CHANNELS", x) < 0)
2266 goto error;
2267 Py_DECREF(x);
2268#endif
2269#ifdef AL_CHAR_ELEM
2270 x = PyInt_FromLong((long) AL_CHAR_ELEM);
2271 if (x == NULL || PyDict_SetItemString(d, "CHAR_ELEM", x) < 0)
2272 goto error;
2273 Py_DECREF(x);
2274#endif
2275#ifdef AL_CLOCK_GEN
2276 x = PyInt_FromLong((long) AL_CLOCK_GEN);
2277 if (x == NULL || PyDict_SetItemString(d, "CLOCK_GEN", x) < 0)
2278 goto error;
2279 Py_DECREF(x);
2280#endif
2281#ifdef AL_CLOCKGEN_TYPE
2282 x = PyInt_FromLong((long) AL_CLOCKGEN_TYPE);
2283 if (x == NULL || PyDict_SetItemString(d, "CLOCKGEN_TYPE", x) < 0)
2284 goto error;
2285 Py_DECREF(x);
2286#endif
2287#ifdef AL_CONNECT
2288 x = PyInt_FromLong((long) AL_CONNECT);
2289 if (x == NULL || PyDict_SetItemString(d, "CONNECT", x) < 0)
2290 goto error;
2291 Py_DECREF(x);
2292#endif
2293#ifdef AL_CONNECTION_TYPE
2294 x = PyInt_FromLong((long) AL_CONNECTION_TYPE);
2295 if (x == NULL || PyDict_SetItemString(d, "CONNECTION_TYPE", x) < 0)
2296 goto error;
2297 Py_DECREF(x);
2298#endif
2299#ifdef AL_CONNECTIONS
2300 x = PyInt_FromLong((long) AL_CONNECTIONS);
2301 if (x == NULL || PyDict_SetItemString(d, "CONNECTIONS", x) < 0)
2302 goto error;
2303 Py_DECREF(x);
2304#endif
2305#ifdef AL_CRYSTAL_MCLK_TYPE
2306 x = PyInt_FromLong((long) AL_CRYSTAL_MCLK_TYPE);
2307 if (x == NULL || PyDict_SetItemString(d, "CRYSTAL_MCLK_TYPE", x) < 0)
2308 goto error;
2309 Py_DECREF(x);
2310#endif
2311#ifdef AL_DEFAULT_DEVICE
2312 x = PyInt_FromLong((long) AL_DEFAULT_DEVICE);
2313 if (x == NULL || PyDict_SetItemString(d, "DEFAULT_DEVICE", x) < 0)
2314 goto error;
2315 Py_DECREF(x);
2316#endif
2317#ifdef AL_DEFAULT_INPUT
2318 x = PyInt_FromLong((long) AL_DEFAULT_INPUT);
2319 if (x == NULL || PyDict_SetItemString(d, "DEFAULT_INPUT", x) < 0)
2320 goto error;
2321 Py_DECREF(x);
2322#endif
2323#ifdef AL_DEFAULT_OUTPUT
2324 x = PyInt_FromLong((long) AL_DEFAULT_OUTPUT);
2325 if (x == NULL || PyDict_SetItemString(d, "DEFAULT_OUTPUT", x) < 0)
2326 goto error;
2327 Py_DECREF(x);
2328#endif
2329#ifdef AL_DEST
2330 x = PyInt_FromLong((long) AL_DEST);
2331 if (x == NULL || PyDict_SetItemString(d, "DEST", x) < 0)
2332 goto error;
2333 Py_DECREF(x);
2334#endif
2335#ifdef AL_DEVICE_TYPE
2336 x = PyInt_FromLong((long) AL_DEVICE_TYPE);
2337 if (x == NULL || PyDict_SetItemString(d, "DEVICE_TYPE", x) < 0)
2338 goto error;
2339 Py_DECREF(x);
2340#endif
2341#ifdef AL_DEVICES
2342 x = PyInt_FromLong((long) AL_DEVICES);
2343 if (x == NULL || PyDict_SetItemString(d, "DEVICES", x) < 0)
2344 goto error;
2345 Py_DECREF(x);
2346#endif
2347#ifdef AL_DIGITAL_IF_TYPE
2348 x = PyInt_FromLong((long) AL_DIGITAL_IF_TYPE);
2349 if (x == NULL || PyDict_SetItemString(d, "DIGITAL_IF_TYPE", x) < 0)
2350 goto error;
2351 Py_DECREF(x);
2352#endif
2353#ifdef AL_DIGITAL_INPUT_RATE
2354 x = PyInt_FromLong((long) AL_DIGITAL_INPUT_RATE);
2355 if (x == NULL || PyDict_SetItemString(d, "DIGITAL_INPUT_RATE", x) < 0)
2356 goto error;
2357 Py_DECREF(x);
2358#endif
2359#ifdef AL_DISCONNECT
2360 x = PyInt_FromLong((long) AL_DISCONNECT);
2361 if (x == NULL || PyDict_SetItemString(d, "DISCONNECT", x) < 0)
2362 goto error;
2363 Py_DECREF(x);
2364#endif
2365#ifdef AL_ENUM_ELEM
2366 x = PyInt_FromLong((long) AL_ENUM_ELEM);
2367 if (x == NULL || PyDict_SetItemString(d, "ENUM_ELEM", x) < 0)
2368 goto error;
2369 Py_DECREF(x);
2370#endif
2371#ifdef AL_ENUM_VALUE
2372 x = PyInt_FromLong((long) AL_ENUM_VALUE);
2373 if (x == NULL || PyDict_SetItemString(d, "ENUM_VALUE", x) < 0)
2374 goto error;
2375 Py_DECREF(x);
2376#endif
2377#ifdef AL_ERROR_INPUT_OVERFLOW
2378 x = PyInt_FromLong((long) AL_ERROR_INPUT_OVERFLOW);
2379 if (x == NULL || PyDict_SetItemString(d, "ERROR_INPUT_OVERFLOW", x) < 0)
2380 goto error;
2381 Py_DECREF(x);
2382#endif
2383#ifdef AL_ERROR_LENGTH
2384 x = PyInt_FromLong((long) AL_ERROR_LENGTH);
2385 if (x == NULL || PyDict_SetItemString(d, "ERROR_LENGTH", x) < 0)
2386 goto error;
2387 Py_DECREF(x);
2388#endif
2389#ifdef AL_ERROR_LOCATION_LSP
2390 x = PyInt_FromLong((long) AL_ERROR_LOCATION_LSP);
2391 if (x == NULL || PyDict_SetItemString(d, "ERROR_LOCATION_LSP", x) < 0)
2392 goto error;
2393 Py_DECREF(x);
2394#endif
2395#ifdef AL_ERROR_LOCATION_MSP
2396 x = PyInt_FromLong((long) AL_ERROR_LOCATION_MSP);
2397 if (x == NULL || PyDict_SetItemString(d, "ERROR_LOCATION_MSP", x) < 0)
2398 goto error;
2399 Py_DECREF(x);
2400#endif
2401#ifdef AL_ERROR_NUMBER
2402 x = PyInt_FromLong((long) AL_ERROR_NUMBER);
2403 if (x == NULL || PyDict_SetItemString(d, "ERROR_NUMBER", x) < 0)
2404 goto error;
2405 Py_DECREF(x);
2406#endif
2407#ifdef AL_ERROR_OUTPUT_UNDERFLOW
2408 x = PyInt_FromLong((long) AL_ERROR_OUTPUT_UNDERFLOW);
2409 if (x == NULL || PyDict_SetItemString(d, "ERROR_OUTPUT_UNDERFLOW", x) < 0)
2410 goto error;
2411 Py_DECREF(x);
2412#endif
2413#ifdef AL_ERROR_TYPE
2414 x = PyInt_FromLong((long) AL_ERROR_TYPE);
2415 if (x == NULL || PyDict_SetItemString(d, "ERROR_TYPE", x) < 0)
2416 goto error;
2417 Py_DECREF(x);
2418#endif
2419#ifdef AL_FIXED_ELEM
2420 x = PyInt_FromLong((long) AL_FIXED_ELEM);
2421 if (x == NULL || PyDict_SetItemString(d, "FIXED_ELEM", x) < 0)
2422 goto error;
2423 Py_DECREF(x);
2424#endif
2425#ifdef AL_FIXED_MCLK_TYPE
2426 x = PyInt_FromLong((long) AL_FIXED_MCLK_TYPE);
2427 if (x == NULL || PyDict_SetItemString(d, "FIXED_MCLK_TYPE", x) < 0)
2428 goto error;
2429 Py_DECREF(x);
2430#endif
2431#ifdef AL_GAIN
2432 x = PyInt_FromLong((long) AL_GAIN);
2433 if (x == NULL || PyDict_SetItemString(d, "GAIN", x) < 0)
2434 goto error;
2435 Py_DECREF(x);
2436#endif
2437#ifdef AL_GAIN_REF
2438 x = PyInt_FromLong((long) AL_GAIN_REF);
2439 if (x == NULL || PyDict_SetItemString(d, "GAIN_REF", x) < 0)
2440 goto error;
2441 Py_DECREF(x);
2442#endif
2443#ifdef AL_HRB_TYPE
2444 x = PyInt_FromLong((long) AL_HRB_TYPE);
2445 if (x == NULL || PyDict_SetItemString(d, "HRB_TYPE", x) < 0)
2446 goto error;
2447 Py_DECREF(x);
2448#endif
2449#ifdef AL_INPUT_COUNT
2450 x = PyInt_FromLong((long) AL_INPUT_COUNT);
2451 if (x == NULL || PyDict_SetItemString(d, "INPUT_COUNT", x) < 0)
2452 goto error;
2453 Py_DECREF(x);
2454#endif
2455#ifdef AL_INPUT_DEVICE_TYPE
2456 x = PyInt_FromLong((long) AL_INPUT_DEVICE_TYPE);
2457 if (x == NULL || PyDict_SetItemString(d, "INPUT_DEVICE_TYPE", x) < 0)
2458 goto error;
2459 Py_DECREF(x);
2460#endif
2461#ifdef AL_INPUT_DIGITAL
2462 x = PyInt_FromLong((long) AL_INPUT_DIGITAL);
2463 if (x == NULL || PyDict_SetItemString(d, "INPUT_DIGITAL", x) < 0)
2464 goto error;
2465 Py_DECREF(x);
2466#endif
2467#ifdef AL_INPUT_HRB_TYPE
2468 x = PyInt_FromLong((long) AL_INPUT_HRB_TYPE);
2469 if (x == NULL || PyDict_SetItemString(d, "INPUT_HRB_TYPE", x) < 0)
2470 goto error;
2471 Py_DECREF(x);
2472#endif
2473#ifdef AL_INPUT_LINE
2474 x = PyInt_FromLong((long) AL_INPUT_LINE);
2475 if (x == NULL || PyDict_SetItemString(d, "INPUT_LINE", x) < 0)
2476 goto error;
2477 Py_DECREF(x);
2478#endif
2479#ifdef AL_INPUT_MIC
2480 x = PyInt_FromLong((long) AL_INPUT_MIC);
2481 if (x == NULL || PyDict_SetItemString(d, "INPUT_MIC", x) < 0)
2482 goto error;
2483 Py_DECREF(x);
2484#endif
2485#ifdef AL_INPUT_PORT_TYPE
2486 x = PyInt_FromLong((long) AL_INPUT_PORT_TYPE);
2487 if (x == NULL || PyDict_SetItemString(d, "INPUT_PORT_TYPE", x) < 0)
2488 goto error;
2489 Py_DECREF(x);
2490#endif
2491#ifdef AL_INPUT_RATE
2492 x = PyInt_FromLong((long) AL_INPUT_RATE);
2493 if (x == NULL || PyDict_SetItemString(d, "INPUT_RATE", x) < 0)
2494 goto error;
2495 Py_DECREF(x);
2496#endif
2497#ifdef AL_INPUT_SOURCE
2498 x = PyInt_FromLong((long) AL_INPUT_SOURCE);
2499 if (x == NULL || PyDict_SetItemString(d, "INPUT_SOURCE", x) < 0)
2500 goto error;
2501 Py_DECREF(x);
2502#endif
2503#ifdef AL_INT32_ELEM
2504 x = PyInt_FromLong((long) AL_INT32_ELEM);
2505 if (x == NULL || PyDict_SetItemString(d, "INT32_ELEM", x) < 0)
2506 goto error;
2507 Py_DECREF(x);
2508#endif
2509#ifdef AL_INT64_ELEM
2510 x = PyInt_FromLong((long) AL_INT64_ELEM);
2511 if (x == NULL || PyDict_SetItemString(d, "INT64_ELEM", x) < 0)
2512 goto error;
2513 Py_DECREF(x);
2514#endif
2515#ifdef AL_INTERFACE
2516 x = PyInt_FromLong((long) AL_INTERFACE);
2517 if (x == NULL || PyDict_SetItemString(d, "INTERFACE", x) < 0)
2518 goto error;
2519 Py_DECREF(x);
2520#endif
2521#ifdef AL_INTERFACE_TYPE
2522 x = PyInt_FromLong((long) AL_INTERFACE_TYPE);
2523 if (x == NULL || PyDict_SetItemString(d, "INTERFACE_TYPE", x) < 0)
2524 goto error;
2525 Py_DECREF(x);
2526#endif
2527#ifdef AL_INVALID_PARAM
2528 x = PyInt_FromLong((long) AL_INVALID_PARAM);
2529 if (x == NULL || PyDict_SetItemString(d, "INVALID_PARAM", x) < 0)
2530 goto error;
2531 Py_DECREF(x);
2532#endif
2533#ifdef AL_INVALID_VALUE
2534 x = PyInt_FromLong((long) AL_INVALID_VALUE);
2535 if (x == NULL || PyDict_SetItemString(d, "INVALID_VALUE", x) < 0)
2536 goto error;
2537 Py_DECREF(x);
2538#endif
2539#ifdef AL_JITTER
2540 x = PyInt_FromLong((long) AL_JITTER);
2541 if (x == NULL || PyDict_SetItemString(d, "JITTER", x) < 0)
2542 goto error;
2543 Py_DECREF(x);
2544#endif
2545#ifdef AL_LABEL
2546 x = PyInt_FromLong((long) AL_LABEL);
2547 if (x == NULL || PyDict_SetItemString(d, "LABEL", x) < 0)
2548 goto error;
2549 Py_DECREF(x);
2550#endif
2551#ifdef AL_LEFT_INPUT_ATTEN
2552 x = PyInt_FromLong((long) AL_LEFT_INPUT_ATTEN);
2553 if (x == NULL || PyDict_SetItemString(d, "LEFT_INPUT_ATTEN", x) < 0)
2554 goto error;
2555 Py_DECREF(x);
2556#endif
2557#ifdef AL_LEFT_MONITOR_ATTEN
2558 x = PyInt_FromLong((long) AL_LEFT_MONITOR_ATTEN);
2559 if (x == NULL || PyDict_SetItemString(d, "LEFT_MONITOR_ATTEN", x) < 0)
2560 goto error;
2561 Py_DECREF(x);
2562#endif
2563#ifdef AL_LEFT_SPEAKER_GAIN
2564 x = PyInt_FromLong((long) AL_LEFT_SPEAKER_GAIN);
2565 if (x == NULL || PyDict_SetItemString(d, "LEFT_SPEAKER_GAIN", x) < 0)
2566 goto error;
2567 Py_DECREF(x);
2568#endif
2569#ifdef AL_LEFT1_INPUT_ATTEN
2570 x = PyInt_FromLong((long) AL_LEFT1_INPUT_ATTEN);
2571 if (x == NULL || PyDict_SetItemString(d, "LEFT1_INPUT_ATTEN", x) < 0)
2572 goto error;
2573 Py_DECREF(x);
2574#endif
2575#ifdef AL_LEFT2_INPUT_ATTEN
2576 x = PyInt_FromLong((long) AL_LEFT2_INPUT_ATTEN);
2577 if (x == NULL || PyDict_SetItemString(d, "LEFT2_INPUT_ATTEN", x) < 0)
2578 goto error;
2579 Py_DECREF(x);
2580#endif
2581#ifdef AL_LINE_IF_TYPE
2582 x = PyInt_FromLong((long) AL_LINE_IF_TYPE);
2583 if (x == NULL || PyDict_SetItemString(d, "LINE_IF_TYPE", x) < 0)
2584 goto error;
2585 Py_DECREF(x);
2586#endif
2587#ifdef AL_MASTER_CLOCK
2588 x = PyInt_FromLong((long) AL_MASTER_CLOCK);
2589 if (x == NULL || PyDict_SetItemString(d, "MASTER_CLOCK", x) < 0)
2590 goto error;
2591 Py_DECREF(x);
2592#endif
2593#ifdef AL_MATRIX_VAL
2594 x = PyInt_FromLong((long) AL_MATRIX_VAL);
2595 if (x == NULL || PyDict_SetItemString(d, "MATRIX_VAL", x) < 0)
2596 goto error;
2597 Py_DECREF(x);
2598#endif
2599#ifdef AL_MAX_ERROR
2600 x = PyInt_FromLong((long) AL_MAX_ERROR);
2601 if (x == NULL || PyDict_SetItemString(d, "MAX_ERROR", x) < 0)
2602 goto error;
2603 Py_DECREF(x);
2604#endif
2605#ifdef AL_MAX_EVENT_PARAM
2606 x = PyInt_FromLong((long) AL_MAX_EVENT_PARAM);
2607 if (x == NULL || PyDict_SetItemString(d, "MAX_EVENT_PARAM", x) < 0)
2608 goto error;
2609 Py_DECREF(x);
2610#endif
2611#ifdef AL_MAX_PBUFSIZE
2612 x = PyInt_FromLong((long) AL_MAX_PBUFSIZE);
2613 if (x == NULL || PyDict_SetItemString(d, "MAX_PBUFSIZE", x) < 0)
2614 goto error;
2615 Py_DECREF(x);
2616#endif
2617#ifdef AL_MAX_PORTS
2618 x = PyInt_FromLong((long) AL_MAX_PORTS);
2619 if (x == NULL || PyDict_SetItemString(d, "MAX_PORTS", x) < 0)
2620 goto error;
2621 Py_DECREF(x);
2622#endif
2623#ifdef AL_MAX_RESOURCE_ID
2624 x = PyInt_FromLong((long) AL_MAX_RESOURCE_ID);
2625 if (x == NULL || PyDict_SetItemString(d, "MAX_RESOURCE_ID", x) < 0)
2626 goto error;
2627 Py_DECREF(x);
2628#endif
2629#ifdef AL_MAX_SETSIZE
2630 x = PyInt_FromLong((long) AL_MAX_SETSIZE);
2631 if (x == NULL || PyDict_SetItemString(d, "MAX_SETSIZE", x) < 0)
2632 goto error;
2633 Py_DECREF(x);
2634#endif
2635#ifdef AL_MAX_STRLEN
2636 x = PyInt_FromLong((long) AL_MAX_STRLEN);
2637 if (x == NULL || PyDict_SetItemString(d, "MAX_STRLEN", x) < 0)
2638 goto error;
2639 Py_DECREF(x);
2640#endif
2641#ifdef AL_MCLK_TYPE
2642 x = PyInt_FromLong((long) AL_MCLK_TYPE);
2643 if (x == NULL || PyDict_SetItemString(d, "MCLK_TYPE", x) < 0)
2644 goto error;
2645 Py_DECREF(x);
2646#endif
2647#ifdef AL_MIC_IF_TYPE
2648 x = PyInt_FromLong((long) AL_MIC_IF_TYPE);
2649 if (x == NULL || PyDict_SetItemString(d, "MIC_IF_TYPE", x) < 0)
2650 goto error;
2651 Py_DECREF(x);
2652#endif
2653#ifdef AL_MONITOR_CTL
2654 x = PyInt_FromLong((long) AL_MONITOR_CTL);
2655 if (x == NULL || PyDict_SetItemString(d, "MONITOR_CTL", x) < 0)
2656 goto error;
2657 Py_DECREF(x);
2658#endif
2659#ifdef AL_MONITOR_OFF
2660 x = PyInt_FromLong((long) AL_MONITOR_OFF);
2661 if (x == NULL || PyDict_SetItemString(d, "MONITOR_OFF", x) < 0)
2662 goto error;
2663 Py_DECREF(x);
2664#endif
2665#ifdef AL_MONITOR_ON
2666 x = PyInt_FromLong((long) AL_MONITOR_ON);
2667 if (x == NULL || PyDict_SetItemString(d, "MONITOR_ON", x) < 0)
2668 goto error;
2669 Py_DECREF(x);
2670#endif
2671#ifdef AL_MONO
2672 x = PyInt_FromLong((long) AL_MONO);
2673 if (x == NULL || PyDict_SetItemString(d, "MONO", x) < 0)
2674 goto error;
2675 Py_DECREF(x);
2676#endif
2677#ifdef AL_MUTE
2678 x = PyInt_FromLong((long) AL_MUTE);
2679 if (x == NULL || PyDict_SetItemString(d, "MUTE", x) < 0)
2680 goto error;
2681 Py_DECREF(x);
2682#endif
2683#ifdef AL_NAME
2684 x = PyInt_FromLong((long) AL_NAME);
2685 if (x == NULL || PyDict_SetItemString(d, "NAME", x) < 0)
2686 goto error;
2687 Py_DECREF(x);
2688#endif
2689#ifdef AL_NEG_INFINITY
2690 x = PyInt_FromLong((long) AL_NEG_INFINITY);
2691 if (x == NULL || PyDict_SetItemString(d, "NEG_INFINITY", x) < 0)
2692 goto error;
2693 Py_DECREF(x);
2694#endif
2695#ifdef AL_NEG_INFINITY_BIT
2696 x = PyInt_FromLong((long) AL_NEG_INFINITY_BIT);
2697 if (x == NULL || PyDict_SetItemString(d, "NEG_INFINITY_BIT", x) < 0)
2698 goto error;
2699 Py_DECREF(x);
2700#endif
2701#ifdef AL_NO_CHANGE
2702 x = PyInt_FromLong((long) AL_NO_CHANGE);
2703 if (x == NULL || PyDict_SetItemString(d, "NO_CHANGE", x) < 0)
2704 goto error;
2705 Py_DECREF(x);
2706#endif
2707#ifdef AL_NO_CHANGE_BIT
2708 x = PyInt_FromLong((long) AL_NO_CHANGE_BIT);
2709 if (x == NULL || PyDict_SetItemString(d, "NO_CHANGE_BIT", x) < 0)
2710 goto error;
2711 Py_DECREF(x);
2712#endif
2713#ifdef AL_NO_ELEM
2714 x = PyInt_FromLong((long) AL_NO_ELEM);
2715 if (x == NULL || PyDict_SetItemString(d, "NO_ELEM", x) < 0)
2716 goto error;
2717 Py_DECREF(x);
2718#endif
2719#ifdef AL_NO_ERRORS
2720 x = PyInt_FromLong((long) AL_NO_ERRORS);
2721 if (x == NULL || PyDict_SetItemString(d, "NO_ERRORS", x) < 0)
2722 goto error;
2723 Py_DECREF(x);
2724#endif
2725#ifdef AL_NO_OP
2726 x = PyInt_FromLong((long) AL_NO_OP);
2727 if (x == NULL || PyDict_SetItemString(d, "NO_OP", x) < 0)
2728 goto error;
2729 Py_DECREF(x);
2730#endif
2731#ifdef AL_NO_VAL
2732 x = PyInt_FromLong((long) AL_NO_VAL);
2733 if (x == NULL || PyDict_SetItemString(d, "NO_VAL", x) < 0)
2734 goto error;
2735 Py_DECREF(x);
2736#endif
2737#ifdef AL_NULL_RESOURCE
2738 x = PyInt_FromLong((long) AL_NULL_RESOURCE);
2739 if (x == NULL || PyDict_SetItemString(d, "NULL_RESOURCE", x) < 0)
2740 goto error;
2741 Py_DECREF(x);
2742#endif
2743#ifdef AL_OUTPUT_COUNT
2744 x = PyInt_FromLong((long) AL_OUTPUT_COUNT);
2745 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_COUNT", x) < 0)
2746 goto error;
2747 Py_DECREF(x);
2748#endif
2749#ifdef AL_OUTPUT_DEVICE_TYPE
2750 x = PyInt_FromLong((long) AL_OUTPUT_DEVICE_TYPE);
2751 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_DEVICE_TYPE", x) < 0)
2752 goto error;
2753 Py_DECREF(x);
2754#endif
2755#ifdef AL_OUTPUT_HRB_TYPE
2756 x = PyInt_FromLong((long) AL_OUTPUT_HRB_TYPE);
2757 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_HRB_TYPE", x) < 0)
2758 goto error;
2759 Py_DECREF(x);
2760#endif
2761#ifdef AL_OUTPUT_PORT_TYPE
2762 x = PyInt_FromLong((long) AL_OUTPUT_PORT_TYPE);
2763 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_PORT_TYPE", x) < 0)
2764 goto error;
2765 Py_DECREF(x);
2766#endif
2767#ifdef AL_OUTPUT_RATE
2768 x = PyInt_FromLong((long) AL_OUTPUT_RATE);
2769 if (x == NULL || PyDict_SetItemString(d, "OUTPUT_RATE", x) < 0)
2770 goto error;
2771 Py_DECREF(x);
2772#endif
2773#ifdef AL_PARAM_BIT
2774 x = PyInt_FromLong((long) AL_PARAM_BIT);
2775 if (x == NULL || PyDict_SetItemString(d, "PARAM_BIT", x) < 0)
2776 goto error;
2777 Py_DECREF(x);
2778#endif
2779#ifdef AL_PARAMS
2780 x = PyInt_FromLong((long) AL_PARAMS);
2781 if (x == NULL || PyDict_SetItemString(d, "PARAMS", x) < 0)
2782 goto error;
2783 Py_DECREF(x);
2784#endif
2785#ifdef AL_PORT_COUNT
2786 x = PyInt_FromLong((long) AL_PORT_COUNT);
2787 if (x == NULL || PyDict_SetItemString(d, "PORT_COUNT", x) < 0)
2788 goto error;
2789 Py_DECREF(x);
2790#endif
2791#ifdef AL_PORT_TYPE
2792 x = PyInt_FromLong((long) AL_PORT_TYPE);
2793 if (x == NULL || PyDict_SetItemString(d, "PORT_TYPE", x) < 0)
2794 goto error;
2795 Py_DECREF(x);
2796#endif
2797#ifdef AL_PORTS
2798 x = PyInt_FromLong((long) AL_PORTS);
2799 if (x == NULL || PyDict_SetItemString(d, "PORTS", x) < 0)
2800 goto error;
2801 Py_DECREF(x);
2802#endif
2803#ifdef AL_PORTSTYLE_DIRECT
2804 x = PyInt_FromLong((long) AL_PORTSTYLE_DIRECT);
2805 if (x == NULL || PyDict_SetItemString(d, "PORTSTYLE_DIRECT", x) < 0)
2806 goto error;
2807 Py_DECREF(x);
2808#endif
2809#ifdef AL_PORTSTYLE_SERIAL
2810 x = PyInt_FromLong((long) AL_PORTSTYLE_SERIAL);
2811 if (x == NULL || PyDict_SetItemString(d, "PORTSTYLE_SERIAL", x) < 0)
2812 goto error;
2813 Py_DECREF(x);
2814#endif
2815#ifdef AL_PRINT_ERRORS
2816 x = PyInt_FromLong((long) AL_PRINT_ERRORS);
2817 if (x == NULL || PyDict_SetItemString(d, "PRINT_ERRORS", x) < 0)
2818 goto error;
2819 Py_DECREF(x);
2820#endif
2821#ifdef AL_PTR_ELEM
2822 x = PyInt_FromLong((long) AL_PTR_ELEM);
2823 if (x == NULL || PyDict_SetItemString(d, "PTR_ELEM", x) < 0)
2824 goto error;
2825 Py_DECREF(x);
2826#endif
2827#ifdef AL_RANGE_VALUE
2828 x = PyInt_FromLong((long) AL_RANGE_VALUE);
2829 if (x == NULL || PyDict_SetItemString(d, "RANGE_VALUE", x) < 0)
2830 goto error;
2831 Py_DECREF(x);
2832#endif
2833#ifdef AL_RATE
2834 x = PyInt_FromLong((long) AL_RATE);
2835 if (x == NULL || PyDict_SetItemString(d, "RATE", x) < 0)
2836 goto error;
2837 Py_DECREF(x);
2838#endif
2839#ifdef AL_RATE_11025
2840 x = PyInt_FromLong((long) AL_RATE_11025);
2841 if (x == NULL || PyDict_SetItemString(d, "RATE_11025", x) < 0)
2842 goto error;
2843 Py_DECREF(x);
2844#endif
2845#ifdef AL_RATE_16000
2846 x = PyInt_FromLong((long) AL_RATE_16000);
2847 if (x == NULL || PyDict_SetItemString(d, "RATE_16000", x) < 0)
2848 goto error;
2849 Py_DECREF(x);
2850#endif
2851#ifdef AL_RATE_22050
2852 x = PyInt_FromLong((long) AL_RATE_22050);
2853 if (x == NULL || PyDict_SetItemString(d, "RATE_22050", x) < 0)
2854 goto error;
2855 Py_DECREF(x);
2856#endif
2857#ifdef AL_RATE_32000
2858 x = PyInt_FromLong((long) AL_RATE_32000);
2859 if (x == NULL || PyDict_SetItemString(d, "RATE_32000", x) < 0)
2860 goto error;
2861 Py_DECREF(x);
2862#endif
2863#ifdef AL_RATE_44100
2864 x = PyInt_FromLong((long) AL_RATE_44100);
2865 if (x == NULL || PyDict_SetItemString(d, "RATE_44100", x) < 0)
2866 goto error;
2867 Py_DECREF(x);
2868#endif
2869#ifdef AL_RATE_48000
2870 x = PyInt_FromLong((long) AL_RATE_48000);
2871 if (x == NULL || PyDict_SetItemString(d, "RATE_48000", x) < 0)
2872 goto error;
2873 Py_DECREF(x);
2874#endif
2875#ifdef AL_RATE_8000
2876 x = PyInt_FromLong((long) AL_RATE_8000);
2877 if (x == NULL || PyDict_SetItemString(d, "RATE_8000", x) < 0)
2878 goto error;
2879 Py_DECREF(x);
2880#endif
2881#ifdef AL_RATE_AES_1
2882 x = PyInt_FromLong((long) AL_RATE_AES_1);
2883 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_1", x) < 0)
2884 goto error;
2885 Py_DECREF(x);
2886#endif
2887#ifdef AL_RATE_AES_1s
2888 x = PyInt_FromLong((long) AL_RATE_AES_1s);
2889 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_1s", x) < 0)
2890 goto error;
2891 Py_DECREF(x);
2892#endif
2893#ifdef AL_RATE_AES_2
2894 x = PyInt_FromLong((long) AL_RATE_AES_2);
2895 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_2", x) < 0)
2896 goto error;
2897 Py_DECREF(x);
2898#endif
2899#ifdef AL_RATE_AES_3
2900 x = PyInt_FromLong((long) AL_RATE_AES_3);
2901 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_3", x) < 0)
2902 goto error;
2903 Py_DECREF(x);
2904#endif
2905#ifdef AL_RATE_AES_4
2906 x = PyInt_FromLong((long) AL_RATE_AES_4);
2907 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_4", x) < 0)
2908 goto error;
2909 Py_DECREF(x);
2910#endif
2911#ifdef AL_RATE_AES_6
2912 x = PyInt_FromLong((long) AL_RATE_AES_6);
2913 if (x == NULL || PyDict_SetItemString(d, "RATE_AES_6", x) < 0)
2914 goto error;
2915 Py_DECREF(x);
2916#endif
2917#ifdef AL_RATE_FRACTION_D
2918 x = PyInt_FromLong((long) AL_RATE_FRACTION_D);
2919 if (x == NULL || PyDict_SetItemString(d, "RATE_FRACTION_D", x) < 0)
2920 goto error;
2921 Py_DECREF(x);
2922#endif
2923#ifdef AL_RATE_FRACTION_N
2924 x = PyInt_FromLong((long) AL_RATE_FRACTION_N);
2925 if (x == NULL || PyDict_SetItemString(d, "RATE_FRACTION_N", x) < 0)
2926 goto error;
2927 Py_DECREF(x);
2928#endif
2929#ifdef AL_RATE_INPUTRATE
2930 x = PyInt_FromLong((long) AL_RATE_INPUTRATE);
2931 if (x == NULL || PyDict_SetItemString(d, "RATE_INPUTRATE", x) < 0)
2932 goto error;
2933 Py_DECREF(x);
2934#endif
2935#ifdef AL_RATE_NO_DIGITAL_INPUT
2936 x = PyInt_FromLong((long) AL_RATE_NO_DIGITAL_INPUT);
2937 if (x == NULL || PyDict_SetItemString(d, "RATE_NO_DIGITAL_INPUT", x) < 0)
2938 goto error;
2939 Py_DECREF(x);
2940#endif
2941#ifdef AL_RATE_UNACQUIRED
2942 x = PyInt_FromLong((long) AL_RATE_UNACQUIRED);
2943 if (x == NULL || PyDict_SetItemString(d, "RATE_UNACQUIRED", x) < 0)
2944 goto error;
2945 Py_DECREF(x);
2946#endif
2947#ifdef AL_RATE_UNDEFINED
2948 x = PyInt_FromLong((long) AL_RATE_UNDEFINED);
2949 if (x == NULL || PyDict_SetItemString(d, "RATE_UNDEFINED", x) < 0)
2950 goto error;
2951 Py_DECREF(x);
2952#endif
2953#ifdef AL_REF_0DBV
2954 x = PyInt_FromLong((long) AL_REF_0DBV);
2955 if (x == NULL || PyDict_SetItemString(d, "REF_0DBV", x) < 0)
2956 goto error;
2957 Py_DECREF(x);
2958#endif
2959#ifdef AL_REF_NONE
2960 x = PyInt_FromLong((long) AL_REF_NONE);
2961 if (x == NULL || PyDict_SetItemString(d, "REF_NONE", x) < 0)
2962 goto error;
2963 Py_DECREF(x);
2964#endif
2965#ifdef AL_RESERVED1_TYPE
2966 x = PyInt_FromLong((long) AL_RESERVED1_TYPE);
2967 if (x == NULL || PyDict_SetItemString(d, "RESERVED1_TYPE", x) < 0)
2968 goto error;
2969 Py_DECREF(x);
2970#endif
2971#ifdef AL_RESERVED2_TYPE
2972 x = PyInt_FromLong((long) AL_RESERVED2_TYPE);
2973 if (x == NULL || PyDict_SetItemString(d, "RESERVED2_TYPE", x) < 0)
2974 goto error;
2975 Py_DECREF(x);
2976#endif
2977#ifdef AL_RESERVED3_TYPE
2978 x = PyInt_FromLong((long) AL_RESERVED3_TYPE);
2979 if (x == NULL || PyDict_SetItemString(d, "RESERVED3_TYPE", x) < 0)
2980 goto error;
2981 Py_DECREF(x);
2982#endif
2983#ifdef AL_RESERVED4_TYPE
2984 x = PyInt_FromLong((long) AL_RESERVED4_TYPE);
2985 if (x == NULL || PyDict_SetItemString(d, "RESERVED4_TYPE", x) < 0)
2986 goto error;
2987 Py_DECREF(x);
2988#endif
2989#ifdef AL_RESOURCE
2990 x = PyInt_FromLong((long) AL_RESOURCE);
2991 if (x == NULL || PyDict_SetItemString(d, "RESOURCE", x) < 0)
2992 goto error;
2993 Py_DECREF(x);
2994#endif
2995#ifdef AL_RESOURCE_ELEM
2996 x = PyInt_FromLong((long) AL_RESOURCE_ELEM);
2997 if (x == NULL || PyDict_SetItemString(d, "RESOURCE_ELEM", x) < 0)
2998 goto error;
2999 Py_DECREF(x);
3000#endif
3001#ifdef AL_RESOURCE_TYPE
3002 x = PyInt_FromLong((long) AL_RESOURCE_TYPE);
3003 if (x == NULL || PyDict_SetItemString(d, "RESOURCE_TYPE", x) < 0)
3004 goto error;
3005 Py_DECREF(x);
3006#endif
3007#ifdef AL_RIGHT_INPUT_ATTEN
3008 x = PyInt_FromLong((long) AL_RIGHT_INPUT_ATTEN);
3009 if (x == NULL || PyDict_SetItemString(d, "RIGHT_INPUT_ATTEN", x) < 0)
3010 goto error;
3011 Py_DECREF(x);
3012#endif
3013#ifdef AL_RIGHT_MONITOR_ATTEN
3014 x = PyInt_FromLong((long) AL_RIGHT_MONITOR_ATTEN);
3015 if (x == NULL || PyDict_SetItemString(d, "RIGHT_MONITOR_ATTEN", x) < 0)
3016 goto error;
3017 Py_DECREF(x);
3018#endif
3019#ifdef AL_RIGHT_SPEAKER_GAIN
3020 x = PyInt_FromLong((long) AL_RIGHT_SPEAKER_GAIN);
3021 if (x == NULL || PyDict_SetItemString(d, "RIGHT_SPEAKER_GAIN", x) < 0)
3022 goto error;
3023 Py_DECREF(x);
3024#endif
3025#ifdef AL_RIGHT1_INPUT_ATTEN
3026 x = PyInt_FromLong((long) AL_RIGHT1_INPUT_ATTEN);
3027 if (x == NULL || PyDict_SetItemString(d, "RIGHT1_INPUT_ATTEN", x) < 0)
3028 goto error;
3029 Py_DECREF(x);
3030#endif
3031#ifdef AL_RIGHT2_INPUT_ATTEN
3032 x = PyInt_FromLong((long) AL_RIGHT2_INPUT_ATTEN);
3033 if (x == NULL || PyDict_SetItemString(d, "RIGHT2_INPUT_ATTEN", x) < 0)
3034 goto error;
3035 Py_DECREF(x);
3036#endif
3037#ifdef AL_SAMPFMT_DOUBLE
3038 x = PyInt_FromLong((long) AL_SAMPFMT_DOUBLE);
3039 if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_DOUBLE", x) < 0)
3040 goto error;
3041 Py_DECREF(x);
3042#endif
3043#ifdef AL_SAMPFMT_FLOAT
3044 x = PyInt_FromLong((long) AL_SAMPFMT_FLOAT);
3045 if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_FLOAT", x) < 0)
3046 goto error;
3047 Py_DECREF(x);
3048#endif
3049#ifdef AL_SAMPFMT_TWOSCOMP
3050 x = PyInt_FromLong((long) AL_SAMPFMT_TWOSCOMP);
3051 if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_TWOSCOMP", x) < 0)
3052 goto error;
3053 Py_DECREF(x);
3054#endif
3055#ifdef AL_SAMPLE_16
3056 x = PyInt_FromLong((long) AL_SAMPLE_16);
3057 if (x == NULL || PyDict_SetItemString(d, "SAMPLE_16", x) < 0)
3058 goto error;
3059 Py_DECREF(x);
3060#endif
3061#ifdef AL_SAMPLE_24
3062 x = PyInt_FromLong((long) AL_SAMPLE_24);
3063 if (x == NULL || PyDict_SetItemString(d, "SAMPLE_24", x) < 0)
3064 goto error;
3065 Py_DECREF(x);
3066#endif
3067#ifdef AL_SAMPLE_8
3068 x = PyInt_FromLong((long) AL_SAMPLE_8);
3069 if (x == NULL || PyDict_SetItemString(d, "SAMPLE_8", x) < 0)
3070 goto error;
3071 Py_DECREF(x);
3072#endif
3073#ifdef AL_SCALAR_VAL
3074 x = PyInt_FromLong((long) AL_SCALAR_VAL);
3075 if (x == NULL || PyDict_SetItemString(d, "SCALAR_VAL", x) < 0)
3076 goto error;
3077 Py_DECREF(x);
3078#endif
3079#ifdef AL_SET_VAL
3080 x = PyInt_FromLong((long) AL_SET_VAL);
3081 if (x == NULL || PyDict_SetItemString(d, "SET_VAL", x) < 0)
3082 goto error;
3083 Py_DECREF(x);
3084#endif
3085#ifdef AL_SHORT_NAME
3086 x = PyInt_FromLong((long) AL_SHORT_NAME);
3087 if (x == NULL || PyDict_SetItemString(d, "SHORT_NAME", x) < 0)
3088 goto error;
3089 Py_DECREF(x);
3090#endif
3091#ifdef AL_SOURCE
3092 x = PyInt_FromLong((long) AL_SOURCE);
3093 if (x == NULL || PyDict_SetItemString(d, "SOURCE", x) < 0)
3094 goto error;
3095 Py_DECREF(x);
3096#endif
3097#ifdef AL_SPEAKER_IF_TYPE
3098 x = PyInt_FromLong((long) AL_SPEAKER_IF_TYPE);
3099 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_IF_TYPE", x) < 0)
3100 goto error;
3101 Py_DECREF(x);
3102#endif
3103#ifdef AL_SPEAKER_MUTE_CTL
3104 x = PyInt_FromLong((long) AL_SPEAKER_MUTE_CTL);
3105 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_CTL", x) < 0)
3106 goto error;
3107 Py_DECREF(x);
3108#endif
3109#ifdef AL_SPEAKER_MUTE_OFF
3110 x = PyInt_FromLong((long) AL_SPEAKER_MUTE_OFF);
3111 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_OFF", x) < 0)
3112 goto error;
3113 Py_DECREF(x);
3114#endif
3115#ifdef AL_SPEAKER_MUTE_ON
3116 x = PyInt_FromLong((long) AL_SPEAKER_MUTE_ON);
3117 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_ON", x) < 0)
3118 goto error;
3119 Py_DECREF(x);
3120#endif
3121#ifdef AL_SPEAKER_PLUS_LINE_IF_TYPE
3122 x = PyInt_FromLong((long) AL_SPEAKER_PLUS_LINE_IF_TYPE);
3123 if (x == NULL || PyDict_SetItemString(d, "SPEAKER_PLUS_LINE_IF_TYPE", x) < 0)
3124 goto error;
3125 Py_DECREF(x);
3126#endif
3127#ifdef AL_STEREO
3128 x = PyInt_FromLong((long) AL_STEREO);
3129 if (x == NULL || PyDict_SetItemString(d, "STEREO", x) < 0)
3130 goto error;
3131 Py_DECREF(x);
3132#endif
3133#ifdef AL_STRING_VAL
3134 x = PyInt_FromLong((long) AL_STRING_VAL);
3135 if (x == NULL || PyDict_SetItemString(d, "STRING_VAL", x) < 0)
3136 goto error;
3137 Py_DECREF(x);
3138#endif
3139#ifdef AL_SUBSYSTEM
3140 x = PyInt_FromLong((long) AL_SUBSYSTEM);
3141 if (x == NULL || PyDict_SetItemString(d, "SUBSYSTEM", x) < 0)
3142 goto error;
3143 Py_DECREF(x);
3144#endif
3145#ifdef AL_SUBSYSTEM_TYPE
3146 x = PyInt_FromLong((long) AL_SUBSYSTEM_TYPE);
3147 if (x == NULL || PyDict_SetItemString(d, "SUBSYSTEM_TYPE", x) < 0)
3148 goto error;
3149 Py_DECREF(x);
3150#endif
3151#ifdef AL_SYNC_INPUT_TO_AES
3152 x = PyInt_FromLong((long) AL_SYNC_INPUT_TO_AES);
3153 if (x == NULL || PyDict_SetItemString(d, "SYNC_INPUT_TO_AES", x) < 0)
3154 goto error;
3155 Py_DECREF(x);
3156#endif
3157#ifdef AL_SYNC_OUTPUT_TO_AES
3158 x = PyInt_FromLong((long) AL_SYNC_OUTPUT_TO_AES);
3159 if (x == NULL || PyDict_SetItemString(d, "SYNC_OUTPUT_TO_AES", x) < 0)
3160 goto error;
3161 Py_DECREF(x);
3162#endif
3163#ifdef AL_SYSTEM
3164 x = PyInt_FromLong((long) AL_SYSTEM);
3165 if (x == NULL || PyDict_SetItemString(d, "SYSTEM", x) < 0)
3166 goto error;
3167 Py_DECREF(x);
3168#endif
3169#ifdef AL_SYSTEM_TYPE
3170 x = PyInt_FromLong((long) AL_SYSTEM_TYPE);
3171 if (x == NULL || PyDict_SetItemString(d, "SYSTEM_TYPE", x) < 0)
3172 goto error;
3173 Py_DECREF(x);
3174#endif
3175#ifdef AL_TEST_IF_TYPE
3176 x = PyInt_FromLong((long) AL_TEST_IF_TYPE);
3177 if (x == NULL || PyDict_SetItemString(d, "TEST_IF_TYPE", x) < 0)
3178 goto error;
3179 Py_DECREF(x);
3180#endif
3181#ifdef AL_TYPE
3182 x = PyInt_FromLong((long) AL_TYPE);
3183 if (x == NULL || PyDict_SetItemString(d, "TYPE", x) < 0)
3184 goto error;
3185 Py_DECREF(x);
3186#endif
3187#ifdef AL_TYPE_BIT
3188 x = PyInt_FromLong((long) AL_TYPE_BIT);
3189 if (x == NULL || PyDict_SetItemString(d, "TYPE_BIT", x) < 0)
3190 goto error;
3191 Py_DECREF(x);
3192#endif
3193#ifdef AL_UNUSED_COUNT
3194 x = PyInt_FromLong((long) AL_UNUSED_COUNT);
3195 if (x == NULL || PyDict_SetItemString(d, "UNUSED_COUNT", x) < 0)
3196 goto error;
3197 Py_DECREF(x);
3198#endif
3199#ifdef AL_UNUSED_PORTS
3200 x = PyInt_FromLong((long) AL_UNUSED_PORTS);
3201 if (x == NULL || PyDict_SetItemString(d, "UNUSED_PORTS", x) < 0)
3202 goto error;
3203 Py_DECREF(x);
3204#endif
3205#ifdef AL_VARIABLE_MCLK_TYPE
3206 x = PyInt_FromLong((long) AL_VARIABLE_MCLK_TYPE);
3207 if (x == NULL || PyDict_SetItemString(d, "VARIABLE_MCLK_TYPE", x) < 0)
3208 goto error;
3209 Py_DECREF(x);
3210#endif
3211#ifdef AL_VECTOR_VAL
3212 x = PyInt_FromLong((long) AL_VECTOR_VAL);
3213 if (x == NULL || PyDict_SetItemString(d, "VECTOR_VAL", x) < 0)
3214 goto error;
3215 Py_DECREF(x);
3216#endif
3217#ifdef AL_VIDEO_MCLK_TYPE
3218 x = PyInt_FromLong((long) AL_VIDEO_MCLK_TYPE);
3219 if (x == NULL || PyDict_SetItemString(d, "VIDEO_MCLK_TYPE", x) < 0)
3220 goto error;
3221 Py_DECREF(x);
3222#endif
3223#ifdef AL_WORDSIZE
3224 x = PyInt_FromLong((long) AL_WORDSIZE);
3225 if (x == NULL || PyDict_SetItemString(d, "WORDSIZE", x) < 0)
3226 goto error;
3227 Py_DECREF(x);
3228#endif
3229
3230#ifdef AL_NO_ELEM /* IRIX 6 */
3231 (void) alSetErrorHandler(ErrorHandler);
3232#endif /* AL_NO_ELEM */
3233#ifdef OLD_INTERFACE
3234 (void) ALseterrorhandler(ErrorHandler);
3235#endif /* OLD_INTERFACE */
Guido van Rossume3db8621991-09-09 23:33:34 +00003236
Barry Warsaw9bfd2bf2000-09-01 09:01:32 +00003237 error:
3238 return;
Guido van Rossume3db8621991-09-09 23:33:34 +00003239}