From af04562e2529943bbb6b38367d183395fcb266c5 Mon Sep 17 00:00:00 2001 From: Will Medrano Date: Mon, 9 Sep 2024 06:19:23 -0700 Subject: [PATCH 1/4] Bump to version 0.12. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5ccf1776b..0d955d6d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ num-traits = { version = "0.2.6", optional = true } [target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"))'.dependencies] alsa = "0.9" libc = "0.2" -jack = { version = "0.11", optional = true } +jack = { version = "0.12", optional = true } [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies] core-foundation-sys = "0.8.2" # For linking to CoreFoundation.framework and handling device name `CFString`s. From 34ca9b29691b8795a614ae3fdccf0a768e4fca22 Mon Sep 17 00:00:00 2001 From: Will Medrano Date: Mon, 9 Sep 2024 06:19:42 -0700 Subject: [PATCH 2/4] Fix some cargo clippy lints. --- src/host/jack/mod.rs | 7 ++----- src/host/jack/stream.rs | 25 ++++++++++++------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/host/jack/mod.rs b/src/host/jack/mod.rs index e1e244e96..d4a28ecea 100644 --- a/src/host/jack/mod.rs +++ b/src/host/jack/mod.rs @@ -170,11 +170,8 @@ fn get_client(name: &str, client_options: jack::ClientOptions) -> Result { - return Err(format!("Failed to open client because of error: {:?}", e)); + Ok(client) } + Err(e) => Err(format!("Failed to open client because of error: {:?}", e)), } } diff --git a/src/host/jack/stream.rs b/src/host/jack/stream.rs index 95a3e3b40..e10dc424b 100644 --- a/src/host/jack/stream.rs +++ b/src/host/jack/stream.rs @@ -37,7 +37,7 @@ impl Stream { let mut port_names: Vec = vec![]; // Create ports for i in 0..channels { - let port_try = client.register_port(&format!("in_{}", i), jack::AudioIn::default()); + let port_try = client.register_port(&format!("in_{}", i), jack::AudioIn); match port_try { Ok(port) => { // Get the port name in order to later connect it automatically @@ -102,7 +102,7 @@ impl Stream { let mut port_names: Vec = vec![]; // Create ports for i in 0..channels { - let port_try = client.register_port(&format!("out_{}", i), jack::AudioOut::default()); + let port_try = client.register_port(&format!("out_{}", i), jack::AudioOut); match port_try { Ok(port) => { // Get the port name in order to later connect it automatically @@ -218,6 +218,9 @@ impl StreamTrait for Stream { } } +type InputDataCallback = Box; +type OutputDataCallback = Box; + struct LocalProcessHandler { /// No new ports are allowed to be created after the creation of the LocalProcessHandler as that would invalidate the buffer sizes out_ports: Vec>, @@ -225,8 +228,8 @@ struct LocalProcessHandler { sample_rate: SampleRate, buffer_size: usize, - input_data_callback: Option>, - output_data_callback: Option>, + input_data_callback: Option, + output_data_callback: Option, // JACK audio samples are 32-bit float (unless you do some custom dark magic) temp_input_buffer: Vec, @@ -243,10 +246,8 @@ impl LocalProcessHandler { in_ports: Vec>, sample_rate: SampleRate, buffer_size: usize, - input_data_callback: Option>, - output_data_callback: Option< - Box, - >, + input_data_callback: Option, + output_data_callback: Option, playing: Arc, error_callback_ptr: ErrorCallbackPtr, ) -> Self { @@ -270,12 +271,10 @@ impl LocalProcessHandler { } } -fn temp_buffer_to_data(temp_input_buffer: &mut Vec, total_buffer_size: usize) -> Data { - let slice = &temp_input_buffer[0..total_buffer_size]; - let data = slice.as_ptr() as *mut (); +fn temp_buffer_to_data(temp_input_buffer: &mut [f32], total_buffer_size: usize) -> Data { + let slice = &mut temp_input_buffer[0..total_buffer_size]; let len = total_buffer_size; - let data = unsafe { Data::from_parts(data, len, JACK_SAMPLE_FORMAT) }; - data + unsafe { Data::from_parts(slice.as_mut_ptr().cast(), len, JACK_SAMPLE_FORMAT) } } impl jack::ProcessHandler for LocalProcessHandler { From d8d9a711ebec33ce3df564acb3ccea38c7af8f56 Mon Sep 17 00:00:00 2001 From: Will Medrano Date: Mon, 9 Sep 2024 06:23:43 -0700 Subject: [PATCH 3/4] Partially revert temp_buffer_to_data to be closer to original. --- src/host/jack/stream.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/host/jack/stream.rs b/src/host/jack/stream.rs index e10dc424b..e5e52cc69 100644 --- a/src/host/jack/stream.rs +++ b/src/host/jack/stream.rs @@ -273,8 +273,9 @@ impl LocalProcessHandler { fn temp_buffer_to_data(temp_input_buffer: &mut [f32], total_buffer_size: usize) -> Data { let slice = &mut temp_input_buffer[0..total_buffer_size]; + let data: *mut () = slice.as_mut_ptr().cast(); let len = total_buffer_size; - unsafe { Data::from_parts(slice.as_mut_ptr().cast(), len, JACK_SAMPLE_FORMAT) } + unsafe { Data::from_parts(data, len, JACK_SAMPLE_FORMAT) } } impl jack::ProcessHandler for LocalProcessHandler { From b67f731a4b9ced02b7573ddbb68250ebcad7988c Mon Sep 17 00:00:00 2001 From: Will Medrano Date: Mon, 9 Sep 2024 06:25:33 -0700 Subject: [PATCH 4/4] Suppress too many arguments lint. --- src/host/jack/stream.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/host/jack/stream.rs b/src/host/jack/stream.rs index e5e52cc69..820e22ccc 100644 --- a/src/host/jack/stream.rs +++ b/src/host/jack/stream.rs @@ -241,6 +241,7 @@ struct LocalProcessHandler { } impl LocalProcessHandler { + #[allow(too_many_arguments)] fn new( out_ports: Vec>, in_ports: Vec>,