diff options
author | Greg Ward <gward@python.net> | 2002-12-31 03:23:59 (GMT) |
---|---|---|
committer | Greg Ward <gward@python.net> | 2002-12-31 03:23:59 (GMT) |
commit | 744f0fd655cd55676532119894e2845d0533608b (patch) | |
tree | 5886a09fc723ed2249a79e9012d41a84096a26b3 /Modules/ossaudiodev.c | |
parent | 58ae13c1b23fa26c55b02f993bac83a915d3c367 (diff) | |
download | cpython-744f0fd655cd55676532119894e2845d0533608b.zip cpython-744f0fd655cd55676532119894e2845d0533608b.tar.gz cpython-744f0fd655cd55676532119894e2845d0533608b.tar.bz2 |
Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
SOUND_DEVICE_NAMES as 'control_labels' and 'control_names'.
Diffstat (limited to 'Modules/ossaudiodev.c')
-rw-r--r-- | Modules/ossaudiodev.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c index caa5a9f..9bfd55e 100644 --- a/Modules/ossaudiodev.c +++ b/Modules/ossaudiodev.c @@ -894,6 +894,46 @@ static PyMethodDef ossaudiodev_methods[] = { #define _EXPORT_INT(mod, name) \ 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,6 +945,11 @@ initossaudiodev(void) 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! */ _EXPORT_INT(m, AFMT_QUERY); _EXPORT_INT(m, AFMT_MU_LAW); |