#real-time-audio #thread-priority #bump #promote #current-thread #real-time-applications #real-time-priority

audio_thread_priority

Bump a thread to real-time priority, for audio work, on Linux, Android, Windows and macOS

45 releases (breaking)

0.34.0 Aug 13, 2025
0.33.0 Jan 22, 2025
0.32.0 Mar 14, 2024
0.30.0 Nov 6, 2023
0.3.0 Jan 25, 2018

#81 in Audio

Download history 678/week @ 2025-08-27 666/week @ 2025-09-03 529/week @ 2025-09-10 733/week @ 2025-09-17 959/week @ 2025-09-24 942/week @ 2025-10-01 507/week @ 2025-10-08 609/week @ 2025-10-15 829/week @ 2025-10-22 479/week @ 2025-10-29 498/week @ 2025-11-05 553/week @ 2025-11-12 476/week @ 2025-11-19 470/week @ 2025-11-26 822/week @ 2025-12-03 712/week @ 2025-12-10

2,549 downloads per month
Used in 6 crates (5 directly)

MPL-2.0 license

57KB
1K SLoC

audio_thread_priority

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.

License

MPL-2

Dependencies

~0–13MB
~101K SLoC