Debian Codegraph @

third_party/rust/audio_thread_priority/README.md

raw
1 # audio_thread_priority
2
3 [![](https://img.shields.io/crates/v/audio_thread_priority.svg)](https://crates.io/crates/audio_thread_priority)
4 [![](https://docs.rs/audio_thread_priority/badge.svg)](https://docs.rs/audio_thread_priority)
5
6
7 Synopsis:
8
9 ```rust
10
11 use audio_thread_priority::{promote_current_thread_to_real_time, demote_current_thread_from_real_time};
12
13 // ... on a thread that will compute audio and has to be real-time:
14 match promote_current_thread_to_real_time(512, 44100) {
15 Ok(h) => {
16 println!("this thread is now bumped to real-time priority.");
17
18 // Do some real-time work...
19
20 match demote_current_thread_from_real_time(h) {
21 Ok(_) => {
22 println!("this thread is now bumped back to normal.")
23 }
24 Err(_) => {
25 println!("Could not bring the thread back to normal priority.")
26 }
27 };
28 }
29 Err(e) => {
30 eprintln!("Error promoting thread to real-time: {}", e);
31 }
32 }
33
34 ```
35
36 This library can also be used from C or C++ using the included header and
37 compiling the rust code in the application. By default, a `.a` is compiled to
38 ease linking.
39
40 # License
41
42 MPL-2
43