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
4 changes: 2 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["Will S. Medrano <will.s.medrano@gmail.com>"]
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"
Expand All @@ -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"]
Expand Down
5 changes: 2 additions & 3 deletions jack-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
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"
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]
Expand Down
7 changes: 3 additions & 4 deletions jack-sys/src/functions/dynamic_loading.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -524,9 +524,8 @@ fn missing_symbol(name: &'static str, source: libloading::Error) -> LoadError {
LoadError::MissingSymbol { name, source }
}

lazy_static! {
static ref FUNCTIONS: Result<JackFunctions, LoadError> = unsafe { load_jack_functions() };
}
static FUNCTIONS: LazyLock<Result<JackFunctions, LoadError>> =
LazyLock::new(|| unsafe { load_jack_functions() });

/// Loads the JACK library and every symbol this crate requires from it.
///
Expand Down
9 changes: 4 additions & 5 deletions jack-sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<libloading::Library, libloading::Error> = unsafe {
static LIB_RESULT: LazyLock<Result<libloading::Library, libloading::Error>> =
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.
Expand Down
13 changes: 4 additions & 9 deletions src/client/common.rs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<usize> = 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(());
9 changes: 7 additions & 2 deletions src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
15 changes: 7 additions & 8 deletions src/port/port_impl.rs
Original file line number Diff line number Diff line change
@@ -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<usize> =
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<usize> =
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...
Expand Down
2 changes: 1 addition & 1 deletion src/tests/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
7 changes: 0 additions & 7 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::sync::LazyLock;

use ctor::ctor;

use crate::{Client, ClientOptions};

mod client;
Expand All @@ -16,8 +14,3 @@ pub static DEFAULT_TEST_CLIENT: LazyLock<Client> = LazyLock::new(|| {
.unwrap()
.0
});

#[ctor]
fn log_to_stdio() {
crate::set_logger(crate::LoggerType::Stdio);
}
Loading