[Python-checkins] python/dist/src/Modules ossaudiodev.c,1.19,1.20
gward@users.sourceforge.net
gward@users.sourceforge.net
2002年12月30日 19:24:03 -0800
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv8962
Modified Files:
ossaudiodev.c
Log Message:
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
SOUND_DEVICE_NAMES as 'control_labels' and 'control_names'.
Index: ossaudiodev.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/ossaudiodev.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** ossaudiodev.c 31 Dec 2002 03:07:21 -0000 1.19
--- ossaudiodev.c 31 Dec 2002 03:23:59 -0000 1.20
***************
*** 895,898 ****
--- 895,938 ----
if (PyModule_AddIntConstant(mod, #name, (long) (name)) == -1) return;
+
+ static char *control_labels[] = SOUND_DEVICE_LABELS;
+ static char *control_names[] = SOUND_DEVICE_NAMES;
+
+
+ static int
+ build_namelists (PyObject *module)
+ {
+ PyObject *labels;
+ PyObject *names;
+ PyObject *s;
+ int num_controls;
+ int i;
+
+ num_controls = sizeof(control_labels) / sizeof(control_labels[0]);
+ assert(num_controls == sizeof(control_names) / sizeof(control_names[0]));
+
+ labels = PyList_New(num_controls);
+ names = PyList_New(num_controls);
+ for (i = 0; i < num_controls; i++) {
+ s = PyString_FromString(control_labels[i]);
+ if (s == NULL)
+ return -1;
+ PyList_SET_ITEM(labels, i, s);
+
+ s = PyString_FromString(control_names[i]);
+ if (s == NULL)
+ return -1;
+ PyList_SET_ITEM(names, i, s);
+ }
+
+ if (PyModule_AddObject(module, "control_labels", labels) == -1)
+ return -1;
+ if (PyModule_AddObject(module, "control_names", names) == -1)
+ return -1;
+
+ return 0;
+ }
+
+
void
initossaudiodev(void)
***************
*** 905,908 ****
--- 945,953 ----
if (OSSAudioError)
PyModule_AddObject(m, "error", OSSAudioError);
+
+ /* Build 'control_labels' and 'control_names' lists and add them
+ to the module. */
+ if (build_namelists(m) == -1) /* XXX what to do here? */
+ return;
/* Expose the audio format numbers -- essential! */