Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Mac/Modules/snd/_Sndihooks.c

    r2 r391  
    3636#pragma options align=mac68k
    3737struct SampleRateAvailable_arg {
    38         short   numrates;
    39         Handle  rates;
     38    short       numrates;
     39    Handle      rates;
    4040};
    4141
    4242struct SampleSizeAvailable_arg {
    43         short   numsizes;
    44         Handle  sizes;
     43    short       numsizes;
     44    Handle      sizes;
    4545};
    4646
     
    5454PyMac_GetUFixed(PyObject *v, Fixed *f)
    5555{
    56         double d;
    57         unsigned long uns;
    58        
    59         if( !PyArg_Parse(v, "d", &d))
    60                 return 0;
    61         uns = (unsigned long)(d * 0x10000);
    62         *f = (Fixed)uns;
    63         return 1;
     56    double d;
     57    unsigned long uns;
     58
     59    if( !PyArg_Parse(v, "d", &d))
     60        return 0;
     61    uns = (unsigned long)(d * 0x10000);
     62    *f = (Fixed)uns;
     63    return 1;
    6464}
    6565
     
    6868PyMac_BuildUFixed(Fixed f)
    6969{
    70         double d;
    71         unsigned long funs;
    72        
    73         funs = (unsigned long)f;
    74        
    75         d = funs;
    76         d = d / 0x10000;
    77         return Py_BuildValue("d", d);
     70    double d;
     71    unsigned long funs;
     72
     73    funs = (unsigned long)f;
     74
     75    d = funs;
     76    d = d / 0x10000;
     77    return Py_BuildValue("d", d);
    7878}
    7979
     
    8787static PyObject *
    8888sndih_getChannelAvailable(self, args)
    89         PyObject *self; /* Not used */
    90         PyObject *args;
    91 {
    92         long inRefNum;
    93         short nchannel;
    94         OSErr err;
    95 
    96         if (!PyArg_ParseTuple(args, "l", &inRefNum))
    97                 return NULL;
    98        
    99         if( (err=SPBGetDeviceInfo(inRefNum, siChannelAvailable, (Ptr)&nchannel)) != noErr )
    100                 return PyMac_Error(err);
    101         return Py_BuildValue("h", nchannel);
     89    PyObject *self;     /* Not used */
     90    PyObject *args;
     91{
     92    long inRefNum;
     93    short nchannel;
     94    OSErr err;
     95
     96    if (!PyArg_ParseTuple(args, "l", &inRefNum))
     97        return NULL;
     98
     99    if( (err=SPBGetDeviceInfo(inRefNum, siChannelAvailable, (Ptr)&nchannel)) != noErr )
     100        return PyMac_Error(err);
     101    return Py_BuildValue("h", nchannel);
    102102}
    103103
     
    108108static PyObject *
    109109sndih_getNumberChannels(self, args)
    110         PyObject *self; /* Not used */
    111         PyObject *args;
    112 {
    113         long inRefNum;
    114         short nchannel;
    115         OSErr err;
    116 
    117         if (!PyArg_ParseTuple(args, "l", &inRefNum))
    118                 return NULL;
    119        
    120         if( (err=SPBGetDeviceInfo(inRefNum, siNumberChannels, (Ptr)&nchannel)) != noErr )
    121                 return PyMac_Error(err);
    122         return Py_BuildValue("h", nchannel);
     110    PyObject *self;     /* Not used */
     111    PyObject *args;
     112{
     113    long inRefNum;
     114    short nchannel;
     115    OSErr err;
     116
     117    if (!PyArg_ParseTuple(args, "l", &inRefNum))
     118        return NULL;
     119
     120    if( (err=SPBGetDeviceInfo(inRefNum, siNumberChannels, (Ptr)&nchannel)) != noErr )
     121        return PyMac_Error(err);
     122    return Py_BuildValue("h", nchannel);
    123123}
    124124
     
    129129static PyObject *
    130130sndih_setNumberChannels(self, args)
    131         PyObject *self; /* Not used */
    132         PyObject *args;
    133 {
    134         long inRefNum;
    135         short nchannel;
    136         OSErr err;
    137 
    138         if (!PyArg_ParseTuple(args, "lh", &inRefNum, &nchannel))
    139                 return NULL;
    140        
    141         if( (err=SPBSetDeviceInfo(inRefNum, siNumberChannels, (Ptr)&nchannel)) != noErr )
    142                 return PyMac_Error(err);
    143         Py_INCREF(Py_None);
    144         return Py_None;
     131    PyObject *self;     /* Not used */
     132    PyObject *args;
     133{
     134    long inRefNum;
     135    short nchannel;
     136    OSErr err;
     137
     138    if (!PyArg_ParseTuple(args, "lh", &inRefNum, &nchannel))
     139        return NULL;
     140
     141    if( (err=SPBSetDeviceInfo(inRefNum, siNumberChannels, (Ptr)&nchannel)) != noErr )
     142        return PyMac_Error(err);
     143    Py_INCREF(Py_None);
     144    return Py_None;
    145145}
    146146
     
    151151static PyObject *
    152152sndih_getContinuous(self, args)
    153         PyObject *self; /* Not used */
    154         PyObject *args;
    155 {
    156         long inRefNum;
    157         short onoff;
    158         OSErr err;
    159 
    160         if (!PyArg_ParseTuple(args, "l", &inRefNum))
    161                 return NULL;
    162        
    163         if( (err=SPBGetDeviceInfo(inRefNum, siContinuous, (Ptr)&onoff)) != noErr )
    164                 return PyMac_Error(err);
    165         return Py_BuildValue("h", onoff);
     153    PyObject *self;     /* Not used */
     154    PyObject *args;
     155{
     156    long inRefNum;
     157    short onoff;
     158    OSErr err;
     159
     160    if (!PyArg_ParseTuple(args, "l", &inRefNum))
     161        return NULL;
     162
     163    if( (err=SPBGetDeviceInfo(inRefNum, siContinuous, (Ptr)&onoff)) != noErr )
     164        return PyMac_Error(err);
     165    return Py_BuildValue("h", onoff);
    166166}
    167167
     
    172172static PyObject *
    173173sndih_setContinuous(self, args)
    174         PyObject *self; /* Not used */
    175         PyObject *args;
    176 {
    177         long inRefNum;
    178         short onoff;
    179         OSErr err;
    180 
    181         if (!PyArg_ParseTuple(args, "lh", &inRefNum, &onoff))
    182                 return NULL;
    183        
    184         if( (err=SPBSetDeviceInfo(inRefNum, siContinuous, (Ptr)&onoff)) != noErr )
    185                 return PyMac_Error(err);
    186         Py_INCREF(Py_None);
    187         return Py_None;
     174    PyObject *self;     /* Not used */
     175    PyObject *args;
     176{
     177    long inRefNum;
     178    short onoff;
     179    OSErr err;
     180
     181    if (!PyArg_ParseTuple(args, "lh", &inRefNum, &onoff))
     182        return NULL;
     183
     184    if( (err=SPBSetDeviceInfo(inRefNum, siContinuous, (Ptr)&onoff)) != noErr )
     185        return PyMac_Error(err);
     186    Py_INCREF(Py_None);
     187    return Py_None;
    188188}
    189189
     
    194194static PyObject *
    195195sndih_getInputSourceNames(self, args)
    196         PyObject *self; /* Not used */
    197         PyObject *args;
    198 {
    199         long inRefNum;
    200         Handle names;
    201         OSErr err;
    202 
    203         if (!PyArg_ParseTuple(args, "l", &inRefNum))
    204                 return NULL;
    205        
    206         if( (err=SPBGetDeviceInfo(inRefNum, siInputSourceNames, (Ptr)&names)) != noErr )
    207                 return PyMac_Error(err);
    208         return Py_BuildValue("O&", ResObj_New, names);
     196    PyObject *self;     /* Not used */
     197    PyObject *args;
     198{
     199    long inRefNum;
     200    Handle names;
     201    OSErr err;
     202
     203    if (!PyArg_ParseTuple(args, "l", &inRefNum))
     204        return NULL;
     205
     206    if( (err=SPBGetDeviceInfo(inRefNum, siInputSourceNames, (Ptr)&names)) != noErr )
     207        return PyMac_Error(err);
     208    return Py_BuildValue("O&", ResObj_New, names);
    209209}
    210210
     
    215215static PyObject *
    216216sndih_getInputSource(self, args)
    217         PyObject *self; /* Not used */
    218         PyObject *args;
    219 {
    220         long inRefNum;
    221         short source;
    222         OSErr err;
    223 
    224         if (!PyArg_ParseTuple(args, "l", &inRefNum))
    225                 return NULL;
    226        
    227         if( (err=SPBGetDeviceInfo(inRefNum, siInputSource, (Ptr)&source)) != noErr )
    228                 return PyMac_Error(err);
    229         return Py_BuildValue("h", source);
     217    PyObject *self;     /* Not used */
     218    PyObject *args;
     219{
     220    long inRefNum;
     221    short source;
     222    OSErr err;
     223
     224    if (!PyArg_ParseTuple(args, "l", &inRefNum))
     225        return NULL;
     226
     227    if( (err=SPBGetDeviceInfo(inRefNum, siInputSource, (Ptr)&source)) != noErr )
     228        return PyMac_Error(err);
     229    return Py_BuildValue("h", source);
    230230}
    231231
     
    236236static PyObject *
    237237sndih_setInputSource(self, args)
    238         PyObject *self; /* Not used */
    239         PyObject *args;
    240 {
    241         long inRefNum;
    242         short source;
    243         OSErr err;
    244 
    245         if (!PyArg_ParseTuple(args, "lh", &inRefNum, &source))
    246                 return NULL;
    247        
    248         if( (err=SPBSetDeviceInfo(inRefNum, siInputSource, (Ptr)&source)) != noErr )
    249                 return PyMac_Error(err);
    250         Py_INCREF(Py_None);
    251         return Py_None;
     238    PyObject *self;     /* Not used */
     239    PyObject *args;
     240{
     241    long inRefNum;
     242    short source;
     243    OSErr err;
     244
     245    if (!PyArg_ParseTuple(args, "lh", &inRefNum, &source))
     246        return NULL;
     247
     248    if( (err=SPBSetDeviceInfo(inRefNum, siInputSource, (Ptr)&source)) != noErr )
     249        return PyMac_Error(err);
     250    Py_INCREF(Py_None);
     251    return Py_None;
    252252}
    253253
     
    258258static PyObject *
    259259sndih_getPlayThruOnOff(self, args)
    260         PyObject *self; /* Not used */
    261         PyObject *args;
    262 {
    263         long inRefNum;
    264         short onoff;
    265         OSErr err;
    266 
    267         if (!PyArg_ParseTuple(args, "l", &inRefNum))
    268                 return NULL;
    269        
    270         if( (err=SPBGetDeviceInfo(inRefNum, siPlayThruOnOff, (Ptr)&onoff)) != noErr )
    271                 return PyMac_Error(err);
    272         return Py_BuildValue("h", onoff);
     260    PyObject *self;     /* Not used */
     261    PyObject *args;
     262{
     263    long inRefNum;
     264    short onoff;
     265    OSErr err;
     266
     267    if (!PyArg_ParseTuple(args, "l", &inRefNum))
     268        return NULL;
     269
     270    if( (err=SPBGetDeviceInfo(inRefNum, siPlayThruOnOff, (Ptr)&onoff)) != noErr )
     271        return PyMac_Error(err);
     272    return Py_BuildValue("h", onoff);
    273273}
    274274
     
    279279static PyObject *
    280280sndih_setPlayThruOnOff(self, args)
    281         PyObject *self; /* Not used */
    282         PyObject *args;
    283 {
    284         long inRefNum;
    285         short onoff;
    286         OSErr err;
    287 
    288         if (!PyArg_ParseTuple(args, "lh", &inRefNum, &onoff))
    289                 return NULL;
    290        
    291         if( (err=SPBSetDeviceInfo(inRefNum, siPlayThruOnOff, (Ptr)&onoff)) != noErr )
    292                 return PyMac_Error(err);
    293         Py_INCREF(Py_None);
    294         return Py_None;
     281    PyObject *self;     /* Not used */
     282    PyObject *args;
     283{
     284    long inRefNum;
     285    short onoff;
     286    OSErr err;
     287
     288    if (!PyArg_ParseTuple(args, "lh", &inRefNum, &onoff))
     289        return NULL;
     290
     291    if( (err=SPBSetDeviceInfo(inRefNum, siPlayThruOnOff, (Ptr)&onoff)) != noErr )
     292        return PyMac_Error(err);
     293    Py_INCREF(Py_None);
     294    return Py_None;
    295295}
    296296
     
    301301static PyObject *
    302302sndih_getSampleRate(self, args)
    303         PyObject *self; /* Not used */
    304         PyObject *args;
    305 {
    306         long inRefNum;
    307         Fixed sample_rate;
    308         OSErr err;
    309 
    310         if (!PyArg_ParseTuple(args, "l", &inRefNum))
    311                 return NULL;
    312        
    313         if( (err=SPBGetDeviceInfo(inRefNum, siSampleRate, (Ptr)&sample_rate)) != noErr )
    314                 return PyMac_Error(err);
    315         return Py_BuildValue("O&", PyMac_BuildUFixed, sample_rate);
     303    PyObject *self;     /* Not used */
     304    PyObject *args;
     305{
     306    long inRefNum;
     307    Fixed sample_rate;
     308    OSErr err;
     309
     310    if (!PyArg_ParseTuple(args, "l", &inRefNum))
     311        return NULL;
     312
     313    if( (err=SPBGetDeviceInfo(inRefNum, siSampleRate, (Ptr)&sample_rate)) != noErr )
     314        return PyMac_Error(err);
     315    return Py_BuildValue("O&", PyMac_BuildUFixed, sample_rate);
    316316}
    317317
     
    322322static PyObject *
    323323sndih_setSampleRate(self, args)
    324         PyObject *self; /* Not used */
    325         PyObject *args;
    326 {
    327         long inRefNum;
    328         Fixed sample_rate;
    329         OSErr err;
    330 
    331         if (!PyArg_ParseTuple(args, "lO&", &inRefNum, PyMac_GetUFixed, &sample_rate))
    332                 return NULL;
    333        
    334         if( (err=SPBSetDeviceInfo(inRefNum, siSampleRate, (Ptr)&sample_rate)) != noErr )
    335                 return PyMac_Error(err);
    336         Py_INCREF(Py_None);
    337         return Py_None;
     324    PyObject *self;     /* Not used */
     325    PyObject *args;
     326{
     327    long inRefNum;
     328    Fixed sample_rate;
     329    OSErr err;
     330
     331    if (!PyArg_ParseTuple(args, "lO&", &inRefNum, PyMac_GetUFixed, &sample_rate))
     332        return NULL;
     333
     334    if( (err=SPBSetDeviceInfo(inRefNum, siSampleRate, (Ptr)&sample_rate)) != noErr )
     335        return PyMac_Error(err);
     336    Py_INCREF(Py_None);
     337    return Py_None;
    338338}
    339339
     
    344344static PyObject *
    345345sndih_getSampleSize(self, args)
    346         PyObject *self; /* Not used */
    347         PyObject *args;
    348 {
    349         long inRefNum;
    350         short bits;
    351         OSErr err;
    352 
    353         if (!PyArg_ParseTuple(args, "l", &inRefNum))
    354                 return NULL;
    355        
    356         if( (err=SPBGetDeviceInfo(inRefNum, siSampleSize, (Ptr)&bits)) != noErr )
    357                 return PyMac_Error(err);
    358         return Py_BuildValue("h", bits);
     346    PyObject *self;     /* Not used */
     347    PyObject *args;
     348{
     349    long inRefNum;
     350    short bits;
     351    OSErr err;
     352
     353    if (!PyArg_ParseTuple(args, "l", &inRefNum))
     354        return NULL;
     355
     356    if( (err=SPBGetDeviceInfo(inRefNum, siSampleSize, (Ptr)&bits)) != noErr )
     357        return PyMac_Error(err);
     358    return Py_BuildValue("h", bits);
    359359}
    360360
     
    365365static PyObject *
    366366sndih_setSampleSize(self, args)
    367         PyObject *self; /* Not used */
    368         PyObject *args;
    369 {
    370         long inRefNum;
    371         short size;
    372         OSErr err;
    373 
    374         if (!PyArg_ParseTuple(args, "lh", &inRefNum, &size))
    375                 return NULL;
    376        
    377         if( (err=SPBSetDeviceInfo(inRefNum, siSampleSize, (Ptr)&size)) != noErr )
    378                 return PyMac_Error(err);
    379         Py_INCREF(Py_None);
    380         return Py_None;
     367    PyObject *self;     /* Not used */
     368    PyObject *args;
     369{
     370    long inRefNum;
     371    short size;
     372    OSErr err;
     373
     374    if (!PyArg_ParseTuple(args, "lh", &inRefNum, &size))
     375        return NULL;
     376
     377    if( (err=SPBSetDeviceInfo(inRefNum, siSampleSize, (Ptr)&size)) != noErr )
     378        return PyMac_Error(err);
     379    Py_INCREF(Py_None);
     380    return Py_None;
    381381}
    382382
     
    387387static PyObject *
    388388sndih_getSampleSizeAvailable(self, args)
    389         PyObject *self; /* Not used */
    390         PyObject *args;
    391 {
    392         long inRefNum;
    393         struct SampleSizeAvailable_arg arg;
    394         OSErr err;
    395         PyObject *rsizes;
    396         short *fsizes;
    397         int i;
    398 
    399         arg.sizes = NULL;
    400         rsizes = NULL;
    401         if (!PyArg_ParseTuple(args, "l", &inRefNum))
    402                 return NULL;
    403        
    404         if( (err=SPBGetDeviceInfo(inRefNum, siSampleSizeAvailable, (Ptr)&arg)) != noErr ) {
    405                 return PyMac_Error(err);
    406         }
    407         fsizes = (short *)*(arg.sizes);
    408         /* Handle contains a list of rates */
    409         if( (rsizes = PyTuple_New(arg.numsizes)) == NULL)
    410                 return NULL;
    411         for( i=0; i<arg.numsizes; i++ )
    412                 PyTuple_SetItem(rsizes, i, PyInt_FromLong((long)fsizes[i]));
    413         return rsizes;
     389    PyObject *self;     /* Not used */
     390    PyObject *args;
     391{
     392    long inRefNum;
     393    struct SampleSizeAvailable_arg arg;
     394    OSErr err;
     395    PyObject *rsizes;
     396    short *fsizes;
     397    int i;
     398
     399    arg.sizes = NULL;
     400    rsizes = NULL;
     401    if (!PyArg_ParseTuple(args, "l", &inRefNum))
     402        return NULL;
     403
     404    if( (err=SPBGetDeviceInfo(inRefNum, siSampleSizeAvailable, (Ptr)&arg)) != noErr ) {
     405        return PyMac_Error(err);
     406    }
     407    fsizes = (short *)*(arg.sizes);
     408    /* Handle contains a list of rates */
     409    if( (rsizes = PyTuple_New(arg.numsizes)) == NULL)
     410        return NULL;
     411    for( i=0; i<arg.numsizes; i++ )
     412        PyTuple_SetItem(rsizes, i, PyInt_FromLong((long)fsizes[i]));
     413    return rsizes;
    414414}
    415415
     
    420420static PyObject *
    421421sndih_getSampleRateAvailable(self, args)
    422         PyObject *self; /* Not used */
    423         PyObject *args;
    424 {
    425         long inRefNum;
    426         struct SampleRateAvailable_arg arg;
    427         OSErr err;
    428         PyObject *rrates, *obj;
    429         Fixed *frates;
    430         int i;
    431 
    432         arg.rates = NULL;
    433         rrates = NULL;
    434         if (!PyArg_ParseTuple(args, "l", &inRefNum))
    435                 return NULL;
    436        
    437         if( (err=SPBGetDeviceInfo(inRefNum, siSampleRateAvailable, (Ptr)&arg)) != noErr ) {
    438                 return PyMac_Error(err);
    439         }
    440         frates = (Fixed *)*(arg.rates);
    441         if( arg.numrates == 0 ) {
    442                 /* The handle contains upper and lowerbound */
    443                 rrates = Py_BuildValue("O&O&", frates[0], frates[1]);
    444                 if (rrates == NULL) return NULL;
    445         } else {
    446                 /* Handle contains a list of rates */
    447                 if( (rrates = PyTuple_New(arg.numrates)) == NULL)
    448                         return NULL;
    449                 for( i=0; i<arg.numrates; i++ ) {
    450                         if( (obj = Py_BuildValue("O&", PyMac_BuildUFixed, frates[i]))==NULL)
    451                                 goto out;
    452                         PyTuple_SetItem(rrates, i, obj);
    453                 }
    454         }
    455         return Py_BuildValue("hO", arg.numrates, rrates);
     422    PyObject *self;     /* Not used */
     423    PyObject *args;
     424{
     425    long inRefNum;
     426    struct SampleRateAvailable_arg arg;
     427    OSErr err;
     428    PyObject *rrates, *obj;
     429    Fixed *frates;
     430    int i;
     431
     432    arg.rates = NULL;
     433    rrates = NULL;
     434    if (!PyArg_ParseTuple(args, "l", &inRefNum))
     435        return NULL;
     436
     437    if( (err=SPBGetDeviceInfo(inRefNum, siSampleRateAvailable, (Ptr)&arg)) != noErr ) {
     438        return PyMac_Error(err);
     439    }
     440    frates = (Fixed *)*(arg.rates);
     441    if( arg.numrates == 0 ) {
     442        /* The handle contains upper and lowerbound */
     443        rrates = Py_BuildValue("O&O&", frates[0], frates[1]);
     444        if (rrates == NULL) return NULL;
     445    } else {
     446        /* Handle contains a list of rates */
     447        if( (rrates = PyTuple_New(arg.numrates)) == NULL)
     448            return NULL;
     449        for( i=0; i<arg.numrates; i++ ) {
     450            if( (obj = Py_BuildValue("O&", PyMac_BuildUFixed, frates[i]))==NULL)
     451                goto out;
     452            PyTuple_SetItem(rrates, i, obj);
     453        }
     454    }
     455    return Py_BuildValue("hO", arg.numrates, rrates);
    456456out:
    457         Py_XDECREF(rrates);
    458         return NULL;
     457    Py_XDECREF(rrates);
     458    return NULL;
    459459}
    460460
     
    462462
    463463static struct PyMethodDef sndih_methods[] = {
    464  {"getChannelAvailable",        (PyCFunction)sndih_getChannelAvailable, METH_VARARGS,   sndih_getChannelAvailable__doc__},
    465  {"getNumberChannels",  (PyCFunction)sndih_getNumberChannels,   METH_VARARGS,   sndih_getNumberChannels__doc__},
    466  {"setNumberChannels",  (PyCFunction)sndih_setNumberChannels,   METH_VARARGS,   sndih_setNumberChannels__doc__},
    467  {"getContinuous",      (PyCFunction)sndih_getContinuous,       METH_VARARGS,   sndih_getContinuous__doc__},
    468  {"setContinuous",      (PyCFunction)sndih_setContinuous,       METH_VARARGS,   sndih_setContinuous__doc__},
    469  {"getInputSourceNames",        (PyCFunction)sndih_getInputSourceNames, METH_VARARGS,   sndih_getInputSourceNames__doc__},
    470  {"getInputSource",     (PyCFunction)sndih_getInputSource,      METH_VARARGS,   sndih_getInputSource__doc__},
    471  {"setInputSource",     (PyCFunction)sndih_setInputSource,      METH_VARARGS,   sndih_setInputSource__doc__},
    472  {"getPlayThruOnOff",   (PyCFunction)sndih_getPlayThruOnOff,    METH_VARARGS,   sndih_getPlayThruOnOff__doc__},
    473  {"setPlayThruOnOff",   (PyCFunction)sndih_setPlayThruOnOff,    METH_VARARGS,   sndih_setPlayThruOnOff__doc__},
    474  {"getSampleRate",      (PyCFunction)sndih_getSampleRate,       METH_VARARGS,   sndih_getSampleRate__doc__},
    475  {"setSampleRate",      (PyCFunction)sndih_setSampleRate,       METH_VARARGS,   sndih_setSampleRate__doc__},
    476  {"getSampleSize",      (PyCFunction)sndih_getSampleSize,       METH_VARARGS,   sndih_getSampleSize__doc__},
    477  {"setSampleSize",      (PyCFunction)sndih_setSampleSize,       METH_VARARGS,   sndih_setSampleSize__doc__},
    478  {"getSampleSizeAvailable",     (PyCFunction)sndih_getSampleSizeAvailable,      METH_VARARGS,   sndih_getSampleSizeAvailable__doc__},
    479  {"getSampleRateAvailable",     (PyCFunction)sndih_getSampleRateAvailable,      METH_VARARGS,   sndih_getSampleRateAvailable__doc__},
    480  
    481         {NULL,   (PyCFunction)NULL, 0, NULL}            /* sentinel */
     464 {"getChannelAvailable",        (PyCFunction)sndih_getChannelAvailable, METH_VARARGS,   sndih_getChannelAvailable__doc__},
     465 {"getNumberChannels",  (PyCFunction)sndih_getNumberChannels,   METH_VARARGS,   sndih_getNumberChannels__doc__},
     466 {"setNumberChannels",  (PyCFunction)sndih_setNumberChannels,   METH_VARARGS,   sndih_setNumberChannels__doc__},
     467 {"getContinuous",      (PyCFunction)sndih_getContinuous,       METH_VARARGS,   sndih_getContinuous__doc__},
     468 {"setContinuous",      (PyCFunction)sndih_setContinuous,       METH_VARARGS,   sndih_setContinuous__doc__},
     469 {"getInputSourceNames",        (PyCFunction)sndih_getInputSourceNames, METH_VARARGS,   sndih_getInputSourceNames__doc__},
     470 {"getInputSource",     (PyCFunction)sndih_getInputSource,      METH_VARARGS,   sndih_getInputSource__doc__},
     471 {"setInputSource",     (PyCFunction)sndih_setInputSource,      METH_VARARGS,   sndih_setInputSource__doc__},
     472 {"getPlayThruOnOff",   (PyCFunction)sndih_getPlayThruOnOff,    METH_VARARGS,   sndih_getPlayThruOnOff__doc__},
     473 {"setPlayThruOnOff",   (PyCFunction)sndih_setPlayThruOnOff,    METH_VARARGS,   sndih_setPlayThruOnOff__doc__},
     474 {"getSampleRate",      (PyCFunction)sndih_getSampleRate,       METH_VARARGS,   sndih_getSampleRate__doc__},
     475 {"setSampleRate",      (PyCFunction)sndih_setSampleRate,       METH_VARARGS,   sndih_setSampleRate__doc__},
     476 {"getSampleSize",      (PyCFunction)sndih_getSampleSize,       METH_VARARGS,   sndih_getSampleSize__doc__},
     477 {"setSampleSize",      (PyCFunction)sndih_setSampleSize,       METH_VARARGS,   sndih_setSampleSize__doc__},
     478 {"getSampleSizeAvailable",     (PyCFunction)sndih_getSampleSizeAvailable,      METH_VARARGS,   sndih_getSampleSizeAvailable__doc__},
     479 {"getSampleRateAvailable",     (PyCFunction)sndih_getSampleRateAvailable,      METH_VARARGS,   sndih_getSampleRateAvailable__doc__},
     480
     481    {NULL,       (PyCFunction)NULL, 0, NULL}            /* sentinel */
    482482};
    483483
     
    485485/* Initialization function for the module (*must* be called initSndihooks) */
    486486
    487 static char Sndihooks_module_documentation[] = 
     487static char Sndihooks_module_documentation[] =
    488488""
    489489;
     
    492492init_Sndihooks()
    493493{
    494         PyObject *m, *d;
    495 
    496         /* Create the module and add the functions */
    497         m = Py_InitModule4("_Sndihooks", sndih_methods,
    498                 Sndihooks_module_documentation,
    499                 (PyObject*)NULL,PYTHON_API_VERSION);
    500 
    501         /* Add some symbolic constants to the module */
    502         d = PyModule_GetDict(m);
    503         ErrorObject = PyString_FromString("Sndihooks.error");
    504         PyDict_SetItemString(d, "error", ErrorObject);
    505 
    506         /* XXXX Add constants here */
    507        
    508         /* Check for errors */
    509         if (PyErr_Occurred())
    510                 Py_FatalError("can't initialize module Sndihooks");
    511 }
    512 
     494    PyObject *m, *d;
     495
     496    /* Create the module and add the functions */
     497    m = Py_InitModule4("_Sndihooks", sndih_methods,
     498        Sndihooks_module_documentation,
     499        (PyObject*)NULL,PYTHON_API_VERSION);
     500
     501    /* Add some symbolic constants to the module */
     502    d = PyModule_GetDict(m);
     503    ErrorObject = PyString_FromString("Sndihooks.error");
     504    PyDict_SetItemString(d, "error", ErrorObject);
     505
     506    /* XXXX Add constants here */
     507
     508    /* Check for errors */
     509    if (PyErr_Occurred())
     510        Py_FatalError("can't initialize module Sndihooks");
     511}
     512
  • python/trunk/Mac/Modules/snd/_Sndmodule.c

    r2 r391  
    1111/* Macro to test whether a weak-loaded CFM function exists */
    1212#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL )  {\
    13         PyErr_SetString(PyExc_NotImplementedError, \
    14         "Not available in this shared library/OS version"); \
    15         return NULL; \
     13    PyErr_SetString(PyExc_NotImplementedError, \
     14    "Not available in this shared library/OS version"); \
     15    return NULL; \
    1616    }} while(0)
    1717
     
    2323SndCmd_Convert(PyObject *v, SndCommand *pc)
    2424{
    25         int len;
    26         pc->param1 = 0;
    27         pc->param2 = 0;
    28         if (PyTuple_Check(v)) {
    29                 if (PyArg_ParseTuple(v, "h|hl", &pc->cmd, &pc->param1, &pc->param2))
    30                         return 1;
    31                 PyErr_Clear();
    32                 return PyArg_ParseTuple(v, "Hhs#", &pc->cmd, &pc->param1, &pc->param2, &len);
    33         }
    34         return PyArg_Parse(v, "H", &pc->cmd);
     25    int len;
     26    pc->param1 = 0;
     27    pc->param2 = 0;
     28    if (PyTuple_Check(v)) {
     29        if (PyArg_ParseTuple(v, "h|hl", &pc->cmd, &pc->param1, &pc->param2))
     30            return 1;
     31        PyErr_Clear();
     32        return PyArg_ParseTuple(v, "Hhs#", &pc->cmd, &pc->param1, &pc->param2, &len);
     33    }
     34    return PyArg_Parse(v, "H", &pc->cmd);
    3535}
    3636
     
    4747
    4848typedef struct SndChannelObject {
    49         PyObject_HEAD
    50         SndChannelPtr ob_itself;
    51         /* Members used to implement callbacks: */
    52         PyObject *ob_callback;
    53         long ob_A5;
    54         SndCommand ob_cmd;
     49    PyObject_HEAD
     50    SndChannelPtr ob_itself;
     51    /* Members used to implement callbacks: */
     52    PyObject *ob_callback;
     53    long ob_A5;
     54    SndCommand ob_cmd;
    5555} SndChannelObject;
    5656
    5757static PyObject *SndCh_New(SndChannelPtr itself)
    5858{
    59         SndChannelObject *it;
    60         it = PyObject_NEW(SndChannelObject, &SndChannel_Type);
    61         if (it == NULL) return NULL;
    62         it->ob_itself = itself;
    63         it->ob_callback = NULL;
    64         it->ob_A5 = SetCurrentA5();
    65         return (PyObject *)it;
     59    SndChannelObject *it;
     60    it = PyObject_NEW(SndChannelObject, &SndChannel_Type);
     61    if (it == NULL) return NULL;
     62    it->ob_itself = itself;
     63    it->ob_callback = NULL;
     64    it->ob_A5 = SetCurrentA5();
     65    return (PyObject *)it;
    6666}
    6767
    6868static void SndCh_dealloc(SndChannelObject *self)
    6969{
    70         SndDisposeChannel(self->ob_itself, 1);
    71         Py_XDECREF(self->ob_callback);
    72         PyObject_Free((PyObject *)self);
     70    SndDisposeChannel(self->ob_itself, 1);
     71    Py_XDECREF(self->ob_callback);
     72    PyObject_Free((PyObject *)self);
    7373}
    7474
    7575static PyObject *SndCh_SndDoCommand(SndChannelObject *_self, PyObject *_args)
    7676{
    77         PyObject *_res = NULL;
    78         OSErr _err;
    79         SndCommand cmd;
    80         Boolean noWait;
    81         if (!PyArg_ParseTuple(_args, "O&b",
    82                               SndCmd_Convert, &cmd,
    83                               &noWait))
    84                 return NULL;
    85         _err = SndDoCommand(_self->ob_itself,
    86                             &cmd,
    87                             noWait);
    88         if (_err != noErr) return PyMac_Error(_err);
    89         Py_INCREF(Py_None);
    90         _res = Py_None;
    91         return _res;
     77    PyObject *_res = NULL;
     78    OSErr _err;
     79    SndCommand cmd;
     80    Boolean noWait;
     81    if (!PyArg_ParseTuple(_args, "O&b",
     82                          SndCmd_Convert, &cmd,
     83                          &noWait))
     84        return NULL;
     85    _err = SndDoCommand(_self->ob_itself,
     86                        &cmd,
     87                        noWait);
     88    if (_err != noErr) return PyMac_Error(_err);
     89    Py_INCREF(Py_None);
     90    _res = Py_None;
     91    return _res;
    9292}
    9393
    9494static PyObject *SndCh_SndDoImmediate(SndChannelObject *_self, PyObject *_args)
    9595{
    96         PyObject *_res = NULL;
    97         OSErr _err;
    98         SndCommand cmd;
    99         if (!PyArg_ParseTuple(_args, "O&",
    100                               SndCmd_Convert, &cmd))
    101                 return NULL;
    102         _err = SndDoImmediate(_self->ob_itself,
    103                               &cmd);
    104         if (_err != noErr) return PyMac_Error(_err);
    105         Py_INCREF(Py_None);
    106         _res = Py_None;
    107         return _res;
     96    PyObject *_res = NULL;
     97    OSErr _err;
     98    SndCommand cmd;
     99    if (!PyArg_ParseTuple(_args, "O&",
     100                          SndCmd_Convert, &cmd))
     101        return NULL;
     102    _err = SndDoImmediate(_self->ob_itself,
     103                          &cmd);
     104    if (_err != noErr) return PyMac_Error(_err);
     105    Py_INCREF(Py_None);
     106    _res = Py_None;
     107    return _res;
    108108}
    109109
    110110static PyObject *SndCh_SndPlay(SndChannelObject *_self, PyObject *_args)
    111111{
    112         PyObject *_res = NULL;
    113         OSErr _err;
    114         SndListHandle sndHandle;
    115         Boolean async;
    116         if (!PyArg_ParseTuple(_args, "O&b",
    117                               ResObj_Convert, &sndHandle,
    118                               &async))
    119                 return NULL;
    120         _err = SndPlay(_self->ob_itself,
    121                        sndHandle,
    122                        async);
    123         if (_err != noErr) return PyMac_Error(_err);
    124         Py_INCREF(Py_None);
    125         _res = Py_None;
    126         return _res;
     112    PyObject *_res = NULL;
     113    OSErr _err;
     114    SndListHandle sndHandle;
     115    Boolean async;
     116    if (!PyArg_ParseTuple(_args, "O&b",
     117                          ResObj_Convert, &sndHandle,
     118                          &async))
     119        return NULL;
     120    _err = SndPlay(_self->ob_itself,
     121                   sndHandle,
     122                   async);
     123    if (_err != noErr) return PyMac_Error(_err);
     124    Py_INCREF(Py_None);
     125    _res = Py_None;
     126    return _res;
    127127}
    128128
    129129static PyObject *SndCh_SndChannelStatus(SndChannelObject *_self, PyObject *_args)
    130130{
    131         PyObject *_res = NULL;
    132         OSErr _err;
    133         short theLength;
    134         SCStatus theStatus__out__;
    135         if (!PyArg_ParseTuple(_args, "h",
    136                               &theLength))
    137                 return NULL;
    138         _err = SndChannelStatus(_self->ob_itself,
    139                                 theLength,
    140                                 &theStatus__out__);
    141         if (_err != noErr) return PyMac_Error(_err);
    142         _res = Py_BuildValue("s#",
    143                              (char *)&theStatus__out__, (int)sizeof(SCStatus));
    144         return _res;
     131    PyObject *_res = NULL;
     132    OSErr _err;
     133    short theLength;
     134    SCStatus theStatus__out__;
     135    if (!PyArg_ParseTuple(_args, "h",
     136                          &theLength))
     137        return NULL;
     138    _err = SndChannelStatus(_self->ob_itself,
     139                            theLength,
     140                            &theStatus__out__);
     141    if (_err != noErr) return PyMac_Error(_err);
     142    _res = Py_BuildValue("s#",
     143                         (char *)&theStatus__out__, (int)sizeof(SCStatus));
     144    return _res;
    145145}
    146146
    147147static PyObject *SndCh_SndGetInfo(SndChannelObject *_self, PyObject *_args)
    148148{
    149         PyObject *_res = NULL;
    150         OSErr _err;
    151         OSType selector;
    152         void * infoPtr;
    153         if (!PyArg_ParseTuple(_args, "O&w",
    154                               PyMac_GetOSType, &selector,
    155                               &infoPtr))
    156                 return NULL;
    157         _err = SndGetInfo(_self->ob_itself,
    158                           selector,
    159                           infoPtr);
    160         if (_err != noErr) return PyMac_Error(_err);
    161         Py_INCREF(Py_None);
    162         _res = Py_None;
    163         return _res;
     149    PyObject *_res = NULL;
     150    OSErr _err;
     151    OSType selector;
     152    void * infoPtr;
     153    if (!PyArg_ParseTuple(_args, "O&w",
     154                          PyMac_GetOSType, &selector,
     155                          &infoPtr))
     156        return NULL;
     157    _err = SndGetInfo(_self->ob_itself,
     158                      selector,
     159                      infoPtr);
     160    if (_err != noErr) return PyMac_Error(_err);
     161    Py_INCREF(Py_None);
     162    _res = Py_None;
     163    return _res;
    164164}
    165165
    166166static PyObject *SndCh_SndSetInfo(SndChannelObject *_self, PyObject *_args)
    167167{
    168         PyObject *_res = NULL;
    169         OSErr _err;
    170         OSType selector;
    171         void * infoPtr;
    172         if (!PyArg_ParseTuple(_args, "O&w",
    173                               PyMac_GetOSType, &selector,
    174                               &infoPtr))
    175                 return NULL;
    176         _err = SndSetInfo(_self->ob_itself,
    177                           selector,
    178                           infoPtr);
    179         if (_err != noErr) return PyMac_Error(_err);
    180         Py_INCREF(Py_None);
    181         _res = Py_None;
    182         return _res;
     168    PyObject *_res = NULL;
     169    OSErr _err;
     170    OSType selector;
     171    void * infoPtr;
     172    if (!PyArg_ParseTuple(_args, "O&w",
     173                          PyMac_GetOSType, &selector,
     174                          &infoPtr))
     175        return NULL;
     176    _err = SndSetInfo(_self->ob_itself,
     177                      selector,
     178                      infoPtr);
     179    if (_err != noErr) return PyMac_Error(_err);
     180    Py_INCREF(Py_None);
     181    _res = Py_None;
     182    return _res;
    183183}
    184184
    185185static PyMethodDef SndCh_methods[] = {
    186         {"SndDoCommand", (PyCFunction)SndCh_SndDoCommand, 1,
    187         PyDoc_STR("(SndCommand cmd, Boolean noWait) -> None")},
    188         {"SndDoImmediate", (PyCFunction)SndCh_SndDoImmediate, 1,
    189         PyDoc_STR("(SndCommand cmd) -> None")},
    190         {"SndPlay", (PyCFunction)SndCh_SndPlay, 1,
    191         PyDoc_STR("(SndListHandle sndHandle, Boolean async) -> None")},
    192         {"SndChannelStatus", (PyCFunction)SndCh_SndChannelStatus, 1,
    193         PyDoc_STR("(short theLength) -> (SCStatus theStatus)")},
    194         {"SndGetInfo", (PyCFunction)SndCh_SndGetInfo, 1,
    195         PyDoc_STR("(OSType selector, void * infoPtr) -> None")},
    196         {"SndSetInfo", (PyCFunction)SndCh_SndSetInfo, 1,
    197         PyDoc_STR("(OSType selector, void * infoPtr) -> None")},
    198         {NULL, NULL, 0}
     186    {"SndDoCommand", (PyCFunction)SndCh_SndDoCommand, 1,
     187    PyDoc_STR("(SndCommand cmd, Boolean noWait) -> None")},
     188    {"SndDoImmediate", (PyCFunction)SndCh_SndDoImmediate, 1,
     189    PyDoc_STR("(SndCommand cmd) -> None")},
     190    {"SndPlay", (PyCFunction)SndCh_SndPlay, 1,
     191    PyDoc_STR("(SndListHandle sndHandle, Boolean async) -> None")},
     192    {"SndChannelStatus", (PyCFunction)SndCh_SndChannelStatus, 1,
     193    PyDoc_STR("(short theLength) -> (SCStatus theStatus)")},
     194    {"SndGetInfo", (PyCFunction)SndCh_SndGetInfo, 1,
     195    PyDoc_STR("(OSType selector, void * infoPtr) -> None")},
     196    {"SndSetInfo", (PyCFunction)SndCh_SndSetInfo, 1,
     197    PyDoc_STR("(OSType selector, void * infoPtr) -> None")},
     198    {NULL, NULL, 0}
    199199};
    200200
     
    209209
    210210static PyTypeObject SndChannel_Type = {
    211         PyObject_HEAD_INIT(NULL)
    212         0, /*ob_size*/
    213         "_Snd.SndChannel", /*tp_name*/
    214         sizeof(SndChannelObject), /*tp_basicsize*/
    215         0, /*tp_itemsize*/
    216         /* methods */
    217         (destructor) SndCh_dealloc, /*tp_dealloc*/
    218         0, /*tp_print*/
    219         (getattrfunc)0, /*tp_getattr*/
    220         (setattrfunc)0, /*tp_setattr*/
    221         (cmpfunc) SndCh_compare, /*tp_compare*/
    222         (reprfunc) SndCh_repr, /*tp_repr*/
    223         (PyNumberMethods *)0, /* tp_as_number */
    224         (PySequenceMethods *)0, /* tp_as_sequence */
    225         (PyMappingMethods *)0, /* tp_as_mapping */
    226         (hashfunc) SndCh_hash, /*tp_hash*/
    227         0, /*tp_call*/
    228         0, /*tp_str*/
    229         PyObject_GenericGetAttr, /*tp_getattro*/
    230         PyObject_GenericSetAttr, /*tp_setattro */
    231         0, /*tp_as_buffer*/
    232         Py_TPFLAGS_DEFAULT, /* tp_flags */
    233         0, /*tp_doc*/
    234         0, /*tp_traverse*/
    235         0, /*tp_clear*/
    236         0, /*tp_richcompare*/
    237         0, /*tp_weaklistoffset*/
    238         0, /*tp_iter*/
    239         0, /*tp_iternext*/
    240         SndCh_methods, /* tp_methods */
    241         0, /*tp_members*/
    242         SndCh_getsetlist, /*tp_getset*/
    243         0, /*tp_base*/
    244         0, /*tp_dict*/
    245         0, /*tp_descr_get*/
    246         0, /*tp_descr_set*/
    247         0, /*tp_dictoffset*/
    248         0, /*tp_init*/
    249         0, /*tp_alloc*/
    250         0, /*tp_new*/
    251         0, /*tp_free*/
     211    PyObject_HEAD_INIT(NULL)
     212    0, /*ob_size*/
     213    "_Snd.SndChannel", /*tp_name*/
     214    sizeof(SndChannelObject), /*tp_basicsize*/
     215    0, /*tp_itemsize*/
     216    /* methods */
     217    (destructor) SndCh_dealloc, /*tp_dealloc*/
     218    0, /*tp_print*/
     219    (getattrfunc)0, /*tp_getattr*/
     220    (setattrfunc)0, /*tp_setattr*/
     221    (cmpfunc) SndCh_compare, /*tp_compare*/
     222    (reprfunc) SndCh_repr, /*tp_repr*/
     223    (PyNumberMethods *)0, /* tp_as_number */
     224    (PySequenceMethods *)0, /* tp_as_sequence */
     225    (PyMappingMethods *)0, /* tp_as_mapping */
     226    (hashfunc) SndCh_hash, /*tp_hash*/
     227    0, /*tp_call*/
     228    0, /*tp_str*/
     229    PyObject_GenericGetAttr, /*tp_getattro*/
     230    PyObject_GenericSetAttr, /*tp_setattro */
     231    0, /*tp_as_buffer*/
     232    Py_TPFLAGS_DEFAULT, /* tp_flags */
     233    0, /*tp_doc*/
     234    0, /*tp_traverse*/
     235    0, /*tp_clear*/
     236    0, /*tp_richcompare*/
     237    0, /*tp_weaklistoffset*/
     238    0, /*tp_iter*/
     239    0, /*tp_iternext*/
     240    SndCh_methods, /* tp_methods */
     241    0, /*tp_members*/
     242    SndCh_getsetlist, /*tp_getset*/
     243    0, /*tp_base*/
     244    0, /*tp_dict*/
     245    0, /*tp_descr_get*/
     246    0, /*tp_descr_set*/
     247    0, /*tp_dictoffset*/
     248    0, /*tp_init*/
     249    0, /*tp_alloc*/
     250    0, /*tp_new*/
     251    0, /*tp_free*/
    252252};
    253253
     
    262262
    263263typedef struct SPBObject {
    264         PyObject_HEAD
    265         /* Members used to implement callbacks: */
    266         PyObject *ob_completion;
    267         PyObject *ob_interrupt;
    268         PyObject *ob_thiscallback;
    269         long ob_A5;
    270         SPB ob_spb;
     264    PyObject_HEAD
     265    /* Members used to implement callbacks: */
     266    PyObject *ob_completion;
     267    PyObject *ob_interrupt;
     268    PyObject *ob_thiscallback;
     269    long ob_A5;
     270    SPB ob_spb;
    271271} SPBObject;
    272272
    273273static PyObject *SPBObj_New(void)
    274274{
    275         SPBObject *it;
    276         it = PyObject_NEW(SPBObject, &SPB_Type);
    277         if (it == NULL) return NULL;
    278         it->ob_completion = NULL;
    279         it->ob_interrupt = NULL;
    280         it->ob_thiscallback = NULL;
    281         it->ob_A5 = SetCurrentA5();
    282         memset((char *)&it->ob_spb, 0, sizeof(it->ob_spb));
    283         it->ob_spb.userLong = (long)it;
    284         return (PyObject *)it;
     275    SPBObject *it;
     276    it = PyObject_NEW(SPBObject, &SPB_Type);
     277    if (it == NULL) return NULL;
     278    it->ob_completion = NULL;
     279    it->ob_interrupt = NULL;
     280    it->ob_thiscallback = NULL;
     281    it->ob_A5 = SetCurrentA5();
     282    memset((char *)&it->ob_spb, 0, sizeof(it->ob_spb));
     283    it->ob_spb.userLong = (long)it;
     284    return (PyObject *)it;
    285285}
    286286static int SPBObj_Convert(PyObject *v, SPBPtr *p_itself)
    287287{
    288         if (!SPBObj_Check(v))
    289         {
    290                 PyErr_SetString(PyExc_TypeError, "SPB required");
    291                 return 0;
    292         }
    293         *p_itself = &((SPBObject *)v)->ob_spb;
    294         return 1;
     288    if (!SPBObj_Check(v))
     289    {
     290        PyErr_SetString(PyExc_TypeError, "SPB required");
     291        return 0;
     292    }
     293    *p_itself = &((SPBObject *)v)->ob_spb;
     294    return 1;
    295295}
    296296
    297297static void SPBObj_dealloc(SPBObject *self)
    298298{
    299         /* Cleanup of self->ob_itself goes here */
    300         self->ob_spb.userLong = 0;
    301         self->ob_thiscallback = 0;
    302         Py_XDECREF(self->ob_completion);
    303         Py_XDECREF(self->ob_interrupt);
    304         PyObject_Free((PyObject *)self);
     299    /* Cleanup of self->ob_itself goes here */
     300    self->ob_spb.userLong = 0;
     301    self->ob_thiscallback = 0;
     302    Py_XDECREF(self->ob_completion);
     303    Py_XDECREF(self->ob_interrupt);
     304    PyObject_Free((PyObject *)self);
    305305}
    306306
    307307static PyMethodDef SPBObj_methods[] = {
    308         {NULL, NULL, 0}
     308    {NULL, NULL, 0}
    309309};
    310310
    311311static PyObject *SPBObj_get_inRefNum(SPBObject *self, void *closure)
    312312{
    313         return Py_BuildValue("l", self->ob_spb.inRefNum);
     313    return Py_BuildValue("l", self->ob_spb.inRefNum);
    314314}
    315315
    316316static int SPBObj_set_inRefNum(SPBObject *self, PyObject *v, void *closure)
    317317{
    318         return -1 + PyArg_Parse(v, "l", &self->ob_spb.inRefNum);
    319         return 0;
     318    return -1 + PyArg_Parse(v, "l", &self->ob_spb.inRefNum);
     319    return 0;
    320320}
    321321
    322322static PyObject *SPBObj_get_count(SPBObject *self, void *closure)
    323323{
    324         return Py_BuildValue("l", self->ob_spb.count);
     324    return Py_BuildValue("l", self->ob_spb.count);
    325325}
    326326
    327327static int SPBObj_set_count(SPBObject *self, PyObject *v, void *closure)
    328328{
    329         return -1 + PyArg_Parse(v, "l", &self->ob_spb.count);
    330         return 0;
     329    return -1 + PyArg_Parse(v, "l", &self->ob_spb.count);
     330    return 0;
    331331}
    332332
    333333static PyObject *SPBObj_get_milliseconds(SPBObject *self, void *closure)
    334334{
    335         return Py_BuildValue("l", self->ob_spb.milliseconds);
     335    return Py_BuildValue("l", self->ob_spb.milliseconds);
    336336}
    337337
    338338static int SPBObj_set_milliseconds(SPBObject *self, PyObject *v, void *closure)
    339339{
    340         return -1 + PyArg_Parse(v, "l", &self->ob_spb.milliseconds);
    341         return 0;
     340    return -1 + PyArg_Parse(v, "l", &self->ob_spb.milliseconds);
     341    return 0;
    342342}
    343343
    344344static PyObject *SPBObj_get_error(SPBObject *self, void *closure)
    345345{
    346         return Py_BuildValue("h", self->ob_spb.error);
     346    return Py_BuildValue("h", self->ob_spb.error);
    347347}
    348348
     
    353353static int SPBObj_set_completionRoutine(SPBObject *self, PyObject *v, void *closure)
    354354{
    355         self->ob_spb.completionRoutine = NewSICompletionUPP(SPB_completion);
    356                     self->ob_completion = v;
    357                     Py_INCREF(v);
    358                     return 0;
    359         return 0;
     355    self->ob_spb.completionRoutine = NewSICompletionUPP(SPB_completion);
     356                self->ob_completion = v;
     357                Py_INCREF(v);
     358                return 0;
     359    return 0;
    360360}
    361361
    362362static PyGetSetDef SPBObj_getsetlist[] = {
    363         {"inRefNum", (getter)SPBObj_get_inRefNum, (setter)SPBObj_set_inRefNum, NULL},
    364         {"count", (getter)SPBObj_get_count, (setter)SPBObj_set_count, NULL},
    365         {"milliseconds", (getter)SPBObj_get_milliseconds, (setter)SPBObj_set_milliseconds, NULL},
    366         {"error", (getter)SPBObj_get_error, (setter)SPBObj_set_error, NULL},
    367         {"completionRoutine", (getter)SPBObj_get_completionRoutine, (setter)SPBObj_set_completionRoutine, NULL},
    368         {NULL, NULL, NULL, NULL},
     363    {"inRefNum", (getter)SPBObj_get_inRefNum, (setter)SPBObj_set_inRefNum, NULL},
     364    {"count", (getter)SPBObj_get_count, (setter)SPBObj_set_count, NULL},
     365    {"milliseconds", (getter)SPBObj_get_milliseconds, (setter)SPBObj_set_milliseconds, NULL},
     366    {"error", (getter)SPBObj_get_error, (setter)SPBObj_set_error, NULL},
     367    {"completionRoutine", (getter)SPBObj_get_completionRoutine, (setter)SPBObj_set_completionRoutine, NULL},
     368    {NULL, NULL, NULL, NULL},
    369369};
    370370
     
    377377
    378378static PyTypeObject SPB_Type = {
    379         PyObject_HEAD_INIT(NULL)
    380         0, /*ob_size*/
    381         "_Snd.SPB", /*tp_name*/
    382         sizeof(SPBObject), /*tp_basicsize*/
    383         0, /*tp_itemsize*/
    384         /* methods */
    385         (destructor) SPBObj_dealloc, /*tp_dealloc*/
    386         0, /*tp_print*/
    387         (getattrfunc)0, /*tp_getattr*/
    388         (setattrfunc)0, /*tp_setattr*/
    389         (cmpfunc) SPBObj_compare, /*tp_compare*/
    390         (reprfunc) SPBObj_repr, /*tp_repr*/
    391         (PyNumberMethods *)0, /* tp_as_number */
    392         (PySequenceMethods *)0, /* tp_as_sequence */
    393         (PyMappingMethods *)0, /* tp_as_mapping */
    394         (hashfunc) SPBObj_hash, /*tp_hash*/
    395         0, /*tp_call*/
    396         0, /*tp_str*/
    397         PyObject_GenericGetAttr, /*tp_getattro*/
    398         PyObject_GenericSetAttr, /*tp_setattro */
    399         0, /*tp_as_buffer*/
    400         Py_TPFLAGS_DEFAULT, /* tp_flags */
    401         0, /*tp_doc*/
    402         0, /*tp_traverse*/
    403         0, /*tp_clear*/
    404         0, /*tp_richcompare*/
    405         0, /*tp_weaklistoffset*/
    406         0, /*tp_iter*/
    407         0, /*tp_iternext*/
    408         SPBObj_methods, /* tp_methods */
    409         0, /*tp_members*/
    410         SPBObj_getsetlist, /*tp_getset*/
    411         0, /*tp_base*/
    412         0, /*tp_dict*/
    413         0, /*tp_descr_get*/
    414         0, /*tp_descr_set*/
    415         0, /*tp_dictoffset*/
    416         0, /*tp_init*/
    417         0, /*tp_alloc*/
    418         0, /*tp_new*/
    419         0, /*tp_free*/
     379    PyObject_HEAD_INIT(NULL)
     380    0, /*ob_size*/
     381    "_Snd.SPB", /*tp_name*/
     382    sizeof(SPBObject), /*tp_basicsize*/
     383    0, /*tp_itemsize*/
     384    /* methods */
     385    (destructor) SPBObj_dealloc, /*tp_dealloc*/
     386    0, /*tp_print*/
     387    (getattrfunc)0, /*tp_getattr*/
     388    (setattrfunc)0, /*tp_setattr*/
     389    (cmpfunc) SPBObj_compare, /*tp_compare*/
     390    (reprfunc) SPBObj_repr, /*tp_repr*/
     391    (PyNumberMethods *)0, /* tp_as_number */
     392    (PySequenceMethods *)0, /* tp_as_sequence */
     393    (PyMappingMethods *)0, /* tp_as_mapping */
     394    (hashfunc) SPBObj_hash, /*tp_hash*/
     395    0, /*tp_call*/
     396    0, /*tp_str*/
     397    PyObject_GenericGetAttr, /*tp_getattro*/
     398    PyObject_GenericSetAttr, /*tp_setattro */
     399    0, /*tp_as_buffer*/
     400    Py_TPFLAGS_DEFAULT, /* tp_flags */
     401    0, /*tp_doc*/
     402    0, /*tp_traverse*/
     403    0, /*tp_clear*/
     404    0, /*tp_richcompare*/
     405    0, /*tp_weaklistoffset*/
     406    0, /*tp_iter*/
     407    0, /*tp_iternext*/
     408    SPBObj_methods, /* tp_methods */
     409    0, /*tp_members*/
     410    SPBObj_getsetlist, /*tp_getset*/
     411    0, /*tp_base*/
     412    0, /*tp_dict*/
     413    0, /*tp_descr_get*/
     414    0, /*tp_descr_set*/
     415    0, /*tp_dictoffset*/
     416    0, /*tp_init*/
     417    0, /*tp_alloc*/
     418    0, /*tp_new*/
     419    0, /*tp_free*/
    420420};
    421421
     
    425425static PyObject *Snd_SPB(PyObject *_self, PyObject *_args)
    426426{
    427         PyObject *_res = NULL;
    428         _res = SPBObj_New(); return _res;
     427    PyObject *_res = NULL;
     428    _res = SPBObj_New(); return _res;
    429429}
    430430
    431431static PyObject *Snd_SysBeep(PyObject *_self, PyObject *_args)
    432432{
    433         PyObject *_res = NULL;
    434         short duration;
    435         if (!PyArg_ParseTuple(_args, "h",
    436                               &duration))
    437                 return NULL;
    438         SysBeep(duration);
    439         Py_INCREF(Py_None);
    440         _res = Py_None;
    441         return _res;
     433    PyObject *_res = NULL;
     434    short duration;
     435    if (!PyArg_ParseTuple(_args, "h",
     436                          &duration))
     437        return NULL;
     438    SysBeep(duration);
     439    Py_INCREF(Py_None);
     440    _res = Py_None;
     441    return _res;
    442442}
    443443
    444444static PyObject *Snd_SndNewChannel(PyObject *_self, PyObject *_args)
    445445{
    446         PyObject *_res = NULL;
    447         OSErr _err;
    448         SndChannelPtr chan = 0;
    449         short synth;
    450         long init;
    451         PyObject* userRoutine;
    452         if (!PyArg_ParseTuple(_args, "hlO",
    453                               &synth,
    454                               &init,
    455                               &userRoutine))
    456                 return NULL;
    457         if (userRoutine != Py_None && !PyCallable_Check(userRoutine))
    458         {
    459                 PyErr_SetString(PyExc_TypeError, "callback must be callable");
    460                 goto userRoutine__error__;
    461         }
    462         _err = SndNewChannel(&chan,
    463                              synth,
    464                              init,
    465                              NewSndCallBackUPP(SndCh_UserRoutine));
    466         if (_err != noErr) return PyMac_Error(_err);
    467         _res = Py_BuildValue("O&",
    468                              SndCh_New, chan);
    469         if (_res != NULL && userRoutine != Py_None)
    470         {
    471                 SndChannelObject *p = (SndChannelObject *)_res;
    472                 p->ob_itself->userInfo = (long)p;
    473                 Py_INCREF(userRoutine);
    474                 p->ob_callback = userRoutine;
    475         }
     446    PyObject *_res = NULL;
     447    OSErr _err;
     448    SndChannelPtr chan = 0;
     449    short synth;
     450    long init;
     451    PyObject* userRoutine;
     452    if (!PyArg_ParseTuple(_args, "hlO",
     453                          &synth,
     454                          &init,
     455                          &userRoutine))
     456        return NULL;
     457    if (userRoutine != Py_None && !PyCallable_Check(userRoutine))
     458    {
     459        PyErr_SetString(PyExc_TypeError, "callback must be callable");
     460        goto userRoutine__error__;
     461    }
     462    _err = SndNewChannel(&chan,
     463                         synth,
     464                         init,
     465                         NewSndCallBackUPP(SndCh_UserRoutine));
     466    if (_err != noErr) return PyMac_Error(_err);
     467    _res = Py_BuildValue("O&",
     468                         SndCh_New, chan);
     469    if (_res != NULL && userRoutine != Py_None)
     470    {
     471        SndChannelObject *p = (SndChannelObject *)_res;
     472        p->ob_itself->userInfo = (long)p;
     473        Py_INCREF(userRoutine);
     474        p->ob_callback = userRoutine;
     475    }
    476476 userRoutine__error__: ;
    477         return _res;
     477    return _res;
    478478}
    479479
    480480static PyObject *Snd_SndSoundManagerVersion(PyObject *_self, PyObject *_args)
    481481{
    482         PyObject *_res = NULL;
    483         NumVersion _rv;
    484         if (!PyArg_ParseTuple(_args, ""))
    485                 return NULL;
    486         _rv = SndSoundManagerVersion();
    487         _res = Py_BuildValue("O&",
    488                              PyMac_BuildNumVersion, _rv);
    489         return _res;
     482    PyObject *_res = NULL;
     483    NumVersion _rv;
     484    if (!PyArg_ParseTuple(_args, ""))
     485        return NULL;
     486    _rv = SndSoundManagerVersion();
     487    _res = Py_BuildValue("O&",
     488                         PyMac_BuildNumVersion, _rv);
     489    return _res;
    490490}
    491491
    492492static PyObject *Snd_SndManagerStatus(PyObject *_self, PyObject *_args)
    493493{
    494         PyObject *_res = NULL;
    495         OSErr _err;
    496         short theLength;
    497         SMStatus theStatus__out__;
    498         if (!PyArg_ParseTuple(_args, "h",
    499                               &theLength))
    500                 return NULL;
    501         _err = SndManagerStatus(theLength,
    502                                 &theStatus__out__);
    503         if (_err != noErr) return PyMac_Error(_err);
    504         _res = Py_BuildValue("s#",
    505                              (char *)&theStatus__out__, (int)sizeof(SMStatus));
    506         return _res;
     494    PyObject *_res = NULL;
     495    OSErr _err;
     496    short theLength;
     497    SMStatus theStatus__out__;
     498    if (!PyArg_ParseTuple(_args, "h",
     499                          &theLength))
     500        return NULL;
     501    _err = SndManagerStatus(theLength,
     502                            &theStatus__out__);
     503    if (_err != noErr) return PyMac_Error(_err);
     504    _res = Py_BuildValue("s#",
     505                         (char *)&theStatus__out__, (int)sizeof(SMStatus));
     506    return _res;
    507507}
    508508
    509509static PyObject *Snd_SndGetSysBeepState(PyObject *_self, PyObject *_args)
    510510{
    511         PyObject *_res = NULL;
    512         short sysBeepState;
    513         if (!PyArg_ParseTuple(_args, ""))
    514                 return NULL;
    515         SndGetSysBeepState(&sysBeepState);
    516         _res = Py_BuildValue("h",
    517                              sysBeepState);
    518         return _res;
     511    PyObject *_res = NULL;
     512    short sysBeepState;
     513    if (!PyArg_ParseTuple(_args, ""))
     514        return NULL;
     515    SndGetSysBeepState(&sysBeepState);
     516    _res = Py_BuildValue("h",
     517                         sysBeepState);
     518    return _res;
    519519}
    520520
    521521static PyObject *Snd_SndSetSysBeepState(PyObject *_self, PyObject *_args)
    522522{
    523         PyObject *_res = NULL;
    524         OSErr _err;
    525         short sysBeepState;
    526         if (!PyArg_ParseTuple(_args, "h",
    527                               &sysBeepState))
    528                 return NULL;
    529         _err = SndSetSysBeepState(sysBeepState);
    530         if (_err != noErr) return PyMac_Error(_err);
    531         Py_INCREF(Py_None);
    532         _res = Py_None;
    533         return _res;
     523    PyObject *_res = NULL;
     524    OSErr _err;
     525    short sysBeepState;
     526    if (!PyArg_ParseTuple(_args, "h",
     527                          &sysBeepState))
     528        return NULL;
     529    _err = SndSetSysBeepState(sysBeepState);
     530    if (_err != noErr) return PyMac_Error(_err);
     531    Py_INCREF(Py_None);
     532    _res = Py_None;
     533    return _res;
    534534}
    535535
    536536static PyObject *Snd_GetSysBeepVolume(PyObject *_self, PyObject *_args)
    537537{
    538         PyObject *_res = NULL;
    539         OSErr _err;
    540         long level;
    541         if (!PyArg_ParseTuple(_args, ""))
    542                 return NULL;
    543         _err = GetSysBeepVolume(&level);
    544         if (_err != noErr) return PyMac_Error(_err);
    545         _res = Py_BuildValue("l",
    546                              level);
    547         return _res;
     538    PyObject *_res = NULL;
     539    OSErr _err;
     540    long level;
     541    if (!PyArg_ParseTuple(_args, ""))
     542        return NULL;
     543    _err = GetSysBeepVolume(&level);
     544    if (_err != noErr) return PyMac_Error(_err);
     545    _res = Py_BuildValue("l",
     546                         level);
     547    return _res;
    548548}
    549549
    550550static PyObject *Snd_SetSysBeepVolume(PyObject *_self, PyObject *_args)
    551551{
    552         PyObject *_res = NULL;
    553         OSErr _err;
    554         long level;
    555         if (!PyArg_ParseTuple(_args, "l",
    556                               &level))
    557                 return NULL;
    558         _err = SetSysBeepVolume(level);
    559         if (_err != noErr) return PyMac_Error(_err);
    560         Py_INCREF(Py_None);
    561         _res = Py_None;
    562         return _res;
     552    PyObject *_res = NULL;
     553    OSErr _err;
     554    long level;
     555    if (!PyArg_ParseTuple(_args, "l",
     556                          &level))
     557        return NULL;
     558    _err = SetSysBeepVolume(level);
     559    if (_err != noErr) return PyMac_Error(_err);
     560    Py_INCREF(Py_None);
     561    _res = Py_None;
     562    return _res;
    563563}
    564564
    565565static PyObject *Snd_GetDefaultOutputVolume(PyObject *_self, PyObject *_args)
    566566{
    567         PyObject *_res = NULL;
    568         OSErr _err;
    569         long level;
    570         if (!PyArg_ParseTuple(_args, ""))
    571                 return NULL;
    572         _err = GetDefaultOutputVolume(&level);
    573         if (_err != noErr) return PyMac_Error(_err);
    574         _res = Py_BuildValue("l",
    575                              level);
    576         return _res;
     567    PyObject *_res = NULL;
     568    OSErr _err;
     569    long level;
     570    if (!PyArg_ParseTuple(_args, ""))
     571        return NULL;
     572    _err = GetDefaultOutputVolume(&level);
     573    if (_err != noErr) return PyMac_Error(_err);
     574    _res = Py_BuildValue("l",
     575                         level);
     576    return _res;
    577577}
    578578
    579579static PyObject *Snd_SetDefaultOutputVolume(PyObject *_self, PyObject *_args)
    580580{
    581         PyObject *_res = NULL;
    582         OSErr _err;
    583         long level;
    584         if (!PyArg_ParseTuple(_args, "l",
    585                               &level))
    586                 return NULL;
    587         _err = SetDefaultOutputVolume(level);
    588         if (_err != noErr) return PyMac_Error(_err);
    589         Py_INCREF(Py_None);
    590         _res = Py_None;
    591         return _res;
     581    PyObject *_res = NULL;
     582    OSErr _err;
     583    long level;
     584    if (!PyArg_ParseTuple(_args, "l",
     585                          &level))
     586        return NULL;
     587    _err = SetDefaultOutputVolume(level);
     588    if (_err != noErr) return PyMac_Error(_err);
     589    Py_INCREF(Py_None);
     590    _res = Py_None;
     591    return _res;
    592592}
    593593
    594594static PyObject *Snd_GetSoundHeaderOffset(PyObject *_self, PyObject *_args)
    595595{
    596         PyObject *_res = NULL;
    597         OSErr _err;
    598         SndListHandle sndHandle;
    599         long offset;
    600         if (!PyArg_ParseTuple(_args, "O&",
    601                               ResObj_Convert, &sndHandle))
    602                 return NULL;
    603         _err = GetSoundHeaderOffset(sndHandle,
    604                                     &offset);
    605         if (_err != noErr) return PyMac_Error(_err);
    606         _res = Py_BuildValue("l",
    607                              offset);
    608         return _res;
     596    PyObject *_res = NULL;
     597    OSErr _err;
     598    SndListHandle sndHandle;
     599    long offset;
     600    if (!PyArg_ParseTuple(_args, "O&",
     601                          ResObj_Convert, &sndHandle))
     602        return NULL;
     603    _err = GetSoundHeaderOffset(sndHandle,
     604                                &offset);
     605    if (_err != noErr) return PyMac_Error(_err);
     606    _res = Py_BuildValue("l",
     607                         offset);
     608    return _res;
    609609}
    610610
    611611static PyObject *Snd_GetCompressionInfo(PyObject *_self, PyObject *_args)
    612612{
    613         PyObject *_res = NULL;
    614         OSErr _err;
    615         short compressionID;
    616         OSType format;
    617         short numChannels;
    618         short sampleSize;
    619         CompressionInfo cp__out__;
    620         if (!PyArg_ParseTuple(_args, "hO&hh",
    621                               &compressionID,
    622                               PyMac_GetOSType, &format,
    623                               &numChannels,
    624                               &sampleSize))
    625                 return NULL;
    626         _err = GetCompressionInfo(compressionID,
    627                                   format,
    628                                   numChannels,
    629                                   sampleSize,
    630                                   &cp__out__);
    631         if (_err != noErr) return PyMac_Error(_err);
    632         _res = Py_BuildValue("s#",
    633                              (char *)&cp__out__, (int)sizeof(CompressionInfo));
    634         return _res;
     613    PyObject *_res = NULL;
     614    OSErr _err;
     615    short compressionID;
     616    OSType format;
     617    short numChannels;
     618    short sampleSize;
     619    CompressionInfo cp__out__;
     620    if (!PyArg_ParseTuple(_args, "hO&hh",
     621                          &compressionID,
     622                          PyMac_GetOSType, &format,
     623                          &numChannels,
     624                          &sampleSize))
     625        return NULL;
     626    _err = GetCompressionInfo(compressionID,
     627                              format,
     628                              numChannels,
     629                              sampleSize,
     630                              &cp__out__);
     631    if (_err != noErr) return PyMac_Error(_err);
     632    _res = Py_BuildValue("s#",
     633                         (char *)&cp__out__, (int)sizeof(CompressionInfo));
     634    return _res;
    635635}
    636636
    637637static PyObject *Snd_SetSoundPreference(PyObject *_self, PyObject *_args)
    638638{
    639         PyObject *_res = NULL;
    640         OSErr _err;
    641         OSType theType;
    642         Str255 name;
    643         Handle settings;
    644         if (!PyArg_ParseTuple(_args, "O&O&",
    645                               PyMac_GetOSType, &theType,
    646                               ResObj_Convert, &settings))
    647                 return NULL;
    648         _err = SetSoundPreference(theType,
    649                                   name,
    650                                   settings);
    651         if (_err != noErr) return PyMac_Error(_err);
    652         _res = Py_BuildValue("O&",
    653                              PyMac_BuildStr255, name);
    654         return _res;
     639    PyObject *_res = NULL;
     640    OSErr _err;
     641    OSType theType;
     642    Str255 name;
     643    Handle settings;
     644    if (!PyArg_ParseTuple(_args, "O&O&",
     645                          PyMac_GetOSType, &theType,
     646                          ResObj_Convert, &settings))
     647        return NULL;
     648    _err = SetSoundPreference(theType,
     649                              name,
     650                              settings);
     651    if (_err != noErr) return PyMac_Error(_err);
     652    _res = Py_BuildValue("O&",
     653                         PyMac_BuildStr255, name);
     654    return _res;
    655655}
    656656
    657657static PyObject *Snd_GetSoundPreference(PyObject *_self, PyObject *_args)
    658658{
    659         PyObject *_res = NULL;
    660         OSErr _err;
    661         OSType theType;
    662         Str255 name;
    663         Handle settings;
    664         if (!PyArg_ParseTuple(_args, "O&O&",
    665                               PyMac_GetOSType, &theType,
    666                               ResObj_Convert, &settings))
    667                 return NULL;
    668         _err = GetSoundPreference(theType,
    669                                   name,
    670                                   settings);
    671         if (_err != noErr) return PyMac_Error(_err);
    672         _res = Py_BuildValue("O&",
    673                              PyMac_BuildStr255, name);
    674         return _res;
     659    PyObject *_res = NULL;
     660    OSErr _err;
     661    OSType theType;
     662    Str255 name;
     663    Handle settings;
     664    if (!PyArg_ParseTuple(_args, "O&O&",
     665                          PyMac_GetOSType, &theType,
     666                          ResObj_Convert, &settings))
     667        return NULL;
     668    _err = GetSoundPreference(theType,
     669                              name,
     670                              settings);
     671    if (_err != noErr) return PyMac_Error(_err);
     672    _res = Py_BuildValue("O&",
     673                         PyMac_BuildStr255, name);
     674    return _res;
    675675}
    676676
    677677static PyObject *Snd_GetCompressionName(PyObject *_self, PyObject *_args)
    678678{
    679         PyObject *_res = NULL;
    680         OSErr _err;
    681         OSType compressionType;
    682         Str255 compressionName;
    683         if (!PyArg_ParseTuple(_args, "O&",
    684                               PyMac_GetOSType, &compressionType))
    685                 return NULL;
    686         _err = GetCompressionName(compressionType,
    687                                   compressionName);
    688         if (_err != noErr) return PyMac_Error(_err);
    689         _res = Py_BuildValue("O&",
    690                              PyMac_BuildStr255, compressionName);
    691         return _res;
     679    PyObject *_res = NULL;
     680    OSErr _err;
     681    OSType compressionType;
     682    Str255 compressionName;
     683    if (!PyArg_ParseTuple(_args, "O&",
     684                          PyMac_GetOSType, &compressionType))
     685        return NULL;
     686    _err = GetCompressionName(compressionType,
     687                              compressionName);
     688    if (_err != noErr) return PyMac_Error(_err);
     689    _res = Py_BuildValue("O&",
     690                         PyMac_BuildStr255, compressionName);
     691    return _res;
    692692}
    693693
    694694static PyObject *Snd_SPBVersion(PyObject *_self, PyObject *_args)
    695695{
    696         PyObject *_res = NULL;
    697         NumVersion _rv;
    698         if (!PyArg_ParseTuple(_args, ""))
    699                 return NULL;
    700         _rv = SPBVersion();
    701         _res = Py_BuildValue("O&",
    702                              PyMac_BuildNumVersion, _rv);
    703         return _res;
     696    PyObject *_res = NULL;
     697    NumVersion _rv;
     698    if (!PyArg_ParseTuple(_args, ""))
     699        return NULL;
     700    _rv = SPBVersion();
     701    _res = Py_BuildValue("O&",
     702                         PyMac_BuildNumVersion, _rv);
     703    return _res;
    704704}
    705705
    706706static PyObject *Snd_SndRecord(PyObject *_self, PyObject *_args)
    707707{
    708         PyObject *_res = NULL;
    709         OSErr _err;
    710         Point corner;
    711         OSType quality;
    712         SndListHandle sndHandle;
    713         if (!PyArg_ParseTuple(_args, "O&O&",
    714                               PyMac_GetPoint, &corner,
    715                               PyMac_GetOSType, &quality))
    716                 return NULL;
    717         _err = SndRecord((ModalFilterUPP)0,
    718                          corner,
    719                          quality,
    720                          &sndHandle);
    721         if (_err != noErr) return PyMac_Error(_err);
    722         _res = Py_BuildValue("O&",
    723                              ResObj_New, sndHandle);
    724         return _res;
     708    PyObject *_res = NULL;
     709    OSErr _err;
     710    Point corner;
     711    OSType quality;
     712    SndListHandle sndHandle;
     713    if (!PyArg_ParseTuple(_args, "O&O&",
     714                          PyMac_GetPoint, &corner,
     715                          PyMac_GetOSType, &quality))
     716        return NULL;
     717    _err = SndRecord((ModalFilterUPP)0,
     718                     corner,
     719                     quality,
     720                     &sndHandle);
     721    if (_err != noErr) return PyMac_Error(_err);
     722    _res = Py_BuildValue("O&",
     723                         ResObj_New, sndHandle);
     724    return _res;
    725725}
    726726
    727727static PyObject *Snd_SPBSignInDevice(PyObject *_self, PyObject *_args)
    728728{
    729         PyObject *_res = NULL;
    730         OSErr _err;
    731         short deviceRefNum;
    732         Str255 deviceName;
    733         if (!PyArg_ParseTuple(_args, "hO&",
    734                               &deviceRefNum,
    735                               PyMac_GetStr255, deviceName))
    736                 return NULL;
    737         _err = SPBSignInDevice(deviceRefNum,
    738                                deviceName);
    739         if (_err != noErr) return PyMac_Error(_err);
    740         Py_INCREF(Py_None);
    741         _res = Py_None;
    742         return _res;
     729    PyObject *_res = NULL;
     730    OSErr _err;
     731    short deviceRefNum;
     732    Str255 deviceName;
     733    if (!PyArg_ParseTuple(_args, "hO&",
     734                          &deviceRefNum,
     735                          PyMac_GetStr255, deviceName))
     736        return NULL;
     737    _err = SPBSignInDevice(deviceRefNum,
     738                           deviceName);
     739    if (_err != noErr) return PyMac_Error(_err);
     740    Py_INCREF(Py_None);
     741    _res = Py_None;
     742    return _res;
    743743}
    744744
    745745static PyObject *Snd_SPBSignOutDevice(PyObject *_self, PyObject *_args)
    746746{
    747         PyObject *_res = NULL;
    748         OSErr _err;
    749         short deviceRefNum;
    750         if (!PyArg_ParseTuple(_args, "h",
    751                               &deviceRefNum))
    752                 return NULL;
    753         _err = SPBSignOutDevice(deviceRefNum);
    754         if (_err != noErr) return PyMac_Error(_err);
    755         Py_INCREF(Py_None);
    756         _res = Py_None;
    757         return _res;
     747    PyObject *_res = NULL;
     748    OSErr _err;
     749    short deviceRefNum;
     750    if (!PyArg_ParseTuple(_args, "h",
     751                          &deviceRefNum))
     752        return NULL;
     753    _err = SPBSignOutDevice(deviceRefNum);
     754    if (_err != noErr) return PyMac_Error(_err);
     755    Py_INCREF(Py_None);
     756    _res = Py_None;
     757    return _res;
    758758}
    759759
    760760static PyObject *Snd_SPBGetIndexedDevice(PyObject *_self, PyObject *_args)
    761761{
    762         PyObject *_res = NULL;
    763         OSErr _err;
    764         short count;
    765         Str255 deviceName;
    766         Handle deviceIconHandle;
    767         if (!PyArg_ParseTuple(_args, "h",
    768                               &count))
    769                 return NULL;
    770         _err = SPBGetIndexedDevice(count,
    771                                    deviceName,
    772                                    &deviceIconHandle);
    773         if (_err != noErr) return PyMac_Error(_err);
    774         _res = Py_BuildValue("O&O&",
    775                              PyMac_BuildStr255, deviceName,
    776                              ResObj_New, deviceIconHandle);
    777         return _res;
     762    PyObject *_res = NULL;
     763    OSErr _err;
     764    short count;
     765    Str255 deviceName;
     766    Handle deviceIconHandle;
     767    if (!PyArg_ParseTuple(_args, "h",
     768                          &count))
     769        return NULL;
     770    _err = SPBGetIndexedDevice(count,
     771                               deviceName,
     772                               &deviceIconHandle);
     773    if (_err != noErr) return PyMac_Error(_err);
     774    _res = Py_BuildValue("O&O&",
     775                         PyMac_BuildStr255, deviceName,
     776                         ResObj_New, deviceIconHandle);
     777    return _res;
    778778}
    779779
    780780static PyObject *Snd_SPBOpenDevice(PyObject *_self, PyObject *_args)
    781781{
    782         PyObject *_res = NULL;
    783         OSErr _err;
    784         Str255 deviceName;
    785         short permission;
    786         long inRefNum;
    787         if (!PyArg_ParseTuple(_args, "O&h",
    788                               PyMac_GetStr255, deviceName,
    789                               &permission))
    790                 return NULL;
    791         _err = SPBOpenDevice(deviceName,
    792                              permission,
    793                              &inRefNum);
    794         if (_err != noErr) return PyMac_Error(_err);
    795         _res = Py_BuildValue("l",
    796                              inRefNum);
    797         return _res;
     782    PyObject *_res = NULL;
     783    OSErr _err;
     784    Str255 deviceName;
     785    short permission;
     786    long inRefNum;
     787    if (!PyArg_ParseTuple(_args, "O&h",
     788                          PyMac_GetStr255, deviceName,
     789                          &permission))
     790        return NULL;
     791    _err = SPBOpenDevice(deviceName,
     792                         permission,
     793                         &inRefNum);
     794    if (_err != noErr) return PyMac_Error(_err);
     795    _res = Py_BuildValue("l",
     796                         inRefNum);
     797    return _res;
    798798}
    799799
    800800static PyObject *Snd_SPBCloseDevice(PyObject *_self, PyObject *_args)
    801801{
    802         PyObject *_res = NULL;
    803         OSErr _err;
    804         long inRefNum;
    805         if (!PyArg_ParseTuple(_args, "l",
    806                               &inRefNum))
    807                 return NULL;
    808         _err = SPBCloseDevice(inRefNum);
    809         if (_err != noErr) return PyMac_Error(_err);
    810         Py_INCREF(Py_None);
    811         _res = Py_None;
    812         return _res;
     802    PyObject *_res = NULL;
     803    OSErr _err;
     804    long inRefNum;
     805    if (!PyArg_ParseTuple(_args, "l",
     806                          &inRefNum))
     807        return NULL;
     808    _err = SPBCloseDevice(inRefNum);
     809    if (_err != noErr) return PyMac_Error(_err);
     810    Py_INCREF(Py_None);
     811    _res = Py_None;
     812    return _res;
    813813}
    814814
    815815static PyObject *Snd_SPBRecord(PyObject *_self, PyObject *_args)
    816816{
    817         PyObject *_res = NULL;
    818         OSErr _err;
    819         SPBPtr inParamPtr;
    820         Boolean asynchFlag;
    821         if (!PyArg_ParseTuple(_args, "O&b",
    822                               SPBObj_Convert, &inParamPtr,
    823                               &asynchFlag))
    824                 return NULL;
    825         _err = SPBRecord(inParamPtr,
    826                          asynchFlag);
    827         if (_err != noErr) return PyMac_Error(_err);
    828         Py_INCREF(Py_None);
    829         _res = Py_None;
    830         return _res;
     817    PyObject *_res = NULL;
     818    OSErr _err;
     819    SPBPtr inParamPtr;
     820    Boolean asynchFlag;
     821    if (!PyArg_ParseTuple(_args, "O&b",
     822                          SPBObj_Convert, &inParamPtr,
     823                          &asynchFlag))
     824        return NULL;
     825    _err = SPBRecord(inParamPtr,
     826                     asynchFlag);
     827    if (_err != noErr) return PyMac_Error(_err);
     828    Py_INCREF(Py_None);
     829    _res = Py_None;
     830    return _res;
    831831}
    832832
    833833static PyObject *Snd_SPBPauseRecording(PyObject *_self, PyObject *_args)
    834834{
    835         PyObject *_res = NULL;
    836         OSErr _err;
    837         long inRefNum;
    838         if (!PyArg_ParseTuple(_args, "l",
    839                               &inRefNum))
    840                 return NULL;
    841         _err = SPBPauseRecording(inRefNum);
    842         if (_err != noErr) return PyMac_Error(_err);
    843         Py_INCREF(Py_None);
    844         _res = Py_None;
    845         return _res;
     835    PyObject *_res = NULL;
     836    OSErr _err;
     837    long inRefNum;
     838    if (!PyArg_ParseTuple(_args, "l",
     839                          &inRefNum))
     840        return NULL;
     841    _err = SPBPauseRecording(inRefNum);
     842    if (_err != noErr) return PyMac_Error(_err);
     843    Py_INCREF(Py_None);
     844    _res = Py_None;
     845    return _res;
    846846}
    847847
    848848static PyObject *Snd_SPBResumeRecording(PyObject *_self, PyObject *_args)
    849849{
    850         PyObject *_res = NULL;
    851         OSErr _err;
    852         long inRefNum;
    853         if (!PyArg_ParseTuple(_args, "l",
    854                               &inRefNum))
    855                 return NULL;
    856         _err = SPBResumeRecording(inRefNum);
    857         if (_err != noErr) return PyMac_Error(_err);
    858         Py_INCREF(Py_None);
    859         _res = Py_None;
    860         return _res;
     850    PyObject *_res = NULL;
     851    OSErr _err;
     852    long inRefNum;
     853    if (!PyArg_ParseTuple(_args, "l",
     854                          &inRefNum))
     855        return NULL;
     856    _err = SPBResumeRecording(inRefNum);
     857    if (_err != noErr) return PyMac_Error(_err);
     858    Py_INCREF(Py_None);
     859    _res = Py_None;
     860    return _res;
    861861}
    862862
    863863static PyObject *Snd_SPBStopRecording(PyObject *_self, PyObject *_args)
    864864{
    865         PyObject *_res = NULL;
    866         OSErr _err;
    867         long inRefNum;
    868         if (!PyArg_ParseTuple(_args, "l",
    869                               &inRefNum))
    870                 return NULL;
    871         _err = SPBStopRecording(inRefNum);
    872         if (_err != noErr) return PyMac_Error(_err);
    873         Py_INCREF(Py_None);
    874         _res = Py_None;
    875         return _res;
     865    PyObject *_res = NULL;
     866    OSErr _err;
     867    long inRefNum;
     868    if (!PyArg_ParseTuple(_args, "l",
     869                          &inRefNum))
     870        return NULL;
     871    _err = SPBStopRecording(inRefNum);
     872    if (_err != noErr) return PyMac_Error(_err);
     873    Py_INCREF(Py_None);
     874    _res = Py_None;
     875    return _res;
    876876}
    877877
    878878static PyObject *Snd_SPBGetRecordingStatus(PyObject *_self, PyObject *_args)
    879879{
    880         PyObject *_res = NULL;
    881         OSErr _err;
    882         long inRefNum;
    883         short recordingStatus;
    884         short meterLevel;
    885         unsigned long totalSamplesToRecord;
    886         unsigned long numberOfSamplesRecorded;
    887         unsigned long totalMsecsToRecord;
    888         unsigned long numberOfMsecsRecorded;
    889         if (!PyArg_ParseTuple(_args, "l",
    890                               &inRefNum))
    891                 return NULL;
    892         _err = SPBGetRecordingStatus(inRefNum,
    893                                      &recordingStatus,
    894                                      &meterLevel,
    895                                      &totalSamplesToRecord,
    896                                      &numberOfSamplesRecorded,
    897                                      &totalMsecsToRecord,
    898                                      &numberOfMsecsRecorded);
    899         if (_err != noErr) return PyMac_Error(_err);
    900         _res = Py_BuildValue("hhllll",
    901                              recordingStatus,
    902                              meterLevel,
    903                              totalSamplesToRecord,
    904                              numberOfSamplesRecorded,
    905                              totalMsecsToRecord,
    906                              numberOfMsecsRecorded);
    907         return _res;
     880    PyObject *_res = NULL;
     881    OSErr _err;
     882    long inRefNum;
     883    short recordingStatus;
     884    short meterLevel;
     885    unsigned long totalSamplesToRecord;
     886    unsigned long numberOfSamplesRecorded;
     887    unsigned long totalMsecsToRecord;
     888    unsigned long numberOfMsecsRecorded;
     889    if (!PyArg_ParseTuple(_args, "l",
     890                          &inRefNum))
     891        return NULL;
     892    _err = SPBGetRecordingStatus(inRefNum,
     893                                 &recordingStatus,
     894                                 &meterLevel,
     895                                 &totalSamplesToRecord,
     896                                 &numberOfSamplesRecorded,
     897                                 &totalMsecsToRecord,
     898                                 &numberOfMsecsRecorded);
     899    if (_err != noErr) return PyMac_Error(_err);
     900    _res = Py_BuildValue("hhllll",
     901                         recordingStatus,
     902                         meterLevel,
     903                         totalSamplesToRecord,
     904                         numberOfSamplesRecorded,
     905                         totalMsecsToRecord,
     906                         numberOfMsecsRecorded);
     907    return _res;
    908908}
    909909
    910910static PyObject *Snd_SPBGetDeviceInfo(PyObject *_self, PyObject *_args)
    911911{
    912         PyObject *_res = NULL;
    913         OSErr _err;
    914         long inRefNum;
    915         OSType infoType;
    916         void * infoData;
    917         if (!PyArg_ParseTuple(_args, "lO&w",
    918                               &inRefNum,
    919                               PyMac_GetOSType, &infoType,
    920                               &infoData))
    921                 return NULL;
    922         _err = SPBGetDeviceInfo(inRefNum,
    923                                 infoType,
    924                                 infoData);
    925         if (_err != noErr) return PyMac_Error(_err);
    926         Py_INCREF(Py_None);
    927         _res = Py_None;
    928         return _res;
     912    PyObject *_res = NULL;
     913    OSErr _err;
     914    long inRefNum;
     915    OSType infoType;
     916    void * infoData;
     917    if (!PyArg_ParseTuple(_args, "lO&w",
     918                          &inRefNum,
     919                          PyMac_GetOSType, &infoType,
     920                          &infoData))
     921        return NULL;
     922    _err = SPBGetDeviceInfo(inRefNum,
     923                            infoType,
     924                            infoData);
     925    if (_err != noErr) return PyMac_Error(_err);
     926    Py_INCREF(Py_None);
     927    _res = Py_None;
     928    return _res;
    929929}
    930930
    931931static PyObject *Snd_SPBSetDeviceInfo(PyObject *_self, PyObject *_args)
    932932{
    933         PyObject *_res = NULL;
    934         OSErr _err;
    935         long inRefNum;
    936         OSType infoType;
    937         void * infoData;
    938         if (!PyArg_ParseTuple(_args, "lO&w",
    939                               &inRefNum,
    940                               PyMac_GetOSType, &infoType,
    941                               &infoData))
    942                 return NULL;
    943         _err = SPBSetDeviceInfo(inRefNum,
    944                                 infoType,
    945                                 infoData);
    946         if (_err != noErr) return PyMac_Error(_err);
    947         Py_INCREF(Py_None);
    948         _res = Py_None;
    949         return _res;
     933    PyObject *_res = NULL;
     934    OSErr _err;
     935    long inRefNum;
     936    OSType infoType;
     937    void * infoData;
     938    if (!PyArg_ParseTuple(_args, "lO&w",
     939                          &inRefNum,
     940                          PyMac_GetOSType, &infoType,
     941                          &infoData))
     942        return NULL;
     943    _err = SPBSetDeviceInfo(inRefNum,
     944                            infoType,
     945                            infoData);
     946    if (_err != noErr) return PyMac_Error(_err);
     947    Py_INCREF(Py_None);
     948    _res = Py_None;
     949    return _res;
    950950}
    951951
    952952static PyObject *Snd_SPBMillisecondsToBytes(PyObject *_self, PyObject *_args)
    953953{
    954         PyObject *_res = NULL;
    955         OSErr _err;
    956         long inRefNum;
    957         long milliseconds;
    958         if (!PyArg_ParseTuple(_args, "l",
    959                               &inRefNum))
    960                 return NULL;
    961         _err = SPBMillisecondsToBytes(inRefNum,
    962                                       &milliseconds);
    963         if (_err != noErr) return PyMac_Error(_err);
    964         _res = Py_BuildValue("l",
    965                              milliseconds);
    966         return _res;
     954    PyObject *_res = NULL;
     955    OSErr _err;
     956    long inRefNum;
     957    long milliseconds;
     958    if (!PyArg_ParseTuple(_args, "l",
     959                          &inRefNum))
     960        return NULL;
     961    _err = SPBMillisecondsToBytes(inRefNum,
     962                                  &milliseconds);
     963    if (_err != noErr) return PyMac_Error(_err);
     964    _res = Py_BuildValue("l",
     965                         milliseconds);
     966    return _res;
    967967}
    968968
    969969static PyObject *Snd_SPBBytesToMilliseconds(PyObject *_self, PyObject *_args)
    970970{
    971         PyObject *_res = NULL;
    972         OSErr _err;
    973         long inRefNum;
    974         long byteCount;
    975         if (!PyArg_ParseTuple(_args, "l",
    976                               &inRefNum))
    977                 return NULL;
    978         _err = SPBBytesToMilliseconds(inRefNum,
    979                                       &byteCount);
    980         if (_err != noErr) return PyMac_Error(_err);
    981         _res = Py_BuildValue("l",
    982                              byteCount);
    983         return _res;
     971    PyObject *_res = NULL;
     972    OSErr _err;
     973    long inRefNum;
     974    long byteCount;
     975    if (!PyArg_ParseTuple(_args, "l",
     976                          &inRefNum))
     977        return NULL;
     978    _err = SPBBytesToMilliseconds(inRefNum,
     979                                  &byteCount);
     980    if (_err != noErr) return PyMac_Error(_err);
     981    _res = Py_BuildValue("l",
     982                         byteCount);
     983    return _res;
    984984}
    985985#endif /* __LP64__ */
     
    987987static PyMethodDef Snd_methods[] = {
    988988#ifndef __LP64__
    989         {"SPB", (PyCFunction)Snd_SPB, 1,
    990         PyDoc_STR(NULL)},
    991         {"SysBeep", (PyCFunction)Snd_SysBeep, 1,
    992         PyDoc_STR("(short duration) -> None")},
    993         {"SndNewChannel", (PyCFunction)Snd_SndNewChannel, 1,
    994         PyDoc_STR("(short synth, long init, PyObject* userRoutine) -> (SndChannelPtr chan)")},
    995         {"SndSoundManagerVersion", (PyCFunction)Snd_SndSoundManagerVersion, 1,
    996         PyDoc_STR("() -> (NumVersion _rv)")},
    997         {"SndManagerStatus", (PyCFunction)Snd_SndManagerStatus, 1,
    998         PyDoc_STR("(short theLength) -> (SMStatus theStatus)")},
    999         {"SndGetSysBeepState", (PyCFunction)Snd_SndGetSysBeepState, 1,
    1000         PyDoc_STR("() -> (short sysBeepState)")},
    1001         {"SndSetSysBeepState", (PyCFunction)Snd_SndSetSysBeepState, 1,
    1002         PyDoc_STR("(short sysBeepState) -> None")},
    1003         {"GetSysBeepVolume", (PyCFunction)Snd_GetSysBeepVolume, 1,
    1004         PyDoc_STR("() -> (long level)")},
    1005         {"SetSysBeepVolume", (PyCFunction)Snd_SetSysBeepVolume, 1,
    1006         PyDoc_STR("(long level) -> None")},
    1007         {"GetDefaultOutputVolume", (PyCFunction)Snd_GetDefaultOutputVolume, 1,
    1008         PyDoc_STR("() -> (long level)")},
    1009         {"SetDefaultOutputVolume", (PyCFunction)Snd_SetDefaultOutputVolume, 1,
    1010         PyDoc_STR("(long level) -> None")},
    1011         {"GetSoundHeaderOffset", (PyCFunction)Snd_GetSoundHeaderOffset, 1,
    1012         PyDoc_STR("(SndListHandle sndHandle) -> (long offset)")},
    1013         {"GetCompressionInfo", (PyCFunction)Snd_GetCompressionInfo, 1,
    1014         PyDoc_STR("(short compressionID, OSType format, short numChannels, short sampleSize) -> (CompressionInfo cp)")},
    1015         {"SetSoundPreference", (PyCFunction)Snd_SetSoundPreference, 1,
    1016         PyDoc_STR("(OSType theType, Handle settings) -> (Str255 name)")},
    1017         {"GetSoundPreference", (PyCFunction)Snd_GetSoundPreference, 1,
    1018         PyDoc_STR("(OSType theType, Handle settings) -> (Str255 name)")},
    1019         {"GetCompressionName", (PyCFunction)Snd_GetCompressionName, 1,
    1020         PyDoc_STR("(OSType compressionType) -> (Str255 compressionName)")},
    1021         {"SPBVersion", (PyCFunction)Snd_SPBVersion, 1,
    1022         PyDoc_STR("() -> (NumVersion _rv)")},
    1023         {"SndRecord", (PyCFunction)Snd_SndRecord, 1,
    1024         PyDoc_STR("(Point corner, OSType quality) -> (SndListHandle sndHandle)")},
    1025         {"SPBSignInDevice", (PyCFunction)Snd_SPBSignInDevice, 1,
    1026         PyDoc_STR("(short deviceRefNum, Str255 deviceName) -> None")},
    1027         {"SPBSignOutDevice", (PyCFunction)Snd_SPBSignOutDevice, 1,
    1028         PyDoc_STR("(short deviceRefNum) -> None")},
    1029         {"SPBGetIndexedDevice", (PyCFunction)Snd_SPBGetIndexedDevice, 1,
    1030         PyDoc_STR("(short count) -> (Str255 deviceName, Handle deviceIconHandle)")},
    1031         {"SPBOpenDevice", (PyCFunction)Snd_SPBOpenDevice, 1,
    1032         PyDoc_STR("(Str255 deviceName, short permission) -> (long inRefNum)")},
    1033         {"SPBCloseDevice", (PyCFunction)Snd_SPBCloseDevice, 1,
    1034         PyDoc_STR("(long inRefNum) -> None")},
    1035         {"SPBRecord", (PyCFunction)Snd_SPBRecord, 1,
    1036         PyDoc_STR("(SPBPtr inParamPtr, Boolean asynchFlag) -> None")},
    1037         {"SPBPauseRecording", (PyCFunction)Snd_SPBPauseRecording, 1,
    1038         PyDoc_STR("(long inRefNum) -> None")},
    1039         {"SPBResumeRecording", (PyCFunction)Snd_SPBResumeRecording, 1,
    1040         PyDoc_STR("(long inRefNum) -> None")},
    1041         {"SPBStopRecording", (PyCFunction)Snd_SPBStopRecording, 1,
    1042         PyDoc_STR("(long inRefNum) -> None")},
    1043         {"SPBGetRecordingStatus", (PyCFunction)Snd_SPBGetRecordingStatus, 1,
    1044         PyDoc_STR("(long inRefNum) -> (short recordingStatus, short meterLevel, unsigned long totalSamplesToRecord, unsigned long numberOfSamplesRecorded, unsigned long totalMsecsToRecord, unsigned long numberOfMsecsRecorded)")},
    1045         {"SPBGetDeviceInfo", (PyCFunction)Snd_SPBGetDeviceInfo, 1,
    1046         PyDoc_STR("(long inRefNum, OSType infoType, void * infoData) -> None")},
    1047         {"SPBSetDeviceInfo", (PyCFunction)Snd_SPBSetDeviceInfo, 1,
    1048         PyDoc_STR("(long inRefNum, OSType infoType, void * infoData) -> None")},
    1049         {"SPBMillisecondsToBytes", (PyCFunction)Snd_SPBMillisecondsToBytes, 1,
    1050         PyDoc_STR("(long inRefNum) -> (long milliseconds)")},
    1051         {"SPBBytesToMilliseconds", (PyCFunction)Snd_SPBBytesToMilliseconds, 1,
    1052         PyDoc_STR("(long inRefNum) -> (long byteCount)")},
     989    {"SPB", (PyCFunction)Snd_SPB, 1,
     990    PyDoc_STR(NULL)},
     991    {"SysBeep", (PyCFunction)Snd_SysBeep, 1,
     992    PyDoc_STR("(short duration) -> None")},
     993    {"SndNewChannel", (PyCFunction)Snd_SndNewChannel, 1,
     994    PyDoc_STR("(short synth, long init, PyObject* userRoutine) -> (SndChannelPtr chan)")},
     995    {"SndSoundManagerVersion", (PyCFunction)Snd_SndSoundManagerVersion, 1,
     996    PyDoc_STR("() -> (NumVersion _rv)")},
     997    {"SndManagerStatus", (PyCFunction)Snd_SndManagerStatus, 1,
     998    PyDoc_STR("(short theLength) -> (SMStatus theStatus)")},
     999    {"SndGetSysBeepState", (PyCFunction)Snd_SndGetSysBeepState, 1,
     1000    PyDoc_STR("() -> (short sysBeepState)")},
     1001    {"SndSetSysBeepState", (PyCFunction)Snd_SndSetSysBeepState, 1,
     1002    PyDoc_STR("(short sysBeepState) -> None")},
     1003    {"GetSysBeepVolume", (PyCFunction)Snd_GetSysBeepVolume, 1,
     1004    PyDoc_STR("() -> (long level)")},
     1005    {"SetSysBeepVolume", (PyCFunction)Snd_SetSysBeepVolume, 1,
     1006    PyDoc_STR("(long level) -> None")},
     1007    {"GetDefaultOutputVolume", (PyCFunction)Snd_GetDefaultOutputVolume, 1,
     1008    PyDoc_STR("() -> (long level)")},
     1009    {"SetDefaultOutputVolume", (PyCFunction)Snd_SetDefaultOutputVolume, 1,
     1010    PyDoc_STR("(long level) -> None")},
     1011    {"GetSoundHeaderOffset", (PyCFunction)Snd_GetSoundHeaderOffset, 1,
     1012    PyDoc_STR("(SndListHandle sndHandle) -> (long offset)")},
     1013    {"GetCompressionInfo", (PyCFunction)Snd_GetCompressionInfo, 1,
     1014    PyDoc_STR("(short compressionID, OSType format, short numChannels, short sampleSize) -> (CompressionInfo cp)")},
     1015    {"SetSoundPreference", (PyCFunction)Snd_SetSoundPreference, 1,
     1016    PyDoc_STR("(OSType theType, Handle settings) -> (Str255 name)")},
     1017    {"GetSoundPreference", (PyCFunction)Snd_GetSoundPreference, 1,
     1018    PyDoc_STR("(OSType theType, Handle settings) -> (Str255 name)")},
     1019    {"GetCompressionName", (PyCFunction)Snd_GetCompressionName, 1,
     1020    PyDoc_STR("(OSType compressionType) -> (Str255 compressionName)")},
     1021    {"SPBVersion", (PyCFunction)Snd_SPBVersion, 1,
     1022    PyDoc_STR("() -> (NumVersion _rv)")},
     1023    {"SndRecord", (PyCFunction)Snd_SndRecord, 1,
     1024    PyDoc_STR("(Point corner, OSType quality) -> (SndListHandle sndHandle)")},
     1025    {"SPBSignInDevice", (PyCFunction)Snd_SPBSignInDevice, 1,
     1026    PyDoc_STR("(short deviceRefNum, Str255 deviceName) -> None")},
     1027    {"SPBSignOutDevice", (PyCFunction)Snd_SPBSignOutDevice, 1,
     1028    PyDoc_STR("(short deviceRefNum) -> None")},
     1029    {"SPBGetIndexedDevice", (PyCFunction)Snd_SPBGetIndexedDevice, 1,
     1030    PyDoc_STR("(short count) -> (Str255 deviceName, Handle deviceIconHandle)")},
     1031    {"SPBOpenDevice", (PyCFunction)Snd_SPBOpenDevice, 1,
     1032    PyDoc_STR("(Str255 deviceName, short permission) -> (long inRefNum)")},
     1033    {"SPBCloseDevice", (PyCFunction)Snd_SPBCloseDevice, 1,
     1034    PyDoc_STR("(long inRefNum) -> None")},
     1035    {"SPBRecord", (PyCFunction)Snd_SPBRecord, 1,
     1036    PyDoc_STR("(SPBPtr inParamPtr, Boolean asynchFlag) -> None")},
     1037    {"SPBPauseRecording", (PyCFunction)Snd_SPBPauseRecording, 1,
     1038    PyDoc_STR("(long inRefNum) -> None")},
     1039    {"SPBResumeRecording", (PyCFunction)Snd_SPBResumeRecording, 1,
     1040    PyDoc_STR("(long inRefNum) -> None")},
     1041    {"SPBStopRecording", (PyCFunction)Snd_SPBStopRecording, 1,
     1042    PyDoc_STR("(long inRefNum) -> None")},
     1043    {"SPBGetRecordingStatus", (PyCFunction)Snd_SPBGetRecordingStatus, 1,
     1044    PyDoc_STR("(long inRefNum) -> (short recordingStatus, short meterLevel, unsigned long totalSamplesToRecord, unsigned long numberOfSamplesRecorded, unsigned long totalMsecsToRecord, unsigned long numberOfMsecsRecorded)")},
     1045    {"SPBGetDeviceInfo", (PyCFunction)Snd_SPBGetDeviceInfo, 1,
     1046    PyDoc_STR("(long inRefNum, OSType infoType, void * infoData) -> None")},
     1047    {"SPBSetDeviceInfo", (PyCFunction)Snd_SPBSetDeviceInfo, 1,
     1048    PyDoc_STR("(long inRefNum, OSType infoType, void * infoData) -> None")},
     1049    {"SPBMillisecondsToBytes", (PyCFunction)Snd_SPBMillisecondsToBytes, 1,
     1050    PyDoc_STR("(long inRefNum) -> (long milliseconds)")},
     1051    {"SPBBytesToMilliseconds", (PyCFunction)Snd_SPBBytesToMilliseconds, 1,
     1052    PyDoc_STR("(long inRefNum) -> (long byteCount)")},
    10531053#endif /* __LP64__ */
    1054         {NULL, NULL, 0}
     1054    {NULL, NULL, 0}
    10551055};
    10561056
     
    10621062SndCh_CallCallBack(void *arg)
    10631063{
    1064         SndChannelObject *p = (SndChannelObject *)arg;
    1065         PyObject *args;
    1066         PyObject *res;
    1067         args = Py_BuildValue("(O(hhl))",
    1068                              p, p->ob_cmd.cmd, p->ob_cmd.param1, p->ob_cmd.param2);
    1069         res = PyEval_CallObject(p->ob_callback, args);
    1070         Py_DECREF(args);
    1071         if (res == NULL)
    1072                 return -1;
    1073         Py_DECREF(res);
    1074         return 0;
     1064    SndChannelObject *p = (SndChannelObject *)arg;
     1065    PyObject *args;
     1066    PyObject *res;
     1067    args = Py_BuildValue("(O(hhl))",
     1068                         p, p->ob_cmd.cmd, p->ob_cmd.param1, p->ob_cmd.param2);
     1069    res = PyEval_CallObject(p->ob_callback, args);
     1070    Py_DECREF(args);
     1071    if (res == NULL)
     1072        return -1;
     1073    Py_DECREF(res);
     1074    return 0;
    10751075}
    10761076
     
    10791079SndCh_UserRoutine(SndChannelPtr chan, SndCommand *cmd)
    10801080{
    1081         SndChannelObject *p = (SndChannelObject *)(chan->userInfo);
    1082         if (p->ob_callback != NULL) {
    1083                 long A5 = SetA5(p->ob_A5);
    1084                 p->ob_cmd = *cmd;
    1085                 Py_AddPendingCall(SndCh_CallCallBack, (void *)p);
    1086                 SetA5(A5);
    1087         }
     1081    SndChannelObject *p = (SndChannelObject *)(chan->userInfo);
     1082    if (p->ob_callback != NULL) {
     1083        long A5 = SetA5(p->ob_A5);
     1084        p->ob_cmd = *cmd;
     1085        Py_AddPendingCall(SndCh_CallCallBack, (void *)p);
     1086        SetA5(A5);
     1087    }
    10881088}
    10891089
     
    10921092SPB_CallCallBack(void *arg)
    10931093{
    1094         SPBObject *p = (SPBObject *)arg;
    1095         PyObject *args;
    1096         PyObject *res;
    1097 
    1098         if ( p->ob_thiscallback == 0 ) return 0;
    1099         args = Py_BuildValue("(O)", p);
    1100         res = PyEval_CallObject(p->ob_thiscallback, args);
    1101         p->ob_thiscallback = 0;
    1102         Py_DECREF(args);
    1103         if (res == NULL)
    1104                 return -1;
    1105         Py_DECREF(res);
    1106         return 0;
     1094    SPBObject *p = (SPBObject *)arg;
     1095    PyObject *args;
     1096    PyObject *res;
     1097
     1098    if ( p->ob_thiscallback == 0 ) return 0;
     1099    args = Py_BuildValue("(O)", p);
     1100    res = PyEval_CallObject(p->ob_thiscallback, args);
     1101    p->ob_thiscallback = 0;
     1102    Py_DECREF(args);
     1103    if (res == NULL)
     1104        return -1;
     1105    Py_DECREF(res);
     1106    return 0;
    11071107}
    11081108
     
    11101110SPB_completion(SPBPtr my_spb)
    11111111{
    1112         SPBObject *p = (SPBObject *)(my_spb->userLong);
    1113 
    1114         if (p && p->ob_completion) {
    1115                 long A5 = SetA5(p->ob_A5);
    1116                 p->ob_thiscallback = p->ob_completion;  /* Hope we cannot get two at the same time */
    1117                 Py_AddPendingCall(SPB_CallCallBack, (void *)p);
    1118                 SetA5(A5);
    1119         }
     1112    SPBObject *p = (SPBObject *)(my_spb->userLong);
     1113
     1114    if (p && p->ob_completion) {
     1115        long A5 = SetA5(p->ob_A5);
     1116        p->ob_thiscallback = p->ob_completion;  /* Hope we cannot get two at the same time */
     1117        Py_AddPendingCall(SPB_CallCallBack, (void *)p);
     1118        SetA5(A5);
     1119    }
    11201120}
    11211121#endif /* __LP64__ */
     
    11251125void init_Snd(void)
    11261126{
    1127         PyObject *m;
     1127    PyObject *m;
    11281128#ifndef __LP64__
    1129         PyObject *d;
     1129    PyObject *d;
    11301130#endif /* __LP64__ */
    11311131
     
    11341134
    11351135
    1136         m = Py_InitModule("_Snd", Snd_methods);
     1136    m = Py_InitModule("_Snd", Snd_methods);
    11371137#ifndef __LP64__
    1138         d = PyModule_GetDict(m);
    1139         Snd_Error = PyMac_GetOSErrException();
    1140         if (Snd_Error == NULL ||
    1141             PyDict_SetItemString(d, "Error", Snd_Error) != 0)
    1142                 return;
    1143         SndChannel_Type.ob_type = &PyType_Type;
    1144         if (PyType_Ready(&SndChannel_Type) < 0) return;
    1145         Py_INCREF(&SndChannel_Type);
    1146         PyModule_AddObject(m, "SndChannel", (PyObject *)&SndChannel_Type);
    1147         /* Backward-compatible name */
    1148         Py_INCREF(&SndChannel_Type);
    1149         PyModule_AddObject(m, "SndChannelType", (PyObject *)&SndChannel_Type);
    1150         SPB_Type.ob_type = &PyType_Type;
    1151         if (PyType_Ready(&SPB_Type) < 0) return;
    1152         Py_INCREF(&SPB_Type);
    1153         PyModule_AddObject(m, "SPB", (PyObject *)&SPB_Type);
    1154         /* Backward-compatible name */
    1155         Py_INCREF(&SPB_Type);
    1156         PyModule_AddObject(m, "SPBType", (PyObject *)&SPB_Type);
     1138    d = PyModule_GetDict(m);
     1139    Snd_Error = PyMac_GetOSErrException();
     1140    if (Snd_Error == NULL ||
     1141        PyDict_SetItemString(d, "Error", Snd_Error) != 0)
     1142        return;
     1143    SndChannel_Type.ob_type = &PyType_Type;
     1144    if (PyType_Ready(&SndChannel_Type) < 0) return;
     1145    Py_INCREF(&SndChannel_Type);
     1146    PyModule_AddObject(m, "SndChannel", (PyObject *)&SndChannel_Type);
     1147    /* Backward-compatible name */
     1148    Py_INCREF(&SndChannel_Type);
     1149    PyModule_AddObject(m, "SndChannelType", (PyObject *)&SndChannel_Type);
     1150    SPB_Type.ob_type = &PyType_Type;
     1151    if (PyType_Ready(&SPB_Type) < 0) return;
     1152    Py_INCREF(&SPB_Type);
     1153#if 0
     1154    PyModule_AddObject(m, "SPB", (PyObject *)&SPB_Type);
     1155#endif
     1156    /* Backward-compatible name */
     1157    Py_INCREF(&SPB_Type);
     1158    PyModule_AddObject(m, "SPBType", (PyObject *)&SPB_Type);
    11571159#endif /* __LP64__ */
    11581160}
Note: See TracChangeset for help on using the changeset viewer.