Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -310,9 +310,10 @@ static PyObject* Pyaubio_source_iter_next(Py_source *self) { · 309 unmodified lines | ||
| 310 | 310 | PyObject *vec = PyTuple_GetItem(done, 0); |
| 311 | 311 | return vec; |
| 312 | 312 | } else if (PyLong_AsLong(size) > 0) { |
| 313 | − // short read | |
| 313 | + // short read, return a shorter array | |
| 314 | 314 | PyArrayObject *shortread = (PyArrayObject*)PyTuple_GetItem(done, 0); |
| 315 | 315 | PyArray_Dims newdims; |
| 316 | + PyObject *reshaped; | |
| 316 | 317 | newdims.len = PyArray_NDIM(shortread); |
| 317 | 318 | newdims.ptr = PyArray_DIMS(shortread); |
| 318 | 319 | // mono or multiple channels? |
| @@ -321,8 +322,9 @@ static PyObject* Pyaubio_source_iter_next(Py_source *self) { · 2 unmodified lines | ||
| 321 | 322 | } else { |
| 322 | 323 | newdims.ptr[1] = PyLong_AsLong(size); |
| 323 | 324 | } |
| 324 | − PyArray_Resize(shortread, &newdims, 1, NPY_ANYORDER); | |
| 325 | − return (PyObject*)shortread; | |
| 325 | + reshaped = PyArray_Newshape(shortread, &newdims, NPY_CORDER); | |
| 326 | + Py_DECREF(shortread); | |
| 327 | + return reshaped; | |
| 326 | 328 | } else { |
| 327 | 329 | PyErr_SetNone(PyExc_StopIteration); |
| 328 | 330 | return NULL; |