diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 695a7ad47..3d9661da7 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -43,8 +43,8 @@ jobs: uses: actions/checkout@v2 - name: Install dependencies run: sudo apt update && sudo apt install libjack-jackd2-dev - - name: Install Rust 1.85 - uses: dtolnay/rust-toolchain@1.85 + - name: Install Rust 1.88 + uses: dtolnay/rust-toolchain@1.88 - name: Check jack (Default Features) run: cargo check --verbose - name: Check jack (No Features) diff --git a/Cargo.toml b/Cargo.toml index eea040ebb..a3ea58f0a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ authors = ["Will S. Medrano "] description = "Real time audio and midi with JACK." documentation = "https://docs.rs/jack" edition = "2024" -rust-version = "1.85" +rust-version = "1.88" keywords = ["jack", "realtime", "audio", "midi", "music"] license = "MIT" name = "jack" @@ -14,15 +14,13 @@ version = "0.13.5" [dependencies] bitflags = "2" jack-sys = {version = "0.6", path = "./jack-sys"} -lazy_static = "1.4" libc = "0.2" log = { version = "0.4", optional = true} -rtrb = { version = "0.3.2", optional = true } +rtrb = { version = "0.4", optional = true } [dev-dependencies] approx = "0.5" crossbeam-channel = "0.5" -ctor = "0.2" [features] default = ["dynamic_loading", "log"] diff --git a/jack-sys/Cargo.toml b/jack-sys/Cargo.toml index a079451f3..820925dfc 100644 --- a/jack-sys/Cargo.toml +++ b/jack-sys/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Patrick Reisert"] description = "Low-level binding to the JACK audio API." edition = "2024" -rust-version = "1.85" +rust-version = "1.88" license = "MIT OR Apache-2.0" links = "jack" name = "jack-sys" @@ -10,9 +10,8 @@ repository = "https://github.com/RustAudio/rust-jack/tree/main/jack-sys" version = "0.6.0" [dependencies] -lazy_static = "1.4" libc = "0.2" -libloading = "0.8" +libloading = "0.9" log = "0.4" [build-dependencies] diff --git a/jack-sys/src/functions/dynamic_loading.rs b/jack-sys/src/functions/dynamic_loading.rs index 44c45c843..4c9bd6ef5 100644 --- a/jack-sys/src/functions/dynamic_loading.rs +++ b/jack-sys/src/functions/dynamic_loading.rs @@ -1,6 +1,6 @@ use crate::types::*; -use lazy_static::lazy_static; use std::ops::Deref; +use std::sync::LazyLock; pub struct JackFunctions { jack_release_timebase_impl: unsafe extern "C" fn(*mut jack_client_t) -> ::libc::c_int, @@ -524,9 +524,8 @@ fn missing_symbol(name: &'static str, source: libloading::Error) -> LoadError { LoadError::MissingSymbol { name, source } } -lazy_static! { - static ref FUNCTIONS: Result = unsafe { load_jack_functions() }; -} +static FUNCTIONS: LazyLock> = + LazyLock::new(|| unsafe { load_jack_functions() }); /// Loads the JACK library and every symbol this crate requires from it. /// diff --git a/jack-sys/src/lib.rs b/jack-sys/src/lib.rs index ff51fe672..410fa3080 100644 --- a/jack-sys/src/lib.rs +++ b/jack-sys/src/lib.rs @@ -1,5 +1,5 @@ #![allow(non_camel_case_types, non_upper_case_globals)] -use lazy_static::lazy_static; +use std::sync::LazyLock; mod consts; mod types; @@ -15,12 +15,11 @@ pub use functions::dynamic_linking::*; #[cfg(feature = "dynamic_loading")] pub use functions::dynamic_loading::*; -lazy_static! { - static ref LIB_RESULT: Result = unsafe { +static LIB_RESULT: LazyLock> = + LazyLock::new(|| unsafe { log::info!("Loading jack from {}.", JACK_LIB); libloading::Library::new(JACK_LIB) - }; -} + }); /// Get the underlying library handle used for dynamic loading. Can be used to extract symbols from /// the library. diff --git a/src/client/common.rs b/src/client/common.rs index 5ed6c579d..0a1bae213 100644 --- a/src/client/common.rs +++ b/src/client/common.rs @@ -1,6 +1,5 @@ use jack_sys as j; -use lazy_static::lazy_static; -use std::sync::Mutex; +use std::sync::{LazyLock, Mutex}; /// The maximum length of the JACK client name string. Unlike the "C" JACK API, this does not take /// into account the final `NULL` character and instead corresponds directly to `.len()`. This value @@ -10,11 +9,7 @@ fn client_name_size() -> usize { s as usize } -lazy_static! { - /// The maximum string length for port names. - pub static ref CLIENT_NAME_SIZE: usize = client_name_size(); -} +/// The maximum string length for port names. +pub static CLIENT_NAME_SIZE: LazyLock = LazyLock::new(client_name_size); -lazy_static! { - pub static ref CREATE_OR_DESTROY_CLIENT_MUTEX: Mutex<()> = Mutex::new(()); -} +pub static CREATE_OR_DESTROY_CLIENT_MUTEX: Mutex<()> = Mutex::new(()); diff --git a/src/logging.rs b/src/logging.rs index 00f896f76..0bedb9f11 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -50,12 +50,17 @@ pub enum LoggerType { } impl Default for LoggerType { - #[cfg(feature = "log")] + #[cfg(test)] + fn default() -> LoggerType { + LoggerType::Stdio + } + + #[cfg(all(not(test), feature = "log"))] fn default() -> LoggerType { LoggerType::Log } - #[cfg(not(feature = "log"))] + #[cfg(all(not(test), not(feature = "log")))] fn default() -> LoggerType { LoggerType::Stdio } diff --git a/src/port/port_impl.rs b/src/port/port_impl.rs index 85728de3c..8af317e2f 100644 --- a/src/port/port_impl.rs +++ b/src/port/port_impl.rs @@ -1,23 +1,22 @@ use jack_sys as j; -use lazy_static::lazy_static; use std::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd}; use std::fmt::Debug; use std::hash::{Hash, Hasher}; use std::marker::Sized; -use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering as AtomicOrdering}; +use std::sync::{Arc, LazyLock}; use std::{ffi, fmt, iter}; use crate::jack_utils::to_cstring; use crate::{ClientHandle, Error, Frames, LatencyType, PortFlags}; -lazy_static! { - /// The maximum string length for port names. - pub static ref PORT_NAME_SIZE: usize = unsafe { j::jack_port_name_size() - 1 } as usize; +/// The maximum string length for port names. +pub static PORT_NAME_SIZE: LazyLock = + LazyLock::new(|| unsafe { j::jack_port_name_size() - 1 } as usize); - /// The maximum string length for jack type names. - pub static ref PORT_TYPE_SIZE: usize = unsafe { j::jack_port_type_size() - 1 } as usize; -} +/// The maximum string length for jack type names. +pub static PORT_TYPE_SIZE: LazyLock = + LazyLock::new(|| unsafe { j::jack_port_type_size() - 1 } as usize); /// Defines the configuration for a certain port to JACK, ie 32 bit floating audio input, 8 bit raw /// midi output, etc... diff --git a/src/tests/log.rs b/src/tests/log.rs index 886786ddc..e3a82b192 100644 --- a/src/tests/log.rs +++ b/src/tests/log.rs @@ -28,5 +28,5 @@ fn can_set_logger() { } }) .ok(); - super::log_to_stdio(); // Revert to enable debugging in other tests. + crate::set_logger(crate::LoggerType::Stdio); // Revert to enable debugging in other tests. } diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 0f82d0616..4f9c76859 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -1,7 +1,5 @@ use std::sync::LazyLock; -use ctor::ctor; - use crate::{Client, ClientOptions}; mod client; @@ -16,8 +14,3 @@ pub static DEFAULT_TEST_CLIENT: LazyLock = LazyLock::new(|| { .unwrap() .0 }); - -#[ctor] -fn log_to_stdio() { - crate::set_logger(crate::LoggerType::Stdio); -}