PageRenderTime 34ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/Modules/almodule.c

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