I started, but hit a problem: I want a function that iterates the main loop. For that I want to store the jack AsyncClient struct somewhere once the audio starts.
At the moment its a local variable with auto type:
let _active_client = client.activate_async(
JackNotifications,
jack::ClosureProcessHandler::new(process_callback),
).unwrap();
This works!
If I give a type (needed to return it to caller):
let _active_client: jack::AsyncClient<jack::NotificationHandler, jack::ProcessHandler> = client.activate_async(
JackNotifications,
jack::ClosureProcessHandler::new(process_callback),
).unwrap();
This fails:
arning: trait objects without an explicit `dyn` are deprecated
--> organelle/src/main.rs:301:47
|
301 | let _active_client: jack::AsyncClient<jack::NotificationHandler, jack::ProcessHandler> = client.activate_async(
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn jack::NotificationHandler`
|
= note: `#[warn(bare_trait_objects)]` on by default
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
warning: trait objects without an explicit `dyn` are deprecated
--> organelle/src/main.rs:301:74
|
301 | let _active_client: jack::AsyncClient<jack::NotificationHandler, jack::ProcessHandler> = client.activate_async(
| ^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn jack::ProcessHandler`
|
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
error[E0277]: the size for values of type `dyn NotificationHandler` cannot be known at compilation time
--> organelle/src/main.rs:301:29
|
301 | let _active_client: jack::AsyncClient<jack::NotificationHandler, jack::ProcessHandler> = client.activate_async(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `dyn NotificationHandler`
note: required by a bound in `AsyncClient`
--> /home/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/jack-0.8.2/src/client/async_client.rs:33:24
|
33 | pub struct AsyncClient<N, P> {
| ^ required by this bound in `AsyncClient`
error[E0277]: the size for values of type `dyn ProcessHandler` cannot be known at compilation time
--> organelle/src/main.rs:301:29
|
301 | let _active_client: jack::AsyncClient<jack::NotificationHandler, jack::ProcessHandler> = client.activate_async(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `dyn ProcessHandler`
note: required by a bound in `AsyncClient`
--> /home/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/jack-0.8.2/src/client/async_client.rs:33:27
|
33 | pub struct AsyncClient<N, P> {
| ^ required by this bound in `AsyncClient`
error[E0308]: mismatched types
--> organelle/src/main.rs:301:98
|
216 | let process_callback = move |_: &jack::Client, ps: &jack::ProcessScope| -> jack::Control {
| ________________________________-
217 | | let mut boucle = boucle_rc.lock().unwrap();
218 | | let mut buffers = buffers_rc.lock().unwrap();
219 | | let mut play_clock = buffers.play_clock.clone();
... |
298 | | jack::Control::Continue
299 | | };
| |_________- the found closure
300 |
301 | let _active_client: jack::AsyncClient<jack::NotificationHandler, jack::ProcessHandler> = client.activate_async(
| _____________________________------------------------------------------------------------------___^
| | |
| | expected due to this
302 | | dynJackNotifications,
303 | | jack::ClosureProcessHandler::new(process_callback),
304 | | ).unwrap();
| |__________________^ expected trait object `dyn ProcessHandler`, found struct `ClosureProcessHandler`
|
= note: expected struct `AsyncClient<dyn NotificationHandler, dyn ProcessHandler>`
found struct `AsyncClient<_, ClosureProcessHandler<[closure@organelle/src/main.rs:216:32: 299:10]>>`
I have no idea what types to pass for the generic parameters N and P so that this code would compile.
Unit tests for organelle should exist.
I started, but hit a problem: I want a function that iterates the main loop. For that I want to store the jack AsyncClient struct somewhere once the audio starts.
At the moment its a local variable with auto type:
This works!
If I give a type (needed to return it to caller):
This fails:
I have no idea what types to pass for the generic parameters
N
andP
so that this code would compile.