Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
eyeplum opened this issue Apr 12, 2022 · 1 comment · May be fixed by #69
Open

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

eyeplum opened this issue Apr 12, 2022 · 1 comment · May be fixed by #69

Comments

@eyeplum
Copy link
Contributor

eyeplum commented Apr 12, 2022

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 added a commit to kinetiknz/cubeb-rs that referenced this issue Apr 27, 2022
…ent.

A cubeb backend may run user callbacks on any thread it chooses to, but
must never run the same user callback on multiple threads concurrently.
If I understand correctly, the `Send` constraint is sufficient to
represent the appropriate constraint for this, making `Sync`
unnecessary.

Fixes mozilla#68
@kinetiknz
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants