home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / palmos / pippy-0.6beta-src.tar.gz / pippy-0.6beta-src.tar / pippy-0.6beta-src / src / Modules / almodule.c < prev    next >
C/C++ Source or Header  |  2000-12-21  |  84KB  |  3,419 lines

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