diff --git a/README.md b/README.md index 8d5d369e..776acd75 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,8 @@ Rust bindings for [JACK Audio Connection Kit](). The JACK server is usually started by the user or system. Clients can request that the JACK server is started on demand when they connect, but this can be -disabled by creating a client with the `NO_START_SERVER` option. +disabled by creating a client with the `NO_START_SERVER` option or +`ClientOptions::default()`. - Linux and BSD users may install JACK1, JACK2 (preferred for low latency), or Pipewire JACK (preferred for ease of use) from their system package manager. diff --git a/docs/contrib/closure_callbacks.md b/docs/contrib/closure_callbacks.md index dd426827..c154c180 100644 --- a/docs/contrib/closure_callbacks.md +++ b/docs/contrib/closure_callbacks.md @@ -18,7 +18,7 @@ contains captures the required state and then activating it. ```rust // 1. Create the client. let (client, _status) = - jack::Client::new("silence", jack::ClientOptions::NO_START_SERVER).unwrap(); + jack::Client::new("silence", jack::ClientOptions::default()).unwrap(); // 2. Define the state. let mut output = client.register_port("out", jack::AudioOut::default()); @@ -45,7 +45,7 @@ buffer size. ```rust // 1. Create the client. let (client, _status) = - jack::Client::new("silence", jack::ClientOptions::NO_START_SERVER).unwrap(); + jack::Client::new("silence", jack::ClientOptions::default()).unwrap(); // 2. Define the state. struct State { diff --git a/docs/logging.md b/docs/logging.md index a89174eb..0a8fcab0 100644 --- a/docs/logging.md +++ b/docs/logging.md @@ -36,7 +36,7 @@ env_logger::builder().filter(None, log::LevelFilter::Info).init(); // JACK may log things to `info!` or `error!`. let (client, _status) = - jack::Client::new("rust_jack_simple", jack::ClientOptions::NO_START_SERVER).unwrap(); + jack::Client::new("rust_jack_simple", jack::ClientOptions::default()).unwrap(); ``` diff --git a/docs/quickstart.md b/docs/quickstart.md index a9c79579..a5bdb7d8 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -55,7 +55,7 @@ program that can take inputs and forward them to outputs. fn main() { // 1. Create client let (client, _status) = - jack::Client::new("rust_jack_simple", jack::ClientOptions::NO_START_SERVER).unwrap(); + jack::Client::new("rust_jack_simple", jack::ClientOptions::default()).unwrap(); // 2. Register ports. They will be used in a callback that will be // called when new data is available. diff --git a/examples/internal_client.rs b/examples/internal_client.rs index 7125ca86..8de2a06c 100644 --- a/examples/internal_client.rs +++ b/examples/internal_client.rs @@ -6,7 +6,7 @@ fn main() { // Create client let (client, _status) = jack::Client::new( "rust_jack_internal_client_tester", - jack::ClientOptions::NO_START_SERVER, + jack::ClientOptions::default(), ) .unwrap(); diff --git a/examples/playback_capture.rs b/examples/playback_capture.rs index 38ccc28f..a15f7aaf 100644 --- a/examples/playback_capture.rs +++ b/examples/playback_capture.rs @@ -6,7 +6,7 @@ fn main() { // Create client jack::set_logger(jack::LoggerType::Stdio); let (client, _status) = - jack::Client::new("rust_jack_simple", jack::ClientOptions::NO_START_SERVER).unwrap(); + jack::Client::new("rust_jack_simple", jack::ClientOptions::default()).unwrap(); // Register ports. They will be used in a callback that will be // called when new data is available. diff --git a/examples/set_transport.rs b/examples/set_transport.rs index 30b18a41..cda4dd3f 100644 --- a/examples/set_transport.rs +++ b/examples/set_transport.rs @@ -2,7 +2,7 @@ use std::env; fn main() { let (client, _status) = - jack::Client::new("rust_jack_trans", jack::ClientOptions::NO_START_SERVER).unwrap(); + jack::Client::new("rust_jack_trans", jack::ClientOptions::default()).unwrap(); let transport = client.transport(); diff --git a/examples/show_midi.rs b/examples/show_midi.rs index 4a311353..f1acd87e 100644 --- a/examples/show_midi.rs +++ b/examples/show_midi.rs @@ -43,7 +43,7 @@ impl std::fmt::Debug for MidiCopy { fn main() { // Open the client. let (client, _status) = - jack::Client::new("rust_jack_show_midi", jack::ClientOptions::NO_START_SERVER).unwrap(); + jack::Client::new("rust_jack_show_midi", jack::ClientOptions::default()).unwrap(); // Create a sync channel to send back copies of midi messages we get. let (sender, receiver) = sync_channel(64); diff --git a/examples/show_transport.rs b/examples/show_transport.rs index e2ba2948..87368940 100644 --- a/examples/show_transport.rs +++ b/examples/show_transport.rs @@ -7,7 +7,7 @@ use std::sync::{ fn main() { // Create client let (client, _status) = - jack::Client::new("rust_jack_trans", jack::ClientOptions::NO_START_SERVER).unwrap(); + jack::Client::new("rust_jack_trans", jack::ClientOptions::default()).unwrap(); let transport = client.transport(); let stop = Arc::new(AtomicBool::new(false)); diff --git a/examples/sine.rs b/examples/sine.rs index 10d78cc6..cee00030 100644 --- a/examples/sine.rs +++ b/examples/sine.rs @@ -8,7 +8,7 @@ use std::str::FromStr; fn main() { // 1. open a client let (client, _status) = - jack::Client::new("rust_jack_sine", jack::ClientOptions::NO_START_SERVER).unwrap(); + jack::Client::new("rust_jack_sine", jack::ClientOptions::default()).unwrap(); // 2. register port let out_port = client diff --git a/src/client/async_client.rs b/src/client/async_client.rs index ea260beb..fc556651 100644 --- a/src/client/async_client.rs +++ b/src/client/async_client.rs @@ -20,7 +20,7 @@ use crate::Error; /// ``` /// // Create a client and a handler /// let (client, _status) = -/// jack::Client::new("my_client", jack::ClientOptions::NO_START_SERVER).unwrap(); +/// jack::Client::new("my_client", jack::ClientOptions::default()).unwrap(); /// let process_handler = jack::contrib::ClosureProcessHandler::new( /// move |_: &jack::Client, _: &jack::ProcessScope| jack::Control::Continue, /// ); diff --git a/src/client/client_impl.rs b/src/client/client_impl.rs index abd94f40..4490ea3a 100644 --- a/src/client/client_impl.rs +++ b/src/client/client_impl.rs @@ -17,7 +17,7 @@ use crate::{ /// /// # Example /// ``` -/// let c_res = jack::Client::new("rusty_client", jack::ClientOptions::NO_START_SERVER); +/// let c_res = jack::Client::new("rusty_client", jack::ClientOptions::default()); /// match c_res { /// Ok((client, status)) => println!( /// "Managed to open client {}, with diff --git a/src/contrib/closure.rs b/src/contrib/closure.rs index ee407ad7..74e9382c 100644 --- a/src/contrib/closure.rs +++ b/src/contrib/closure.rs @@ -58,7 +58,7 @@ where /// /// ```rust /// // 1. Create the client. - /// let (client, _status) = jack::Client::new("silence", jack::ClientOptions::NO_START_SERVER).unwrap(); + /// let (client, _status) = jack::Client::new("silence", jack::ClientOptions::default()).unwrap(); /// /// // 2. Define the state. /// struct State{ diff --git a/src/lib.rs b/src/lib.rs index 875551f9..4c376bd1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -78,7 +78,7 @@ pub mod contrib { mod tests; static TIME_CLIENT: std::sync::LazyLock = std::sync::LazyLock::new(|| { - Client::new("deprecated_get_time", ClientOptions::NO_START_SERVER) + Client::new("deprecated_get_time", ClientOptions::default()) .unwrap() .0 }); diff --git a/src/port/audio.rs b/src/port/audio.rs index cb6e7eda..fb128eb9 100644 --- a/src/port/audio.rs +++ b/src/port/audio.rs @@ -11,7 +11,7 @@ use crate::{Port, PortFlags, PortSpec, ProcessScope}; /// /// # Example /// ``` -/// let client = jack::Client::new("rusty_client", jack::ClientOptions::NO_START_SERVER) +/// let client = jack::Client::new("rusty_client", jack::ClientOptions::default()) /// .unwrap() /// .0; /// let spec = jack::AudioIn::default(); @@ -30,7 +30,7 @@ pub struct AudioIn { /// /// # Example /// ``` -/// let client = jack::Client::new("rusty_client", jack::ClientOptions::NO_START_SERVER) +/// let client = jack::Client::new("rusty_client", jack::ClientOptions::default()) /// .unwrap() /// .0; /// let spec = jack::AudioIn::default(); diff --git a/src/properties.rs b/src/properties.rs index 0c8bdea8..bb205b8f 100644 --- a/src/properties.rs +++ b/src/properties.rs @@ -364,7 +364,7 @@ mod metadata { #[test] fn can_set_and_get() { - let (c, _) = Client::new("dummy", ClientOptions::NO_START_SERVER).unwrap(); + let (c, _) = Client::new("dummy", ClientOptions::default()).unwrap(); let prop1 = Property::new("foo", None); assert_eq!(c.property_set(c.uuid(), "blah", &prop1), Ok(())); @@ -405,8 +405,8 @@ mod metadata { #[test] fn can_remove() { - let (c1, _) = Client::new("client1", ClientOptions::NO_START_SERVER).unwrap(); - let (c2, _) = Client::new("client2", ClientOptions::NO_START_SERVER).unwrap(); + let (c1, _) = Client::new("client1", ClientOptions::default()).unwrap(); + let (c2, _) = Client::new("client2", ClientOptions::default()).unwrap(); let prop1 = Property::new("foo", None); let prop2 = Property::new( "http://churchofrobotron.com/2084", @@ -455,7 +455,7 @@ mod metadata { #[test] fn can_property_remove_all() { - let (c, _) = Client::new("dummy", ClientOptions::NO_START_SERVER).unwrap(); + let (c, _) = Client::new("dummy", ClientOptions::default()).unwrap(); let prop = Property::new("foo", Some("bar".into())); assert_eq!(c.property_set(c.uuid(), "blah", &prop), Ok(())); @@ -488,8 +488,8 @@ mod metadata { Some("robot apocalypse".into()), ); - let (mut c1, _) = Client::new("client1", ClientOptions::NO_START_SERVER).unwrap(); - let (c2, _) = Client::new("client2", ClientOptions::NO_START_SERVER).unwrap(); + let (mut c1, _) = Client::new("client1", ClientOptions::default()).unwrap(); + let (c2, _) = Client::new("client2", ClientOptions::default()).unwrap(); let (sender, receiver): (Sender, _) = channel(); assert_eq!( Ok(()), @@ -563,7 +563,7 @@ mod metadata { #[test] #[should_panic] fn double_register() { - let (mut c, _) = Client::new("client1", ClientOptions::NO_START_SERVER).unwrap(); + let (mut c, _) = Client::new("client1", ClientOptions::default()).unwrap(); assert_eq!( Ok(()), c.register_property_change_handler(ClosurePropertyChangeHandler::new(|_| {})) diff --git a/src/tests/client.rs b/src/tests/client.rs index 5ff4fc9b..356fa1d9 100644 --- a/src/tests/client.rs +++ b/src/tests/client.rs @@ -1,7 +1,7 @@ #[test] fn client_can_open() { let (client, status) = - crate::Client::new("my new client", crate::ClientOptions::NO_START_SERVER).unwrap(); + crate::Client::new("my new client", crate::ClientOptions::default()).unwrap(); assert_eq!(status, crate::ClientStatus::empty()); assert_eq!(client.name(), "my new client"); assert_ne!(client.sample_rate(), 0); @@ -39,8 +39,8 @@ fn maybe_client_can_set_buffer_size() { #[test] fn client_uuid_are_unique() { - let (client1, _) = crate::Client::new("", crate::ClientOptions::NO_START_SERVER).unwrap(); - let (client2, _) = crate::Client::new("", crate::ClientOptions::NO_START_SERVER).unwrap(); + let (client1, _) = crate::Client::new("", crate::ClientOptions::default()).unwrap(); + let (client2, _) = crate::Client::new("", crate::ClientOptions::default()).unwrap(); assert_ne!(client1.uuid_string(), ""); assert_ne!(client2.uuid_string(), ""); assert_ne!(client1.uuid_string(), client2.uuid_string()); @@ -52,9 +52,9 @@ fn client_uuid_are_unique() { #[test] fn uuid_can_map_to_client_name() { let (client1, _) = - crate::Client::new("uuid-client-1", crate::ClientOptions::NO_START_SERVER).unwrap(); + crate::Client::new("uuid-client-1", crate::ClientOptions::default()).unwrap(); let (client2, _) = - crate::Client::new("uuid-client-2", crate::ClientOptions::NO_START_SERVER).unwrap(); + crate::Client::new("uuid-client-2", crate::ClientOptions::default()).unwrap(); assert_eq!( client1.name_by_uuid_str(&client1.uuid_string()).unwrap(), @@ -76,9 +76,9 @@ fn uuid_can_map_to_client_name() { #[test] fn nonexistant_uuid_to_client_name_returns_none() { - let (client1, _) = crate::Client::new("", crate::ClientOptions::NO_START_SERVER).unwrap(); + let (client1, _) = crate::Client::new("", crate::ClientOptions::default()).unwrap(); let (client2, _) = - crate::Client::new("dropped-client", crate::ClientOptions::NO_START_SERVER).unwrap(); + crate::Client::new("dropped-client", crate::ClientOptions::default()).unwrap(); let uuid_string = client2.uuid_string(); let uuid = client2.uuid(); drop(client2); diff --git a/src/tests/processing.rs b/src/tests/processing.rs index 64bd2920..a964e2e4 100644 --- a/src/tests/processing.rs +++ b/src/tests/processing.rs @@ -1,6 +1,6 @@ #[test] fn panic_in_process_handler_propagates_as_error_in_deactivate() { - let (client, _) = crate::Client::new("", crate::ClientOptions::NO_START_SERVER).unwrap(); + let (client, _) = crate::Client::new("", crate::ClientOptions::default()).unwrap(); let (send, recv) = std::sync::mpsc::sync_channel(1); let process_handler = crate::contrib::ClosureProcessHandler::new(move |_, _| { send.try_send(true).ok(); @@ -15,7 +15,7 @@ fn panic_in_process_handler_propagates_as_error_in_deactivate() { #[test] fn panic_in_buffer_size_handler_propagates_as_error_in_deactivate() { - let (client, _) = crate::Client::new("", crate::ClientOptions::NO_START_SERVER).unwrap(); + let (client, _) = crate::Client::new("", crate::ClientOptions::default()).unwrap(); let (send, recv) = std::sync::mpsc::sync_channel(2); let handler = crate::contrib::ClosureProcessHandler::with_state( (), @@ -34,7 +34,7 @@ fn panic_in_buffer_size_handler_propagates_as_error_in_deactivate() { #[test] fn quitting_stops_calling_process() { - let (client, _) = crate::Client::new("", crate::ClientOptions::NO_START_SERVER).unwrap(); + let (client, _) = crate::Client::new("", crate::ClientOptions::default()).unwrap(); let mut calls = 0; let (send, recv) = std::sync::mpsc::sync_channel(2); let process_handler = crate::contrib::ClosureProcessHandler::new(move |_, _| { @@ -52,7 +52,7 @@ fn quitting_stops_calling_process() { #[test] fn quitting_buffer_size_never_runs_process() { - let (client, _) = crate::Client::new("", crate::ClientOptions::NO_START_SERVER).unwrap(); + let (client, _) = crate::Client::new("", crate::ClientOptions::default()).unwrap(); let (send, recv) = std::sync::mpsc::sync_channel(2); let handler = crate::contrib::ClosureProcessHandler::with_state( (), @@ -73,7 +73,7 @@ fn quitting_buffer_size_never_runs_process() { #[test] fn buffer_size_is_called_before_process() { - let (client, _) = crate::Client::new("", crate::ClientOptions::NO_START_SERVER).unwrap(); + let (client, _) = crate::Client::new("", crate::ClientOptions::default()).unwrap(); let (send, recv) = std::sync::mpsc::sync_channel(2); let process_handler = crate::contrib::ClosureProcessHandler::with_state( "initializing", @@ -98,7 +98,7 @@ fn buffer_size_is_called_before_process() { #[test] fn signals_in_audio_ports_are_forwarded() { // Setup clients and ports. - let (client, _) = crate::Client::new("", crate::ClientOptions::NO_START_SERVER).unwrap(); + let (client, _) = crate::Client::new("", crate::ClientOptions::default()).unwrap(); let buffer_size = client.buffer_size() as usize; assert_ne!(buffer_size, 0); let input = client @@ -140,7 +140,7 @@ fn signals_in_audio_ports_are_forwarded() { #[test] fn messages_in_midi_ports_are_forwarded() { - let (client, _) = crate::Client::new("", crate::ClientOptions::NO_START_SERVER).unwrap(); + let (client, _) = crate::Client::new("", crate::ClientOptions::default()).unwrap(); let buffer_size = client.buffer_size() as usize; assert_ne!(buffer_size, 0); @@ -189,7 +189,7 @@ fn messages_in_midi_ports_are_forwarded() { #[test] fn activating_client_notifies_buffer_size_before_beginning() { - let (client, _) = crate::Client::new("", crate::ClientOptions::NO_START_SERVER).unwrap(); + let (client, _) = crate::Client::new("", crate::ClientOptions::default()).unwrap(); let initial_buffer_size = client.buffer_size() as usize; assert_ne!(initial_buffer_size, 0); }