~ubuntu-branches/ubuntu/saucy/python-pyo/saucy-proposed

« back to all changes in this revision

Viewing changes to src/objects/sfplayermodule.c

  • Committer: Package Import Robot
  • Author(s): Tiago Bortoletto Vaz
  • Date: 2012-07-03 23:45:41 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120703234541-jh5jg00lvljnwq8m
Tags: 0.6.2-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
    MYFLT buffer2[self->sndChnls][buflen];
95
95
    
96
96
    if (sp > 0) { /* forward reading */
 
97
        if (self->pointerPos >= self->sndSize) {
 
98
            self->pointerPos -= self->sndSize - self->startPos;
 
99
            if (self->loop == 0) {
 
100
                PyObject_CallMethod((PyObject *)self, "stop", NULL);
 
101
                for (i=0; i<(self->bufsize * self->sndChnls); i++) {
 
102
                    self->samplesBuffer[i] = 0.0;
 
103
                }    
 
104
                for (i=0; i<self->bufsize; i++) {
 
105
                    self->trigsBuffer[i] = 0.0;
 
106
                }
 
107
                return;
 
108
            }
 
109
        }        
97
110
        index = (int)self->pointerPos;
98
111
        sf_seek(self->sf, index, SEEK_SET); /* sets position pointer in the file */
99
112
 
136
149
            }    
137
150
            self->pointerPos += delta;
138
151
        }
139
 
 
140
 
        if (self->pointerPos >= self->sndSize) {
 
152
        if (self->pointerPos >= self->sndSize)
141
153
            self->trigsBuffer[0] = 1.0;
142
 
            self->pointerPos -= self->sndSize - self->startPos;
143
 
            if (self->loop == 0) {
144
 
                PyObject_CallMethod((PyObject *)self, "stop", NULL);
145
 
                for (i=0; i<(self->bufsize * self->sndChnls); i++) {
146
 
                    self->samplesBuffer[i] = 0.0;
147
 
                }    
148
 
            }
149
 
        }
150
154
    }
151
155
    else if (sp < 0){ /* backward reading */
152
156
        startPos = self->startPos;
154
158
            startPos = self->sndSize - 1;
155
159
        if (self->pointerPos == 0.0)
156
160
            self->pointerPos = self->sndSize - 1;
 
161
 
 
162
        if (self->pointerPos <= 0) {
 
163
            self->pointerPos += startPos;
 
164
            if (self->loop == 0) {
 
165
                PyObject_CallMethod((PyObject *)self, "stop", NULL);
 
166
                for (i=0; i<(self->bufsize * self->sndChnls); i++) {
 
167
                    self->samplesBuffer[i] = 0.0;
 
168
                }    
 
169
                for (i=0; i<self->bufsize; i++) {
 
170
                    self->trigsBuffer[i] = 0.0;
 
171
                }
 
172
                return;
 
173
            }
 
174
        }
 
175
        
157
176
        index = (int)self->pointerPos + 1;
158
177
        
159
178
        /* fill a buffer with enough samples to satisfy speed reading */
221
240
                self->trigsBuffer[0] = 1.0;
222
241
            else
223
242
                self->init = 0;
224
 
            self->pointerPos += startPos;
225
 
            if (self->loop == 0) {
226
 
                PyObject_CallMethod((PyObject *)self, "stop", NULL);
227
 
                for (i=0; i<(self->bufsize * self->sndChnls); i++) {
228
 
                    self->samplesBuffer[i] = 0.0;
229
 
                }    
230
 
            }
231
243
        }
232
244
    }
233
245
    else { /* speed == 0.0 */
272
284
static void
273
285
SfPlayer_dealloc(SfPlayer* self)
274
286
{
275
 
    sf_close(self->sf);
 
287
    pyo_DEALLOC
 
288
    if (self->sf != NULL)
 
289
        sf_close(self->sf);
276
290
    free(self->trigsBuffer);
277
 
    free(self->data);
 
291
    free(self->samplesBuffer);
278
292
    SfPlayer_clear(self);
279
293
    self->ob_type->tp_free((PyObject*)self);
280
294
}
281
295
 
282
 
static PyObject * SfPlayer_deleteStream(SfPlayer *self) { DELETE_STREAM };
283
 
 
284
296
static PyObject *
285
297
SfPlayer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
286
298
{
287
299
    int i;
 
300
    MYFLT offset = 0.;
 
301
    PyObject *speedtmp=NULL;
288
302
    SfPlayer *self;
289
303
    self = (SfPlayer *)type->tp_alloc(type, 0);
290
304
    
297
311
    INIT_OBJECT_COMMON
298
312
    Stream_setFunctionPtr(self->stream, SfPlayer_compute_next_data_frame);
299
313
    self->mode_func_ptr = SfPlayer_setProcMode;
300
 
    
301
 
    return (PyObject *)self;
302
 
}
303
314
 
304
 
static int
305
 
SfPlayer_init(SfPlayer *self, PyObject *args, PyObject *kwds)
306
 
{
307
 
    int i;
308
 
    MYFLT offset = 0.;
309
 
    PyObject *speedtmp=NULL;
310
 
    
311
315
    static char *kwlist[] = {"path", "speed", "loop", "offset", "interp", NULL};
312
316
    
313
317
    if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_S__OIFI, kwlist, &self->path, &speedtmp, &self->loop, &offset, &self->interp))
314
 
        return -1; 
 
318
        Py_RETURN_NONE; 
315
319
    
316
320
    if (speedtmp) {
317
321
        PyObject_CallMethod((PyObject *)self, "setSpeed", "O", speedtmp);
318
322
    }
319
323
 
320
 
    Py_INCREF(self->stream);
321
324
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
322
325
    
323
326
    (*self->mode_func_ptr)(self);
352
355
    
353
356
    self->pointerPos = self->startPos;
354
357
    
355
 
    Py_INCREF(self);
356
 
    return 0;
 
358
    return (PyObject *)self;
357
359
}
358
360
 
359
361
static PyObject * SfPlayer_getServer(SfPlayer* self) { GET_SERVER };
516
518
{"getServer", (PyCFunction)SfPlayer_getServer, METH_NOARGS, "Returns server object."},
517
519
{"_getStream", (PyCFunction)SfPlayer_getStream, METH_NOARGS, "Returns stream object."},
518
520
{"_getTriggerStream", (PyCFunction)SfPlayer_getTriggerStream, METH_NOARGS, "Returns trigger stream object."},
519
 
{"deleteStream", (PyCFunction)SfPlayer_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
520
521
{"play", (PyCFunction)SfPlayer_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
521
522
{"out", (PyCFunction)SfPlayer_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
522
523
{"stop", (PyCFunction)SfPlayer_stop, METH_NOARGS, "Stops computing."},
565
566
0,                         /* tp_descr_get */
566
567
0,                         /* tp_descr_set */
567
568
0,                         /* tp_dictoffset */
568
 
(initproc)SfPlayer_init,      /* tp_init */
 
569
0,      /* tp_init */
569
570
0,                         /* tp_alloc */
570
571
SfPlayer_new,                 /* tp_new */
571
572
};
659
660
static void
660
661
SfPlay_dealloc(SfPlay* self)
661
662
{
662
 
    free(self->data);
 
663
    pyo_DEALLOC
663
664
    SfPlay_clear(self);
664
665
    self->ob_type->tp_free((PyObject*)self);
665
666
}
666
667
 
667
 
static PyObject * SfPlay_deleteStream(SfPlay *self) { DELETE_STREAM };
668
 
 
669
668
static PyObject *
670
669
SfPlay_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
671
670
{
672
671
    int i;
 
672
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
673
673
    SfPlay *self;
674
674
    self = (SfPlay *)type->tp_alloc(type, 0);
675
675
    
680
680
    INIT_OBJECT_COMMON
681
681
    Stream_setFunctionPtr(self->stream, SfPlay_compute_next_data_frame);
682
682
    self->mode_func_ptr = SfPlay_setProcMode;
683
 
    
684
 
    return (PyObject *)self;
685
 
}
686
683
 
687
 
static int
688
 
SfPlay_init(SfPlay *self, PyObject *args, PyObject *kwds)
689
 
{
690
 
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
691
 
    
692
684
    static char *kwlist[] = {"mainPlayer", "chnl", "mul", "add", NULL};
693
685
    
694
686
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
695
 
        return -1; 
 
687
        Py_RETURN_NONE; 
696
688
    
697
689
    Py_XDECREF(self->mainPlayer);
698
690
    Py_INCREF(maintmp);
706
698
        PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
707
699
    }
708
700
    
709
 
    Py_INCREF(self->stream);
710
701
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
711
702
    
712
703
    (*self->mode_func_ptr)(self);
713
 
        
714
 
    Py_INCREF(self);
715
 
    return 0;
 
704
    
 
705
    return (PyObject *)self;
716
706
}
717
707
 
718
708
static PyObject * SfPlay_getServer(SfPlay* self) { GET_SERVER };
746
736
static PyMethodDef SfPlay_methods[] = {
747
737
{"getServer", (PyCFunction)SfPlay_getServer, METH_NOARGS, "Returns server object."},
748
738
{"_getStream", (PyCFunction)SfPlay_getStream, METH_NOARGS, "Returns stream object."},
749
 
{"deleteStream", (PyCFunction)SfPlay_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
750
739
{"play", (PyCFunction)SfPlay_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
751
740
{"out", (PyCFunction)SfPlay_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
752
741
{"stop", (PyCFunction)SfPlay_stop, METH_NOARGS, "Stops computing."},
836
825
0,                         /* tp_descr_get */
837
826
0,                         /* tp_descr_set */
838
827
0,                         /* tp_dictoffset */
839
 
(initproc)SfPlay_init,      /* tp_init */
 
828
0,      /* tp_init */
840
829
0,                         /* tp_alloc */
841
830
SfPlay_new,                 /* tp_new */
842
831
};
1104
1093
static void
1105
1094
SfMarkerShuffler_dealloc(SfMarkerShuffler* self)
1106
1095
{
1107
 
    sf_close(self->sf);
 
1096
    pyo_DEALLOC
 
1097
    if (self->sf != NULL)
 
1098
        sf_close(self->sf);
1108
1099
    free(self->samplesBuffer);
1109
1100
    free(self->markers);
1110
 
    free(self->data);
1111
1101
    SfMarkerShuffler_clear(self);
1112
1102
    self->ob_type->tp_free((PyObject*)self);
1113
1103
}
1114
1104
 
1115
 
static PyObject * SfMarkerShuffler_deleteStream(SfMarkerShuffler *self) { DELETE_STREAM };
1116
 
 
1117
1105
static PyObject *
1118
1106
SfMarkerShuffler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1119
1107
{
1120
1108
    int i;
 
1109
    PyObject *speedtmp=NULL, *markerstmp=NULL;
1121
1110
    SfMarkerShuffler *self;
1122
1111
    self = (SfMarkerShuffler *)type->tp_alloc(type, 0);
1123
1112
    
1130
1119
    INIT_OBJECT_COMMON
1131
1120
    Stream_setFunctionPtr(self->stream, SfMarkerShuffler_compute_next_data_frame);
1132
1121
    self->mode_func_ptr = SfMarkerShuffler_setProcMode;
1133
 
    
1134
 
    return (PyObject *)self;
1135
 
}
1136
1122
 
1137
 
static int
1138
 
SfMarkerShuffler_init(SfMarkerShuffler *self, PyObject *args, PyObject *kwds)
1139
 
{
1140
 
    PyObject *speedtmp=NULL, *markerstmp=NULL;
1141
 
    
1142
1123
    static char *kwlist[] = {"path", "markers", "speed", "interp", NULL};
1143
1124
    
1144
1125
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "sO|Oi", kwlist, &self->path, &markerstmp, &speedtmp, &self->interp))
1145
 
        return -1; 
 
1126
        Py_RETURN_NONE;
1146
1127
 
1147
1128
    if (speedtmp) {
1148
1129
        PyObject_CallMethod((PyObject *)self, "setSpeed", "O", speedtmp);
1149
1130
    }
1150
1131
    
1151
 
    Py_INCREF(self->stream);
1152
1132
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
1153
1133
    
1154
1134
    (*self->mode_func_ptr)(self);
1170
1150
    if (self->sf == NULL)
1171
1151
    {
1172
1152
        printf("Failed to open the file.\n");
 
1153
        Py_RETURN_NONE;
1173
1154
    }
1174
1155
    self->sndSize = self->info.frames;
1175
1156
    self->sndSr = self->info.samplerate;
1182
1163
    self->samplesBuffer = (MYFLT *)realloc(self->samplesBuffer, self->bufsize * self->sndChnls * sizeof(MYFLT));
1183
1164
 
1184
1165
    Server_generateSeed((Server *)self->server, SFMARKERSHUFFLER_ID);
1185
 
 
1186
 
    Py_INCREF(self);
1187
 
    return 0;
 
1166
    
 
1167
    return (PyObject *)self;
1188
1168
}
1189
1169
 
1190
1170
static PyObject * SfMarkerShuffler_getServer(SfMarkerShuffler* self) { GET_SERVER };
1273
1253
static PyMethodDef SfMarkerShuffler_methods[] = {
1274
1254
{"getServer", (PyCFunction)SfMarkerShuffler_getServer, METH_NOARGS, "Returns server object."},
1275
1255
{"_getStream", (PyCFunction)SfMarkerShuffler_getStream, METH_NOARGS, "Returns stream object."},
1276
 
{"deleteStream", (PyCFunction)SfMarkerShuffler_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
1277
1256
{"play", (PyCFunction)SfMarkerShuffler_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
1278
1257
{"out", (PyCFunction)SfMarkerShuffler_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
1279
1258
{"stop", (PyCFunction)SfMarkerShuffler_stop, METH_NOARGS, "Stops computing."},
1319
1298
0,                         /* tp_descr_get */
1320
1299
0,                         /* tp_descr_set */
1321
1300
0,                         /* tp_dictoffset */
1322
 
(initproc)SfMarkerShuffler_init,      /* tp_init */
 
1301
0,      /* tp_init */
1323
1302
0,                         /* tp_alloc */
1324
1303
SfMarkerShuffler_new,                 /* tp_new */
1325
1304
};
1413
1392
static void
1414
1393
SfMarkerShuffle_dealloc(SfMarkerShuffle* self)
1415
1394
{
1416
 
    free(self->data);
 
1395
    pyo_DEALLOC
1417
1396
    SfMarkerShuffle_clear(self);
1418
1397
    self->ob_type->tp_free((PyObject*)self);
1419
1398
}
1420
1399
 
1421
 
static PyObject * SfMarkerShuffle_deleteStream(SfMarkerShuffle *self) { DELETE_STREAM };
1422
 
 
1423
1400
static PyObject *
1424
1401
SfMarkerShuffle_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1425
1402
{
1426
1403
    int i;
 
1404
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
1427
1405
    SfMarkerShuffle *self;
1428
1406
    self = (SfMarkerShuffle *)type->tp_alloc(type, 0);
1429
1407
    
1434
1412
    INIT_OBJECT_COMMON
1435
1413
    Stream_setFunctionPtr(self->stream, SfMarkerShuffle_compute_next_data_frame);
1436
1414
    self->mode_func_ptr = SfMarkerShuffle_setProcMode;
1437
 
    
1438
 
    return (PyObject *)self;
1439
 
}
1440
1415
 
1441
 
static int
1442
 
SfMarkerShuffle_init(SfMarkerShuffle *self, PyObject *args, PyObject *kwds)
1443
 
{
1444
 
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
1445
 
    
1446
1416
    static char *kwlist[] = {"mainPlayer", "chnl", "mul", "add", NULL};
1447
1417
    
1448
1418
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
1449
 
        return -1; 
 
1419
        Py_RETURN_NONE;
1450
1420
 
1451
1421
    Py_XDECREF(self->mainPlayer);
1452
1422
    Py_INCREF(maintmp);
1460
1430
        PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
1461
1431
    }
1462
1432
    
1463
 
    Py_INCREF(self->stream);
1464
1433
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
1465
1434
    
1466
1435
    (*self->mode_func_ptr)(self);
1467
 
        
1468
 
    Py_INCREF(self);
1469
 
    return 0;
 
1436
    
 
1437
    return (PyObject *)self;
1470
1438
}
1471
1439
 
1472
1440
static PyObject * SfMarkerShuffle_getServer(SfMarkerShuffle* self) { GET_SERVER };
1500
1468
static PyMethodDef SfMarkerShuffle_methods[] = {
1501
1469
{"getServer", (PyCFunction)SfMarkerShuffle_getServer, METH_NOARGS, "Returns server object."},
1502
1470
{"_getStream", (PyCFunction)SfMarkerShuffle_getStream, METH_NOARGS, "Returns stream object."},
1503
 
{"deleteStream", (PyCFunction)SfMarkerShuffle_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
1504
1471
{"play", (PyCFunction)SfMarkerShuffle_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
1505
1472
{"out", (PyCFunction)SfMarkerShuffle_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
1506
1473
{"stop", (PyCFunction)SfMarkerShuffle_stop, METH_NOARGS, "Stops computing."},
1590
1557
0,                         /* tp_descr_get */
1591
1558
0,                         /* tp_descr_set */
1592
1559
0,                         /* tp_dictoffset */
1593
 
(initproc)SfMarkerShuffle_init,      /* tp_init */
 
1560
0,      /* tp_init */
1594
1561
0,                         /* tp_alloc */
1595
1562
SfMarkerShuffle_new,                 /* tp_new */
1596
1563
};
1872
1839
static void
1873
1840
SfMarkerLooper_dealloc(SfMarkerLooper* self)
1874
1841
{
1875
 
    sf_close(self->sf);
 
1842
    pyo_DEALLOC
 
1843
    if (self->sf != NULL)
 
1844
        sf_close(self->sf);
1876
1845
    free(self->samplesBuffer);
1877
1846
    free(self->markers);
1878
 
    free(self->data);
1879
1847
    SfMarkerLooper_clear(self);
1880
1848
    self->ob_type->tp_free((PyObject*)self);
1881
1849
}
1882
1850
 
1883
 
static PyObject * SfMarkerLooper_deleteStream(SfMarkerLooper *self) { DELETE_STREAM };
1884
 
 
1885
1851
static PyObject *
1886
1852
SfMarkerLooper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1887
1853
{
1888
1854
    int i;
 
1855
    PyObject *speedtmp=NULL, *marktmp=NULL, *markerstmp=NULL;
1889
1856
    SfMarkerLooper *self;
1890
1857
    self = (SfMarkerLooper *)type->tp_alloc(type, 0);
1891
1858
    
1902
1869
    INIT_OBJECT_COMMON
1903
1870
    Stream_setFunctionPtr(self->stream, SfMarkerLooper_compute_next_data_frame);
1904
1871
    self->mode_func_ptr = SfMarkerLooper_setProcMode;
1905
 
    
1906
 
    return (PyObject *)self;
1907
 
}
1908
1872
 
1909
 
static int
1910
 
SfMarkerLooper_init(SfMarkerLooper *self, PyObject *args, PyObject *kwds)
1911
 
{
1912
 
    PyObject *speedtmp=NULL, *marktmp=NULL, *markerstmp=NULL;
1913
 
    
1914
1873
    static char *kwlist[] = {"path", "markers", "speed", "mark", "interp", NULL};
1915
1874
    
1916
1875
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "sO|OOi", kwlist, &self->path, &markerstmp, &speedtmp, &marktmp, &self->interp))
1917
 
        return -1; 
 
1876
        Py_RETURN_NONE;
1918
1877
    
1919
1878
    if (speedtmp) {
1920
1879
        PyObject_CallMethod((PyObject *)self, "setSpeed", "O", speedtmp);
1924
1883
        PyObject_CallMethod((PyObject *)self, "setMark", "O", marktmp);
1925
1884
    }
1926
1885
    
1927
 
    Py_INCREF(self->stream);
1928
1886
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
1929
1887
    
1930
1888
    (*self->mode_func_ptr)(self);
1946
1904
    if (self->sf == NULL)
1947
1905
    {
1948
1906
        printf("Failed to open the file.\n");
 
1907
        Py_RETURN_NONE;
1949
1908
    }
1950
1909
    self->sndSize = self->info.frames;
1951
1910
    self->sndSr = self->info.samplerate;
1959
1918
    
1960
1919
    Server_generateSeed((Server *)self->server, SFMARKERLOOPER_ID);
1961
1920
    
1962
 
    Py_INCREF(self);
1963
 
    return 0;
 
1921
    return (PyObject *)self;
1964
1922
}
1965
1923
 
1966
1924
static PyObject * SfMarkerLooper_getServer(SfMarkerLooper* self) { GET_SERVER };
2080
2038
static PyMethodDef SfMarkerLooper_methods[] = {
2081
2039
    {"getServer", (PyCFunction)SfMarkerLooper_getServer, METH_NOARGS, "Returns server object."},
2082
2040
    {"_getStream", (PyCFunction)SfMarkerLooper_getStream, METH_NOARGS, "Returns stream object."},
2083
 
    {"deleteStream", (PyCFunction)SfMarkerLooper_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
2084
2041
    {"play", (PyCFunction)SfMarkerLooper_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
2085
2042
    {"out", (PyCFunction)SfMarkerLooper_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
2086
2043
    {"stop", (PyCFunction)SfMarkerLooper_stop, METH_NOARGS, "Stops computing."},
2127
2084
    0,                         /* tp_descr_get */
2128
2085
    0,                         /* tp_descr_set */
2129
2086
    0,                         /* tp_dictoffset */
2130
 
    (initproc)SfMarkerLooper_init,      /* tp_init */
 
2087
    0,      /* tp_init */
2131
2088
    0,                         /* tp_alloc */
2132
2089
    SfMarkerLooper_new,                 /* tp_new */
2133
2090
};
2221
2178
static void
2222
2179
SfMarkerLoop_dealloc(SfMarkerLoop* self)
2223
2180
{
2224
 
    free(self->data);
 
2181
    pyo_DEALLOC
2225
2182
    SfMarkerLoop_clear(self);
2226
2183
    self->ob_type->tp_free((PyObject*)self);
2227
2184
}
2228
2185
 
2229
 
static PyObject * SfMarkerLoop_deleteStream(SfMarkerLoop *self) { DELETE_STREAM };
2230
 
 
2231
2186
static PyObject *
2232
2187
SfMarkerLoop_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
2233
2188
{
2234
2189
    int i;
 
2190
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
2235
2191
    SfMarkerLoop *self;
2236
2192
    self = (SfMarkerLoop *)type->tp_alloc(type, 0);
2237
2193
    
2242
2198
    INIT_OBJECT_COMMON
2243
2199
    Stream_setFunctionPtr(self->stream, SfMarkerLoop_compute_next_data_frame);
2244
2200
    self->mode_func_ptr = SfMarkerLoop_setProcMode;
2245
 
    
2246
 
    return (PyObject *)self;
2247
 
}
2248
2201
 
2249
 
static int
2250
 
SfMarkerLoop_init(SfMarkerLoop *self, PyObject *args, PyObject *kwds)
2251
 
{
2252
 
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
2253
 
    
2254
2202
    static char *kwlist[] = {"mainPlayer", "chnl", "mul", "add", NULL};
2255
2203
    
2256
2204
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
2257
 
        return -1; 
 
2205
        Py_RETURN_NONE;
2258
2206
    
2259
2207
    Py_XDECREF(self->mainPlayer);
2260
2208
    Py_INCREF(maintmp);
2268
2216
        PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
2269
2217
    }
2270
2218
    
2271
 
    Py_INCREF(self->stream);
2272
2219
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
2273
2220
    
2274
2221
    (*self->mode_func_ptr)(self);
2275
 
        
2276
 
    Py_INCREF(self);
2277
 
    return 0;
 
2222
    
 
2223
    return (PyObject *)self;
2278
2224
}
2279
2225
 
2280
2226
static PyObject * SfMarkerLoop_getServer(SfMarkerLoop* self) { GET_SERVER };
2308
2254
static PyMethodDef SfMarkerLoop_methods[] = {
2309
2255
    {"getServer", (PyCFunction)SfMarkerLoop_getServer, METH_NOARGS, "Returns server object."},
2310
2256
    {"_getStream", (PyCFunction)SfMarkerLoop_getStream, METH_NOARGS, "Returns stream object."},
2311
 
    {"deleteStream", (PyCFunction)SfMarkerLoop_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
2312
2257
    {"play", (PyCFunction)SfMarkerLoop_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
2313
2258
    {"out", (PyCFunction)SfMarkerLoop_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
2314
2259
    {"stop", (PyCFunction)SfMarkerLoop_stop, METH_NOARGS, "Stops computing."},
2398
2343
    0,                         /* tp_descr_get */
2399
2344
    0,                         /* tp_descr_set */
2400
2345
    0,                         /* tp_dictoffset */
2401
 
    (initproc)SfMarkerLoop_init,      /* tp_init */
 
2346
    0,      /* tp_init */
2402
2347
    0,                         /* tp_alloc */
2403
2348
    SfMarkerLoop_new,                 /* tp_new */
2404
2349
};