Skip to content

Commit 50ac765

Browse files
committed
fixup! Release GIL while resampling
attempt to fix exception handling on windows, not tested
1 parent e2ed8bd commit 50ac765

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

src/samplerate.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,12 @@ class CallbackResampler {
297297
if (_state == nullptr) _create();
298298

299299
// read from the callback
300-
size_t output_frames_gen = [&]() {
300+
size_t output_frames_gen = 0;
301+
{
301302
py::gil_scoped_release release;
302-
return src_callback_read(_state, _ratio, (long)frames,
303-
static_cast<float *>(outbuf.ptr));
304-
}();
303+
output_frames_gen = src_callback_read(_state, _ratio, (long)frames,
304+
static_cast<float *>(outbuf.ptr));
305+
}
305306

306307
// check error status
307308
if (output_frames_gen == 0) {
@@ -346,13 +347,14 @@ long the_callback_func(void *cb_data, float **data) {
346347
CallbackResampler *cb = static_cast<CallbackResampler *>(cb_data);
347348
int cb_channels = cb->get_channels();
348349

349-
py::gil_scoped_acquire acquire;
350-
351-
// get the data as a numpy array
352-
auto input = cb->callback();
350+
py::buffer_info inbuf;
351+
{
352+
py::gil_scoped_acquire acquire;
353353

354-
// accessors for the arrays
355-
py::buffer_info inbuf = input.request();
354+
// get the data as a numpy array
355+
auto input = cb->callback();
356+
inbuf = input.request();
357+
}
356358

357359
// end of stream is signaled by a None, which is cast to a ndarray with ndim
358360
// == 0

0 commit comments

Comments
 (0)