History

python/ext/py-source.c: use new_py_foo here too

Paul Brossier committed 10 years ago

Commit 1ee5e211 parent ede5d381 file · +21 −32Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/ext/py-source.c+21−32
@@ -9,8 +9,10 @@ typedef struct · 8 unmodified lines
99 uint_t channels;
1010 uint_t hop_size;
1111 uint_t duration;
12− fvec_t *read_to;
13− fmat_t *mread_to;
12+ PyObject *read_to;
13+ fvec_t c_read_to;
14+ PyObject *mread_to;
15+ fmat_t c_mread_to;
1416 } Py_source;
1517
1618 static char Py_source_doc[] = ""
@@ -149,8 +151,8 @@ Py_source_init (Py_source * self, PyObject * args, PyObject * kwds) · 132 unmodified lines
149151 }
150152 self->duration = aubio_source_get_duration ( self->o );
151153
152− self->read_to = new_fvec(self->hop_size);
153− self->mread_to = new_fmat (self->channels, self->hop_size);
154+ self->read_to = new_py_fvec(self->hop_size);
155+ self->mread_to = new_py_fmat(self->channels, self->hop_size);
154156
155157 return 0;
156158 }
@@ -159,8 +161,9 @@ static void · 2 unmodified lines
159161 Py_source_del (Py_source *self, PyObject *unused)
160162 {
161163 del_aubio_source(self->o);
162− del_fvec(self->read_to);
163− del_fmat(self->mread_to);
164+ //del_fvec(self->read_to);
165+ Py_XDECREF(self->read_to);
166+ Py_XDECREF(self->mread_to);
164167 Py_TYPE(self)->tp_free((PyObject *) self);
165168 }
166169
@@ -169,25 +172,18 @@ Py_source_del (Py_source *self, PyObject *unused) · 2 unmodified lines
169172 static PyObject *
170173 Py_source_do(Py_source * self, PyObject * args)
171174 {
172−
173−
174− /* output vectors prototypes */
175175 uint_t read;
176−
177−
178−
179−
180−
181−
182− /* creating output read_to as a new_fvec of length self->hop_size */
183176 read = 0;
184177
185−
178+ Py_INCREF(self->read_to);
179+ if (!PyAubio_ArrayToCFvec(self->read_to, &(self->c_read_to))) {
180+ return NULL;
181+ }
186182 /* compute _do function */
187− aubio_source_do (self->o, self->read_to, &read);
183+ aubio_source_do (self->o, &(self->c_read_to), &read);
188184
189185 PyObject *outputs = PyTuple_New(2);
190− PyTuple_SetItem( outputs, 0, (PyObject *)PyAubio_CFvecToArray (self->read_to) );
186+ PyTuple_SetItem( outputs, 0, self->read_to );
191187 PyTuple_SetItem( outputs, 1, (PyObject *)PyLong_FromLong(read));
192188 return outputs;
193189 }
@@ -196,25 +192,18 @@ Py_source_do(Py_source * self, PyObject * args) · 2 unmodified lines
196192 static PyObject *
197193 Py_source_do_multi(Py_source * self, PyObject * args)
198194 {
199−
200−
201− /* output vectors prototypes */
202195 uint_t read;
203−
204−
205−
206−
207−
208−
209− /* creating output mread_to as a new_fvec of length self->hop_size */
210196 read = 0;
211197
212−
198+ Py_INCREF(self->mread_to);
199+ if (!PyAubio_ArrayToCFmat(self->mread_to, &(self->c_mread_to))) {
200+ return NULL;
201+ }
213202 /* compute _do function */
214− aubio_source_do_multi (self->o, self->mread_to, &read);
203+ aubio_source_do_multi (self->o, &(self->c_mread_to), &read);
215204
216205 PyObject *outputs = PyTuple_New(2);
217− PyTuple_SetItem( outputs, 0, (PyObject *)PyAubio_CFmatToArray (self->mread_to));
206+ PyTuple_SetItem( outputs, 0, self->mread_to);
218207 PyTuple_SetItem( outputs, 1, (PyObject *)PyLong_FromLong(read));
219208 return outputs;
220209 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t