Bump Jack to v0.12 (#910)
* Bump to version 0.12. * Fix some cargo clippy lints. * Partially revert temp_buffer_to_data to be closer to original. * Suppress too many arguments lint.
This commit is contained in:
parent
cc8ba75543
commit
6ecfec4ed0
3 changed files with 17 additions and 19 deletions
|
|
@ -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]
|
[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"))'.dependencies]
|
||||||
alsa = "0.9"
|
alsa = "0.9"
|
||||||
libc = "0.2"
|
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]
|
[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.
|
core-foundation-sys = "0.8.2" # For linking to CoreFoundation.framework and handling device name `CFString`s.
|
||||||
|
|
|
||||||
|
|
@ -170,11 +170,8 @@ fn get_client(name: &str, client_options: jack::ClientOptions) -> Result<jack::C
|
||||||
} else if status.intersects(jack::ClientStatus::INVALID_OPTION) {
|
} else if status.intersects(jack::ClientStatus::INVALID_OPTION) {
|
||||||
return Err(String::from("Error connecting to JACK server: The operation contained an invalid or unsupported option!"));
|
return Err(String::from("Error connecting to JACK server: The operation contained an invalid or unsupported option!"));
|
||||||
}
|
}
|
||||||
|
Ok(client)
|
||||||
return Ok(client);
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
return Err(format!("Failed to open client because of error: {:?}", e));
|
|
||||||
}
|
}
|
||||||
|
Err(e) => Err(format!("Failed to open client because of error: {:?}", e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ impl Stream {
|
||||||
let mut port_names: Vec<String> = vec![];
|
let mut port_names: Vec<String> = vec![];
|
||||||
// Create ports
|
// Create ports
|
||||||
for i in 0..channels {
|
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 {
|
match port_try {
|
||||||
Ok(port) => {
|
Ok(port) => {
|
||||||
// Get the port name in order to later connect it automatically
|
// Get the port name in order to later connect it automatically
|
||||||
|
|
@ -102,7 +102,7 @@ impl Stream {
|
||||||
let mut port_names: Vec<String> = vec![];
|
let mut port_names: Vec<String> = vec![];
|
||||||
// Create ports
|
// Create ports
|
||||||
for i in 0..channels {
|
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 {
|
match port_try {
|
||||||
Ok(port) => {
|
Ok(port) => {
|
||||||
// Get the port name in order to later connect it automatically
|
// Get the port name in order to later connect it automatically
|
||||||
|
|
@ -218,6 +218,9 @@ impl StreamTrait for Stream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type InputDataCallback = Box<dyn FnMut(&Data, &InputCallbackInfo) + Send + 'static>;
|
||||||
|
type OutputDataCallback = Box<dyn FnMut(&mut Data, &OutputCallbackInfo) + Send + 'static>;
|
||||||
|
|
||||||
struct LocalProcessHandler {
|
struct LocalProcessHandler {
|
||||||
/// No new ports are allowed to be created after the creation of the LocalProcessHandler as that would invalidate the buffer sizes
|
/// No new ports are allowed to be created after the creation of the LocalProcessHandler as that would invalidate the buffer sizes
|
||||||
out_ports: Vec<jack::Port<jack::AudioOut>>,
|
out_ports: Vec<jack::Port<jack::AudioOut>>,
|
||||||
|
|
@ -225,8 +228,8 @@ struct LocalProcessHandler {
|
||||||
|
|
||||||
sample_rate: SampleRate,
|
sample_rate: SampleRate,
|
||||||
buffer_size: usize,
|
buffer_size: usize,
|
||||||
input_data_callback: Option<Box<dyn FnMut(&Data, &InputCallbackInfo) + Send + 'static>>,
|
input_data_callback: Option<InputDataCallback>,
|
||||||
output_data_callback: Option<Box<dyn FnMut(&mut Data, &OutputCallbackInfo) + Send + 'static>>,
|
output_data_callback: Option<OutputDataCallback>,
|
||||||
|
|
||||||
// JACK audio samples are 32-bit float (unless you do some custom dark magic)
|
// JACK audio samples are 32-bit float (unless you do some custom dark magic)
|
||||||
temp_input_buffer: Vec<f32>,
|
temp_input_buffer: Vec<f32>,
|
||||||
|
|
@ -238,15 +241,14 @@ struct LocalProcessHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LocalProcessHandler {
|
impl LocalProcessHandler {
|
||||||
|
#[allow(too_many_arguments)]
|
||||||
fn new(
|
fn new(
|
||||||
out_ports: Vec<jack::Port<jack::AudioOut>>,
|
out_ports: Vec<jack::Port<jack::AudioOut>>,
|
||||||
in_ports: Vec<jack::Port<jack::AudioIn>>,
|
in_ports: Vec<jack::Port<jack::AudioIn>>,
|
||||||
sample_rate: SampleRate,
|
sample_rate: SampleRate,
|
||||||
buffer_size: usize,
|
buffer_size: usize,
|
||||||
input_data_callback: Option<Box<dyn FnMut(&Data, &InputCallbackInfo) + Send + 'static>>,
|
input_data_callback: Option<InputDataCallback>,
|
||||||
output_data_callback: Option<
|
output_data_callback: Option<OutputDataCallback>,
|
||||||
Box<dyn FnMut(&mut Data, &OutputCallbackInfo) + Send + 'static>,
|
|
||||||
>,
|
|
||||||
playing: Arc<AtomicBool>,
|
playing: Arc<AtomicBool>,
|
||||||
error_callback_ptr: ErrorCallbackPtr,
|
error_callback_ptr: ErrorCallbackPtr,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
|
@ -270,12 +272,11 @@ impl LocalProcessHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn temp_buffer_to_data(temp_input_buffer: &mut Vec<f32>, total_buffer_size: usize) -> Data {
|
fn temp_buffer_to_data(temp_input_buffer: &mut [f32], total_buffer_size: usize) -> Data {
|
||||||
let slice = &temp_input_buffer[0..total_buffer_size];
|
let slice = &mut temp_input_buffer[0..total_buffer_size];
|
||||||
let data = slice.as_ptr() as *mut ();
|
let data: *mut () = slice.as_mut_ptr().cast();
|
||||||
let len = total_buffer_size;
|
let len = total_buffer_size;
|
||||||
let data = unsafe { Data::from_parts(data, len, JACK_SAMPLE_FORMAT) };
|
unsafe { Data::from_parts(data, len, JACK_SAMPLE_FORMAT) }
|
||||||
data
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl jack::ProcessHandler for LocalProcessHandler {
|
impl jack::ProcessHandler for LocalProcessHandler {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue