| Crates.io | audio_thread_priority |
| lib.rs | audio_thread_priority |
| version | 0.34.0 |
| created_at | 2018-01-24 17:32:03.326515+00 |
| updated_at | 2025-08-13 12:23:44.892354+00 |
| description | Bump a thread to real-time priority, for audio work, on Linux, Android, Windows and macOS |
| homepage | |
| repository | https://github.com/padenot/audio_thread_priority |
| max_upload_size | |
| id | 48166 |
| size | 87,857 |
Synopsis:
use audio_thread_priority::{promote_current_thread_to_real_time, demote_current_thread_from_real_time};
// ... on a thread that will compute audio and has to be real-time:
match promote_current_thread_to_real_time(512, 44100) {
Ok(h) => {
println!("this thread is now bumped to real-time priority.");
// Do some real-time work...
match demote_current_thread_from_real_time(h) {
Ok(_) => {
println!("this thread is now bumped back to normal.")
}
Err(_) => {
println!("Could not bring the thread back to normal priority.")
}
};
}
Err(e) => {
eprintln!("Error promoting thread to real-time: {}", e);
}
}
This library can also be used from C or C++ using the included header and
compiling the rust code in the application. By default, a .a is compiled to
ease linking.
MPL-2