@@ -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