diff options
Diffstat (limited to 'Modules/audioop.c')
-rw-r--r-- | Modules/audioop.c | 267 |
1 files changed, 150 insertions, 117 deletions
diff --git a/Modules/audioop.c b/Modules/audioop.c index fc79cf52b2d..9ab4834e29c 100644 --- a/Modules/audioop.c +++ b/Modules/audioop.c @@ -1,6 +1,8 @@ /* audioopmodule - Module to detect peak values in arrays */ +#define PY_SSIZE_T_CLEAN + #include "Python.h" #if SIZEOF_INT == 4 @@ -307,7 +309,7 @@ audioop_check_size(int size) } static int -audioop_check_parameters(int len, int size) +audioop_check_parameters(Py_ssize_t len, int size) { if (!audioop_check_size(size)) return 0; @@ -322,10 +324,10 @@ static PyObject * audioop_getsample(PyObject *self, PyObject *args) { signed char *cp; - int len, size, val = 0; - int i; + Py_ssize_t len, i; + int size, val = 0; - if ( !PyArg_ParseTuple(args, "s#ii:getsample", &cp, &len, &size, &i) ) + if ( !PyArg_ParseTuple(args, "s#in:getsample", &cp, &len, &size, &i) ) return 0; if (!audioop_check_parameters(len, size)) return NULL; @@ -336,15 +338,15 @@ audioop_getsample(PyObject *self, PyObject *args) if ( size == 1 ) val = (int)*CHARP(cp, i); else if ( size == 2 ) val = (int)*SHORTP(cp, i*2); else if ( size == 4 ) val = (int)*LONGP(cp, i*4); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } static PyObject * audioop_max(PyObject *self, PyObject *args) { signed char *cp; - int len, size, val = 0; - int i; + Py_ssize_t len, i; + int size, val = 0; int max = 0; if ( !PyArg_ParseTuple(args, "s#i:max", &cp, &len, &size) ) @@ -358,15 +360,15 @@ audioop_max(PyObject *self, PyObject *args) if ( val < 0 ) val = (-val); if ( val > max ) max = val; } - return PyInt_FromLong(max); + return PyLong_FromLong(max); } static PyObject * audioop_minmax(PyObject *self, PyObject *args) { signed char *cp; - int len, size, val = 0; - int i; + Py_ssize_t len, i; + int size, val = 0; int min = 0x7fffffff, max = -0x7fffffff; if (!PyArg_ParseTuple(args, "s#i:minmax", &cp, &len, &size)) @@ -387,8 +389,8 @@ static PyObject * audioop_avg(PyObject *self, PyObject *args) { signed char *cp; - int len, size, val = 0; - int i; + Py_ssize_t len, i; + int size, val = 0; double avg = 0.0; if ( !PyArg_ParseTuple(args, "s#i:avg", &cp, &len, &size) ) @@ -405,15 +407,15 @@ audioop_avg(PyObject *self, PyObject *args) val = 0; else val = (int)(avg / (double)(len/size)); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } static PyObject * audioop_rms(PyObject *self, PyObject *args) { signed char *cp; - int len, size, val = 0; - int i; + Py_ssize_t len, i; + int size, val = 0; double sum_squares = 0.0; if ( !PyArg_ParseTuple(args, "s#i:rms", &cp, &len, &size) ) @@ -430,12 +432,12 @@ audioop_rms(PyObject *self, PyObject *args) val = 0; else val = (int)sqrt(sum_squares / (double)(len/size)); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } -static double _sum2(short *a, short *b, int len) +static double _sum2(short *a, short *b, Py_ssize_t len) { - int i; + Py_ssize_t i; double sum = 0.0; for( i=0; i<len; i++) { @@ -480,14 +482,14 @@ static PyObject * audioop_findfit(PyObject *self, PyObject *args) { short *cp1, *cp2; - int len1, len2; - int j, best_j; + Py_ssize_t len1, len2; + Py_ssize_t j, best_j; double aj_m1, aj_lm1; double sum_ri_2, sum_aij_2, sum_aij_ri, result, best_result, factor; /* Passing a short** for an 's' argument is correct only if the string contents is aligned for interpretation - as short[]. Due to the definition of PyStringObject, + as short[]. Due to the definition of PyBytesObject, this is currently (Python 2.6) the case. */ if ( !PyArg_ParseTuple(args, "s#s#:findfit", (char**)&cp1, &len1, (char**)&cp2, &len2) ) @@ -511,8 +513,9 @@ audioop_findfit(PyObject *self, PyObject *args) best_result = result; best_j = 0; + j = 0; - for (j=1; j<=len1-len2; j++) { + for ( j=1; j<=len1-len2; j++) { aj_m1 = (double)cp1[j-1]; aj_lm1 = (double)cp1[j+len2-1]; @@ -531,7 +534,7 @@ audioop_findfit(PyObject *self, PyObject *args) factor = _sum2(cp1+best_j, cp2, len2) / sum_ri_2; - return Py_BuildValue("(if)", best_j, factor); + return Py_BuildValue("(nf)", best_j, factor); } /* @@ -542,7 +545,7 @@ static PyObject * audioop_findfactor(PyObject *self, PyObject *args) { short *cp1, *cp2; - int len1, len2; + Py_ssize_t len1, len2; double sum_ri_2, sum_aij_ri, result; if ( !PyArg_ParseTuple(args, "s#s#:findfactor", @@ -573,12 +576,12 @@ static PyObject * audioop_findmax(PyObject *self, PyObject *args) { short *cp1; - int len1, len2; - int j, best_j; + Py_ssize_t len1, len2; + Py_ssize_t j, best_j; double aj_m1, aj_lm1; double result, best_result; - if ( !PyArg_ParseTuple(args, "s#i:findmax", + if ( !PyArg_ParseTuple(args, "s#n:findmax", (char**)&cp1, &len1, &len2) ) return 0; if ( len1 & 1 ) { @@ -596,8 +599,9 @@ audioop_findmax(PyObject *self, PyObject *args) best_result = result; best_j = 0; + j = 0; - for (j=1; j<=len1-len2; j++) { + for ( j=1; j<=len1-len2; j++) { aj_m1 = (double)cp1[j-1]; aj_lm1 = (double)cp1[j+len2-1]; @@ -610,16 +614,16 @@ audioop_findmax(PyObject *self, PyObject *args) } - return PyInt_FromLong(best_j); + return PyLong_FromSsize_t(best_j); } static PyObject * audioop_avgpp(PyObject *self, PyObject *args) { signed char *cp; - int len, size, val = 0, prevval = 0, prevextremevalid = 0, + Py_ssize_t len, i; + int size, val = 0, prevval = 0, prevextremevalid = 0, prevextreme = 0; - int i; double avg = 0.0; int diff, prevdiff, extremediff, nextreme = 0; @@ -665,16 +669,16 @@ audioop_avgpp(PyObject *self, PyObject *args) val = 0; else val = (int)(avg / (double)nextreme); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } static PyObject * audioop_maxpp(PyObject *self, PyObject *args) { signed char *cp; - int len, size, val = 0, prevval = 0, prevextremevalid = 0, + Py_ssize_t len, i; + int size, val = 0, prevval = 0, prevextremevalid = 0, prevextreme = 0; - int i; int max = 0; int diff, prevdiff, extremediff; @@ -716,16 +720,17 @@ audioop_maxpp(PyObject *self, PyObject *args) if ( diff != 0 ) prevdiff = diff; } - return PyInt_FromLong(max); + return PyLong_FromLong(max); } static PyObject * audioop_cross(PyObject *self, PyObject *args) { signed char *cp; - int len, size, val = 0; - int i; - int prevval, ncross; + Py_ssize_t len, i; + int size, val = 0; + int prevval; + Py_ssize_t ncross; if ( !PyArg_ParseTuple(args, "s#i:cross", &cp, &len, &size) ) return 0; @@ -741,17 +746,17 @@ audioop_cross(PyObject *self, PyObject *args) if ( val != prevval ) ncross++; prevval = val; } - return PyInt_FromLong(ncross); + return PyLong_FromSsize_t(ncross); } static PyObject * audioop_mul(PyObject *self, PyObject *args) { signed char *cp, *ncp; - int len, size, val = 0; + Py_ssize_t len, i; + int size, val = 0; double factor, fval, maxval; PyObject *rv; - int i; if ( !PyArg_ParseTuple(args, "s#id:mul", &cp, &len, &size, &factor ) ) return 0; @@ -766,10 +771,10 @@ audioop_mul(PyObject *self, PyObject *args) return 0; } - rv = PyString_FromStringAndSize(NULL, len); + rv = PyBytes_FromStringAndSize(NULL, len); if ( rv == 0 ) return 0; - ncp = (signed char *)PyString_AsString(rv); + ncp = (signed char *)PyBytes_AsString(rv); for ( i=0; i < len; i += size ) { @@ -790,19 +795,25 @@ audioop_mul(PyObject *self, PyObject *args) static PyObject * audioop_tomono(PyObject *self, PyObject *args) { + Py_buffer pcp; signed char *cp, *ncp; - int len, size, val1 = 0, val2 = 0; + Py_ssize_t len, i; + int size, val1 = 0, val2 = 0; double fac1, fac2, fval, maxval; PyObject *rv; - int i; - if ( !PyArg_ParseTuple(args, "s#idd:tomono", - &cp, &len, &size, &fac1, &fac2 ) ) + if ( !PyArg_ParseTuple(args, "s*idd:tomono", + &pcp, &size, &fac1, &fac2 ) ) return 0; - if (!audioop_check_parameters(len, size)) + cp = pcp.buf; + len = pcp.len; + if (!audioop_check_parameters(len, size)) { + PyBuffer_Release(&pcp); return NULL; + } if (((len / size) & 1) != 0) { PyErr_SetString(AudioopError, "not a whole number of frames"); + PyBuffer_Release(&pcp); return NULL; } @@ -810,14 +821,17 @@ audioop_tomono(PyObject *self, PyObject *args) else if ( size == 2 ) maxval = (double) 0x7fff; else if ( size == 4 ) maxval = (double) 0x7fffffff; else { + PyBuffer_Release(&pcp); PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); return 0; } - rv = PyString_FromStringAndSize(NULL, len/2); - if ( rv == 0 ) + rv = PyBytes_FromStringAndSize(NULL, len/2); + if ( rv == 0 ) { + PyBuffer_Release(&pcp); return 0; - ncp = (signed char *)PyString_AsString(rv); + } + ncp = (signed char *)PyBytes_AsString(rv); for ( i=0; i < len; i += size*2 ) { @@ -835,6 +849,7 @@ audioop_tomono(PyObject *self, PyObject *args) else if ( size == 2 ) *SHORTP(ncp, i/2) = (short)val1; else if ( size == 4 ) *LONGP(ncp, i/2)= (Py_Int32)val1; } + PyBuffer_Release(&pcp); return rv; } @@ -842,10 +857,10 @@ static PyObject * audioop_tostereo(PyObject *self, PyObject *args) { signed char *cp, *ncp; - int len, size, val1, val2, val = 0; + Py_ssize_t len, i; + int size, val1, val2, val = 0; double fac1, fac2, fval, maxval; PyObject *rv; - int i; if ( !PyArg_ParseTuple(args, "s#idd:tostereo", &cp, &len, &size, &fac1, &fac2 ) ) @@ -861,16 +876,16 @@ audioop_tostereo(PyObject *self, PyObject *args) return 0; } - if (len > INT_MAX/2) { + if (len > PY_SSIZE_T_MAX/2) { PyErr_SetString(PyExc_MemoryError, "not enough memory for output buffer"); return 0; } - rv = PyString_FromStringAndSize(NULL, len*2); + rv = PyBytes_FromStringAndSize(NULL, len*2); if ( rv == 0 ) return 0; - ncp = (signed char *)PyString_AsString(rv); + ncp = (signed char *)PyBytes_AsString(rv); for ( i=0; i < len; i += size ) { @@ -903,9 +918,9 @@ static PyObject * audioop_add(PyObject *self, PyObject *args) { signed char *cp1, *cp2, *ncp; - int len1, len2, size, val1 = 0, val2 = 0, maxval, newval; + Py_ssize_t len1, len2, i; + int size, val1 = 0, val2 = 0, maxval, newval; PyObject *rv; - int i; if ( !PyArg_ParseTuple(args, "s#s#i:add", &cp1, &len1, &cp2, &len2, &size ) ) @@ -925,10 +940,10 @@ audioop_add(PyObject *self, PyObject *args) return 0; } - rv = PyString_FromStringAndSize(NULL, len1); + rv = PyBytes_FromStringAndSize(NULL, len1); if ( rv == 0 ) return 0; - ncp = (signed char *)PyString_AsString(rv); + ncp = (signed char *)PyBytes_AsString(rv); for ( i=0; i < len1; i += size ) { if ( size == 1 ) val1 = (int)*CHARP(cp1, i); @@ -957,9 +972,9 @@ static PyObject * audioop_bias(PyObject *self, PyObject *args) { signed char *cp, *ncp; - int len, size, val = 0; + Py_ssize_t len, i; + int size, val = 0; PyObject *rv; - int i; int bias; if ( !PyArg_ParseTuple(args, "s#ii:bias", @@ -969,10 +984,10 @@ audioop_bias(PyObject *self, PyObject *args) if (!audioop_check_parameters(len, size)) return NULL; - rv = PyString_FromStringAndSize(NULL, len); + rv = PyBytes_FromStringAndSize(NULL, len); if ( rv == 0 ) return 0; - ncp = (signed char *)PyString_AsString(rv); + ncp = (signed char *)PyBytes_AsString(rv); for ( i=0; i < len; i += size ) { @@ -992,9 +1007,9 @@ audioop_reverse(PyObject *self, PyObject *args) { signed char *cp; unsigned char *ncp; - int len, size, val = 0; + Py_ssize_t len, i, j; + int size, val = 0; PyObject *rv; - int i, j; if ( !PyArg_ParseTuple(args, "s#i:reverse", &cp, &len, &size) ) @@ -1003,10 +1018,10 @@ audioop_reverse(PyObject *self, PyObject *args) if (!audioop_check_parameters(len, size)) return NULL; - rv = PyString_FromStringAndSize(NULL, len); + rv = PyBytes_FromStringAndSize(NULL, len); if ( rv == 0 ) return 0; - ncp = (unsigned char *)PyString_AsString(rv); + ncp = (unsigned char *)PyBytes_AsString(rv); for ( i=0; i < len; i += size ) { if ( size == 1 ) val = ((int)*CHARP(cp, i)) << 8; @@ -1027,9 +1042,9 @@ audioop_lin2lin(PyObject *self, PyObject *args) { signed char *cp; unsigned char *ncp; - int len, size, size2, val = 0; + Py_ssize_t len, i, j; + int size, size2, val = 0; PyObject *rv; - int i, j; if ( !PyArg_ParseTuple(args, "s#ii:lin2lin", &cp, &len, &size, &size2) ) @@ -1040,15 +1055,15 @@ audioop_lin2lin(PyObject *self, PyObject *args) if (!audioop_check_size(size2)) return NULL; - if (len/size > INT_MAX/size2) { + if (len/size > PY_SSIZE_T_MAX/size2) { PyErr_SetString(PyExc_MemoryError, "not enough memory for output buffer"); return 0; } - rv = PyString_FromStringAndSize(NULL, (len/size)*size2); + rv = PyBytes_FromStringAndSize(NULL, (len/size)*size2); if ( rv == 0 ) return 0; - ncp = (unsigned char *)PyString_AsString(rv); + ncp = (unsigned char *)PyBytes_AsString(rv); for ( i=0, j=0; i < len; i += size, j += size2 ) { if ( size == 1 ) val = ((int)*CHARP(cp, i)) << 8; @@ -1077,7 +1092,8 @@ static PyObject * audioop_ratecv(PyObject *self, PyObject *args) { char *cp, *ncp; - int len, size, nchannels, inrate, outrate, weightA, weightB; + Py_ssize_t len; + int size, nchannels, inrate, outrate, weightA, weightB; int chan, d, *prev_i, *cur_i, cur_o; PyObject *state, *samps, *str, *rv = NULL; int bytes_per_frame; @@ -1168,12 +1184,12 @@ audioop_ratecv(PyObject *self, PyObject *args) case ceiling(len/inrate) * outrate. */ /* compute ceiling(len/inrate) without overflow */ - int q = len > 0 ? 1 + (len - 1) / inrate : 0; - if (outrate > INT_MAX / q / bytes_per_frame) + Py_ssize_t q = len > 0 ? 1 + (len - 1) / inrate : 0; + if (outrate > PY_SSIZE_T_MAX / q / bytes_per_frame) str = NULL; else - str = PyString_FromStringAndSize(NULL, - q * outrate * bytes_per_frame); + str = PyBytes_FromStringAndSize(NULL, + q * outrate * bytes_per_frame); if (str == NULL) { PyErr_SetString(PyExc_MemoryError, @@ -1181,7 +1197,7 @@ audioop_ratecv(PyObject *self, PyObject *args) goto exit; } } - ncp = PyString_AsString(str); + ncp = PyBytes_AsString(str); for (;;) { while (d < 0) { @@ -1198,13 +1214,12 @@ audioop_ratecv(PyObject *self, PyObject *args) goto exit; /* We have checked before that the length * of the string fits into int. */ - len = (int)(ncp - PyString_AsString(str)); - if (len == 0) { - /*don't want to resize to zero length*/ - rv = PyString_FromStringAndSize("", 0); - Py_DECREF(str); - str = rv; - } else if (_PyString_Resize(&str, len) < 0) + len = (Py_ssize_t)(ncp - PyBytes_AsString(str)); + rv = PyBytes_FromStringAndSize + (PyBytes_AsString(str), len); + Py_DECREF(str); + str = rv; + if (str == NULL) goto exit; rv = Py_BuildValue("(O(iO))", str, d, samps); Py_DECREF(samps); @@ -1258,9 +1273,9 @@ audioop_lin2ulaw(PyObject *self, PyObject *args) { signed char *cp; unsigned char *ncp; - int len, size, val = 0; + Py_ssize_t len, i; + int size, val = 0; PyObject *rv; - int i; if ( !PyArg_ParseTuple(args, "s#i:lin2ulaw", &cp, &len, &size) ) @@ -1269,10 +1284,10 @@ audioop_lin2ulaw(PyObject *self, PyObject *args) if (!audioop_check_parameters(len, size)) return NULL; - rv = PyString_FromStringAndSize(NULL, len/size); + rv = PyBytes_FromStringAndSize(NULL, len/size); if ( rv == 0 ) return 0; - ncp = (unsigned char *)PyString_AsString(rv); + ncp = (unsigned char *)PyBytes_AsString(rv); for ( i=0; i < len; i += size ) { if ( size == 1 ) val = ((int)*CHARP(cp, i)) << 8; @@ -1290,9 +1305,9 @@ audioop_ulaw2lin(PyObject *self, PyObject *args) unsigned char *cp; unsigned char cval; signed char *ncp; - int len, size, val; + Py_ssize_t len, i; + int size, val; PyObject *rv; - int i; if ( !PyArg_ParseTuple(args, "s#i:ulaw2lin", &cp, &len, &size) ) @@ -1301,15 +1316,15 @@ audioop_ulaw2lin(PyObject *self, PyObject *args) if (!audioop_check_size(size)) return NULL; - if (len > INT_MAX/size) { + if (len > PY_SSIZE_T_MAX/size) { PyErr_SetString(PyExc_MemoryError, "not enough memory for output buffer"); return 0; } - rv = PyString_FromStringAndSize(NULL, len*size); + rv = PyBytes_FromStringAndSize(NULL, len*size); if ( rv == 0 ) return 0; - ncp = (signed char *)PyString_AsString(rv); + ncp = (signed char *)PyBytes_AsString(rv); for ( i=0; i < len*size; i += size ) { cval = *cp++; @@ -1327,9 +1342,9 @@ audioop_lin2alaw(PyObject *self, PyObject *args) { signed char *cp; unsigned char *ncp; - int len, size, val = 0; + Py_ssize_t len, i; + int size, val = 0; PyObject *rv; - int i; if ( !PyArg_ParseTuple(args, "s#i:lin2alaw", &cp, &len, &size) ) @@ -1338,10 +1353,10 @@ audioop_lin2alaw(PyObject *self, PyObject *args) if (!audioop_check_parameters(len, size)) return NULL; - rv = PyString_FromStringAndSize(NULL, len/size); + rv = PyBytes_FromStringAndSize(NULL, len/size); if ( rv == 0 ) return 0; - ncp = (unsigned char *)PyString_AsString(rv); + ncp = (unsigned char *)PyBytes_AsString(rv); for ( i=0; i < len; i += size ) { if ( size == 1 ) val = ((int)*CHARP(cp, i)) << 8; @@ -1359,9 +1374,9 @@ audioop_alaw2lin(PyObject *self, PyObject *args) unsigned char *cp; unsigned char cval; signed char *ncp; - int len, size, val; + Py_ssize_t len, i; + int size, val; PyObject *rv; - int i; if ( !PyArg_ParseTuple(args, "s#i:alaw2lin", &cp, &len, &size) ) @@ -1370,15 +1385,15 @@ audioop_alaw2lin(PyObject *self, PyObject *args) if (!audioop_check_size(size)) return NULL; - if (len > INT_MAX/size) { + if (len > PY_SSIZE_T_MAX/size) { PyErr_SetString(PyExc_MemoryError, "not enough memory for output buffer"); return 0; } - rv = PyString_FromStringAndSize(NULL, len*size); + rv = PyBytes_FromStringAndSize(NULL, len*size); if ( rv == 0 ) return 0; - ncp = (signed char *)PyString_AsString(rv); + ncp = (signed char *)PyBytes_AsString(rv); for ( i=0; i < len*size; i += size ) { cval = *cp++; @@ -1396,10 +1411,11 @@ audioop_lin2adpcm(PyObject *self, PyObject *args) { signed char *cp; signed char *ncp; - int len, size, val = 0, step, valpred, delta, + Py_ssize_t len, i; + int size, val = 0, step, valpred, delta, index, sign, vpdiff, diff; PyObject *rv, *state, *str; - int i, outputbuffer = 0, bufferstep; + int outputbuffer = 0, bufferstep; if ( !PyArg_ParseTuple(args, "s#iO:lin2adpcm", &cp, &len, &size, &state) ) @@ -1408,15 +1424,16 @@ audioop_lin2adpcm(PyObject *self, PyObject *args) if (!audioop_check_parameters(len, size)) return NULL; - str = PyString_FromStringAndSize(NULL, len/(size*2)); + str = PyBytes_FromStringAndSize(NULL, len/(size*2)); if ( str == 0 ) return 0; - ncp = (signed char *)PyString_AsString(str); + ncp = (signed char *)PyBytes_AsString(str); /* Decode state, should have (value, step) */ if ( state == Py_None ) { /* First time, it seems. Set defaults */ valpred = 0; + step = 7; index = 0; } else if ( !PyArg_ParseTuple(state, "ii", &valpred, &index) ) return 0; @@ -1501,9 +1518,10 @@ audioop_adpcm2lin(PyObject *self, PyObject *args) { signed char *cp; signed char *ncp; - int len, size, valpred, step, delta, index, sign, vpdiff; + Py_ssize_t len, i; + int size, valpred, step, delta, index, sign, vpdiff; PyObject *rv, *str, *state; - int i, inputbuffer = 0, bufferstep; + int inputbuffer = 0, bufferstep; if ( !PyArg_ParseTuple(args, "s#iO:adpcm2lin", &cp, &len, &size, &state) ) @@ -1516,19 +1534,20 @@ audioop_adpcm2lin(PyObject *self, PyObject *args) if ( state == Py_None ) { /* First time, it seems. Set defaults */ valpred = 0; + step = 7; index = 0; } else if ( !PyArg_ParseTuple(state, "ii", &valpred, &index) ) return 0; - if (len > (INT_MAX/2)/size) { + if (len > (PY_SSIZE_T_MAX/2)/size) { PyErr_SetString(PyExc_MemoryError, "not enough memory for output buffer"); return 0; } - str = PyString_FromStringAndSize(NULL, len*size*2); + str = PyBytes_FromStringAndSize(NULL, len*size*2); if ( str == 0 ) return 0; - ncp = (signed char *)PyString_AsString(str); + ncp = (signed char *)PyBytes_AsString(str); step = stepsizeTable[index]; bufferstep = 0; @@ -1617,17 +1636,31 @@ static PyMethodDef audioop_methods[] = { { 0, 0 } }; + +static struct PyModuleDef audioopmodule = { + PyModuleDef_HEAD_INIT, + "audioop", + NULL, + -1, + audioop_methods, + NULL, + NULL, + NULL, + NULL +}; + PyMODINIT_FUNC -initaudioop(void) +PyInit_audioop(void) { PyObject *m, *d; - m = Py_InitModule("audioop", audioop_methods); + m = PyModule_Create(&audioopmodule); if (m == NULL) - return; + return NULL; d = PyModule_GetDict(m); if (d == NULL) - return; + return NULL; AudioopError = PyErr_NewException("audioop.error", NULL, NULL); if (AudioopError != NULL) PyDict_SetItemString(d,"error",AudioopError); + return m; } |