Hi,

I'm curious about the possibilities to use Rust for programming real-time audio stuff. Usually one has one small task that runs in high priority, and everything else is handled by a main task.

I have a few questions related to this:

1) The real-time audio task should never block when not expected to, so stuff like malloc() is forbidden. Is there a way I can mark a section/module/crate/something of the code as "real time safe", and thus get warnings or errors in case I try to do something that would require heap allocation or other blocking stuff? The rest of the code (i e the main task) should still be able to use the entire libstd.

2) The real-time audio thread might want to receive messages as well. Are channels suitable for this, or are the complications that cause things to be problematic here?

3) When using e g ALSA as your audio API, you usually block waiting on a file descriptor. I was wondering if one would be able to select between ALSA's fd and the channel, thus the blocking part of the real-time thread would look something like:

select! (
    command = rx.recv() => handle_command_from_main_thread(command),
    () = alsa.wait_for_avail() => alsa.write_more_audio_to_buffer()
)

...where alsa.wait_for_avail() would somehow tell rust that it should block on ALSA's file descriptor in addition to other things (such as messages on the channel).

If it matters, assume native threads (i e, not green threads).

 // David
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to