mozilla / cubeb-rs

ISC License
61 stars 19 forks source link

Is it possible to relax the data callback of Stream to not be Sync? #68

Open eyeplum opened 2 years ago

eyeplum commented 2 years ago

Hi there,

I was wondering whether it's possible to relax the constraints of the data callback closure of Stream to not be Sync.

What I'm trying to do at the moment is to prepare audio processors on the main thread before the audio stream starts, then move them into the audio stream's data callback so that they can be used to process audio input/output. With the data callback closure constrained to Sync, I was only able to use structures that are Sync themselves in the audio processors. (For example, it won't work for the resamplers from https://github.com/HEnquist/rubato).

I took a bit closer look into the mechanism of the audio stream, and I think it might be ok to relax the constraint to only require Send for the data callback - at least for the limited use cases I can think of, though I might be missing something.

Keen to hear your thoughts. Cheers.

kinetiknz commented 2 years ago

Thanks for filing the issue and apologies for the delay in responding. As far as I understand, it appears the Sync constraint is overly restrictive and unnecessary given the existing restrictions in cubeb regarding when/where callbacks may be run. I've pushed a PR to drop Sync from the stream's user callbacks.