diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 (GMT) |
commit | 1a21451b1d73b65af949193208372e86bf308411 (patch) | |
tree | 8e98d7be9e249b011ae9380479656e5284ec0234 /Modules/ossaudiodev.c | |
parent | cdf94635d7e364f9ce1905bafa5b540f4d16147c (diff) | |
download | cpython-1a21451b1d73b65af949193208372e86bf308411.zip cpython-1a21451b1d73b65af949193208372e86bf308411.tar.gz cpython-1a21451b1d73b65af949193208372e86bf308411.tar.bz2 |
Implement PEP 3121: new module initialization and finalization API.
Diffstat (limited to 'Modules/ossaudiodev.c')
-rw-r--r-- | Modules/ossaudiodev.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c index b976873..43215b0 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; } |