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