RustAudio / cpal

Cross-platform audio I/O library in pure Rust
Apache License 2.0
2.73k stars 363 forks source link

Recommended way to init non-Send data that's needed in audio callback? #404

Open Boscop opened 4 years ago

Boscop commented 4 years ago

What's the recommended way to init non-Send data that's needed in the audio callback? I.e. initializing it in the audio thread but only once, before the loop starts running. And without the overhead of thread-local storage. This init code is also taking a long time (loading a bunch of VST plugins), and I don't want to block the audio callback on the first call.

ishitatsuyuki commented 4 years ago

Assuming the newer managed-thread API, this kind of initialization is possible for Windows and Linux, but I think it's probably not possible on Apple platforms.

Ralith commented 4 years ago

Perhaps on Apple it could be emulated with once_cell?

Boscop commented 4 years ago

@ishitatsuyuki Where is the newer API available? On master? I'm using the crates.io version.

ishitatsuyuki commented 4 years ago

Yes, it’s on master.