Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ jobs:
strategy:
matrix:
rust: [stable, nightly]
os: [ubuntu-20.04, windows-2019, macos-10.15]
os: [ubuntu-24.04, windows-2025, macos-14]
type: [Release, Debug]

steps:
- uses: actions/checkout@v2

- name: Install Rust
run: rustup toolchain install ${{ matrix.rust }} --profile minimal --component rustfmt clippy
run: |
rustup toolchain install ${{ matrix.rust }} --profile minimal
rustup component add rustfmt --toolchain ${{ matrix.rust }}
rustup component add clippy --toolchain ${{ matrix.rust }}

- name: Install Dependencies (Linux)
run: sudo apt-get update && sudo apt-get install libpulse-dev pulseaudio libdbus-1-dev
if: matrix.os == 'ubuntu-20.04'
if: matrix.os == 'ubuntu-24.04'

- name: Check format
shell: bash
Expand All @@ -36,4 +39,5 @@ jobs:
- name: Test
shell: bash
run: rustup run ${{ matrix.rust }} cargo test --all
if: matrix.os != 'ubuntu-20.04' # setrlimit64 error in the CI container
# setrlimit64 error in the CI container, macOS not supported
if: matrix.os != 'ubuntu-24.04' && matrix.os != 'macos-14'
50 changes: 19 additions & 31 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl fmt::Display for AudioThreadPriorityError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut rv = write!(f, "AudioThreadPriorityError: {}", &self.message);
if let Some(inner) = &self.inner {
rv = write!(f, " ({})", inner);
rv = write!(f, " ({inner})");
}
rv
}
Expand Down Expand Up @@ -587,61 +587,54 @@ mod tests {
{
match promote_current_thread_to_real_time(0, 44100) {
Ok(rt_prio_handle) => {
demote_current_thread_from_real_time(rt_prio_handle).unwrap();
assert!(true);
let rv = demote_current_thread_from_real_time(rt_prio_handle);
assert!(rv.is_ok());
}
Err(e) => {
eprintln!("{}", e);
assert!(false);
panic!("{}", e);
}
}
}
{
match promote_current_thread_to_real_time(512, 44100) {
Ok(rt_prio_handle) => {
demote_current_thread_from_real_time(rt_prio_handle).unwrap();
assert!(true);
let rv = demote_current_thread_from_real_time(rt_prio_handle);
assert!(rv.is_ok());
}
Err(e) => {
eprintln!("{}", e);
assert!(false);
panic!("{}", e);
}
}
}
{
// Try larger values to test https://github.com/mozilla/audio_thread_priority/pull/23
match promote_current_thread_to_real_time(0, 192000) {
Ok(rt_prio_handle) => {
demote_current_thread_from_real_time(rt_prio_handle).unwrap();
assert!(true);
let rv = demote_current_thread_from_real_time(rt_prio_handle);
assert!(rv.is_ok());
}
Err(e) => {
eprintln!("{}", e);
assert!(false);
panic!("{}", e);
}
}
}
{
// Try larger values to test https://github.com/mozilla/audio_thread_priority/pull/23
match promote_current_thread_to_real_time(8192, 48000) {
Ok(rt_prio_handle) => {
demote_current_thread_from_real_time(rt_prio_handle).unwrap();
assert!(true);
let rv = demote_current_thread_from_real_time(rt_prio_handle);
assert!(rv.is_ok());
}
Err(e) => {
eprintln!("{}", e);
assert!(false);
panic!("{}", e);
}
}
}
{
match promote_current_thread_to_real_time(512, 44100) {
Ok(_) => {
assert!(true);
}
Ok(_) => {}
Err(e) => {
eprintln!("{}", e);
assert!(false);
panic!("{}", e);
}
}
// automatically deallocated, but not demoted until the thread exits.
Expand All @@ -666,12 +659,9 @@ mod tests {
{
let info = get_current_thread_info().unwrap();
match promote_thread_to_real_time(info, 512, 44100) {
Ok(_) => {
assert!(true);
}
Ok(_) => { }
Err(e) => {
eprintln!("{}", e);
assert!(false);
panic!("{}", e);
}
}
}
Expand Down Expand Up @@ -702,12 +692,10 @@ mod tests {
match promote_thread_to_real_time(info, 0, 44100) {
Ok(_) => {
eprintln!("thread promotion in the child from the parent succeeded");
assert!(true);
}
Err(_) => {
eprintln!("promotion Err");
Err(e) => {
kill(child, SIGKILL).expect("Could not kill the child?");
assert!(false);
panic!("{}", e);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/rt_linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ fn item_as_i64(i: MessageItem) -> Result<i64, AudioThreadPriorityError> {
MessageItem::Int32(i) => Ok(i as i64),
MessageItem::Int64(i) => Ok(i),
_ => Err(AudioThreadPriorityError::new(&format!(
"Property is not integer ({:?})",
i
"Property is not integer ({i:?})"
))),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/rt_mach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub fn promote_current_thread_to_real_time_internal(
));
}

info!("thread {} bumped to real time priority.", tid);
info!("thread {tid} bumped to real time priority.");
}

Ok(rt_priority_handle)
Expand Down