summaryrefslogtreecommitdiff
path: root/Modules/ossaudiodev.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 +0000
committerMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 +0000
commitecca9993d71841bcea26988c7aafbeb5d504d7a7 (patch)
tree33f1d23fa7bcf60f3149d179e665aaf09504c450 /Modules/ossaudiodev.c
parent4c0cd2b3a9de411cfbc9e81be5ee91506c27e661 (diff)
downloadcpython-ecca9993d71841bcea26988c7aafbeb5d504d7a7.tar.gz
Implement PEP 3121: new module initialization and finalization API.
Diffstat (limited to 'Modules/ossaudiodev.c')
-rw-r--r--Modules/ossaudiodev.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c
index b976873f4e..43215b0723 100644
--- a/Modules/ossaudiodev.c
+++ b/Modules/ossaudiodev.c
@@ -889,7 +889,7 @@ static PyMethodDef ossaudiodev_methods[] = {
#define _EXPORT_INT(mod, name) \
- if (PyModule_AddIntConstant(mod, #name, (long) (name)) == -1) return;
+ if (PyModule_AddIntConstant(mod, #name, (long) (name)) == -1) return NULL;
static char *control_labels[] = SOUND_DEVICE_LABELS;
@@ -939,14 +939,26 @@ error1:
}
-void
-initossaudiodev(void)
+static struct PyModuleDef ossaudiodevmodule = {
+ PyModuleDef_HEAD_INIT,
+ "ossaudiodev",
+ NULL,
+ -1,
+ ossaudiodev_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+PyObject*
+PyInit_ossaudiodev(void)
{
PyObject *m;
- m = Py_InitModule("ossaudiodev", ossaudiodev_methods);
+ m = PyModule_Create(&ossaudiodevmodule);
if (m == NULL)
- return;
+ return NULL;
OSSAudioError = PyErr_NewException("ossaudiodev.OSSAudioError",
NULL, NULL);
@@ -961,7 +973,7 @@ initossaudiodev(void)
/* Build 'control_labels' and 'control_names' lists and add them
to the module. */
if (build_namelists(m) == -1) /* XXX what to do here? */
- return;
+ return NULL;
/* Expose the audio format numbers -- essential! */
_EXPORT_INT(m, AFMT_QUERY);
@@ -1133,4 +1145,5 @@ initossaudiodev(void)
_EXPORT_INT(m, SNDCTL_TMR_STOP);
_EXPORT_INT(m, SNDCTL_TMR_TEMPO);
_EXPORT_INT(m, SNDCTL_TMR_TIMEBASE);
+ return m;
}