wavy icon indicating copy to clipboard operation
wavy copied to clipboard

Implement Send for all 4 structs

Open Mikadore opened this issue 4 years ago • 3 comments

Is your feature request related to a problem? Please describe. It's really painful to work with e.g. tokio::tasks with non-send types.

Describe the solution you'd like Implement send for the 4 relevant structs:

unsafe impl Send for Microphone {}
unsafe impl Send for MicrophoneStream {}
unsafe impl Send for Speakers {}
unsafe impl Send for SpeakersSink {}

Describe alternatives you've considered Wrapping the structs in user code, very unergonomic.

Additional context This should be safe without any other changes.

Mikadore avatar Jul 04 '21 19:07 Mikadore

@Mikadore thanks! This seems like a good change.

AldaronLau avatar Jul 04 '21 19:07 AldaronLau

Any progress on this? I've been trying to use wavy with bevy which also has a thread pool executor and ran into the same issue.

polygon avatar Feb 26 '22 14:02 polygon

@polygon Looking at the data within each struct, I don't think I can do an unsafe impl Send for _ {} and still be sound. The ALSA documentation states it's thread-safe when compiled with the proper flag, but I want wavy to still be sound when ALSA is compiled without that flag. I've been working on a new version for about a year interspersed with work in many other projects, and hoping to release it soon. Future versions shouldn't take as long.

My current idea is to use a separate thread to run ALSA calls on and send data over a channel. I thought about using flume for this, but I don't want to pull in the https://crates.io/crates/pin-project dependency. I'll make sure to get this in when the new version does come out. In the meantime, if you need a workaround, you should be able to solve the problem the same way - by making an abstraction layer over wavy using channels.

AldaronLau avatar Feb 26 '22 17:02 AldaronLau