Skip to content

Commit

Permalink
Use ClientOptions::default() instead of NO_START_SERVER
Browse files Browse the repository at this point in the history
  • Loading branch information
wmedrano committed Sep 14, 2024
1 parent 5d57d24 commit cca63d8
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 39 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Rust bindings for [JACK Audio Connection Kit](<https://jackaudio.org>).

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.
Expand Down
4 changes: 2 additions & 2 deletions docs/contrib/closure_callbacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion docs/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
```


Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/internal_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion examples/playback_capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/set_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion examples/show_midi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion examples/show_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion examples/sine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/client/async_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
/// );
Expand Down
2 changes: 1 addition & 1 deletion src/client/client_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/contrib/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub mod contrib {
mod tests;

static TIME_CLIENT: std::sync::LazyLock<Client> = std::sync::LazyLock::new(|| {
Client::new("deprecated_get_time", ClientOptions::NO_START_SERVER)
Client::new("deprecated_get_time", ClientOptions::default())
.unwrap()
.0
});
Expand Down
4 changes: 2 additions & 2 deletions src/port/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
14 changes: 7 additions & 7 deletions src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(()));
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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(()));

Expand Down Expand Up @@ -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<PropertyChangeOwned>, _) = channel();
assert_eq!(
Ok(()),
Expand Down Expand Up @@ -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(|_| {}))
Expand Down
14 changes: 7 additions & 7 deletions src/tests/client.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -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());
Expand All @@ -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(),
Expand All @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions src/tests/processing.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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(
(),
Expand All @@ -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 |_, _| {
Expand All @@ -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(
(),
Expand All @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

0 comments on commit cca63d8

Please sign in to comment.