Skip to content

Commit

Permalink
Replace old implementation with contrib version.
Browse files Browse the repository at this point in the history
  • Loading branch information
wmedrano committed Sep 14, 2024
1 parent a91ea2e commit 14994bf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/sine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn main() {
// Continue as normal
jack::Control::Continue
},
move |_, _| jack::Control::Continue,
move |_, _, _| jack::Control::Continue,
);

// 4. Activate the client. Also connect the ports to the system audio.
Expand Down
24 changes: 2 additions & 22 deletions src/client/handler_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,5 @@ impl ProcessHandler for () {

/// Wrap a closure that can handle the `process` callback. This is called every time data from ports
/// is available from JACK.
pub struct ClosureProcessHandler<F: 'static + Send + FnMut(&Client, &ProcessScope) -> Control> {
pub process_fn: F,
}

impl<F> ClosureProcessHandler<F>
where
F: 'static + Send + FnMut(&Client, &ProcessScope) -> Control,
{
#[deprecated = "Use jack::contrib::ClosureProcessHandler instead of jack::ClosureProcessHandler"]
pub fn new(f: F) -> ClosureProcessHandler<F> {
ClosureProcessHandler { process_fn: f }
}
}

impl<F> ProcessHandler for ClosureProcessHandler<F>
where
F: 'static + Send + FnMut(&Client, &ProcessScope) -> Control,
{
fn process(&mut self, c: &Client, ps: &ProcessScope) -> Control {
(self.process_fn)(c, ps)
}
}
#[deprecated = "Prefer using jack::contrib::ClosureProcessHandler directly."]
pub type ClosureProcessHandler<F> = crate::contrib::ClosureProcessHandler<(), F>;
1 change: 1 addition & 0 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub use self::client_options::ClientOptions;
pub use self::client_status::ClientStatus;
pub use self::common::CLIENT_NAME_SIZE;

#[allow(deprecated)]
pub use self::handler_impls::ClosureProcessHandler;

// client.rs excluding functionality that involves ports or callbacks
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
//! callback. For example, `Port<AudioIn>::as_mut_slice` returns a audio buffer that can be written
//! to.

#[allow(deprecated)]
pub use crate::client::ClosureProcessHandler;
pub use crate::client::{
AsyncClient, Client, ClientOptions, ClientStatus, ClosureProcessHandler, CycleTimes,
InternalClientID, NotificationHandler, ProcessHandler, ProcessScope, CLIENT_NAME_SIZE,
AsyncClient, Client, ClientOptions, ClientStatus, CycleTimes, InternalClientID,
NotificationHandler, ProcessHandler, ProcessScope, CLIENT_NAME_SIZE,
};
pub use crate::jack_enums::{Control, Error, LatencyType};
pub use crate::logging::{set_logger, LoggerType};
Expand Down Expand Up @@ -68,6 +70,7 @@ mod properties;
mod ringbuffer;
mod transport;

/// A collection of useful but optional functionality.
pub mod contrib {
mod closure;

Expand Down

0 comments on commit 14994bf

Please sign in to comment.