|
1 |
| -use *; |
| 1 | +use super::{JackNFrames, JackPort, JackStatus, JackConnection, Deactivated}; |
| 2 | +use jack_sys::*; |
2 | 3 | use std::panic::{AssertUnwindSafe, catch_unwind};
|
| 4 | +use std::ffi::CStr; |
| 5 | +use libc; |
| 6 | +use errors::*; |
3 | 7 |
|
4 | 8 | /// Context for some callbacks.
|
5 | 9 | pub struct JackCallbackContext {
|
6 |
| - nframes: jack_nframes_t |
| 10 | + nframes: JackNFrames |
7 | 11 | }
|
8 | 12 |
|
9 | 13 | impl JackCallbackContext {
|
@@ -61,13 +65,13 @@ pub trait JackHandler: Send {
|
61 | 65 | /// This is called whenever the size of the the buffer that will be passed to the
|
62 | 66 | /// `process()` function is about to change.
|
63 | 67 | /// Clients that depend on knowing the buffer size must implement this callback.
|
64 |
| - fn buffer_size(&mut self, _new_size: jack_nframes_t) -> JackControl { JackControl::Continue } |
| 68 | + fn buffer_size(&mut self, _new_size: JackNFrames) -> JackControl { JackControl::Continue } |
65 | 69 | /// Called whenever the system sample rate changes.
|
66 | 70 | ///
|
67 | 71 | /// Given that the JACK API exposes no way to change the sample rate, the library author
|
68 | 72 | /// would like you to know that this is a decidedly rare occurence. Still, it's worth
|
69 | 73 | /// being prepared ;)
|
70 |
| - fn sample_rate(&mut self, _new_rate: jack_nframes_t) -> JackControl { JackControl::Continue } |
| 74 | + fn sample_rate(&mut self, _new_rate: JackNFrames) -> JackControl { JackControl::Continue } |
71 | 75 | /// Called just once after the creation of the thread in which all other callbacks are
|
72 | 76 | /// handled.
|
73 | 77 | fn thread_init(&mut self) { }
|
@@ -104,13 +108,13 @@ impl<F> JackHandler for F where F: FnMut(&JackCallbackContext) -> JackControl +
|
104 | 108 | self(ctx)
|
105 | 109 | }
|
106 | 110 | }
|
107 |
| -unsafe extern "C" fn buffer_size_callback<T>(frames: jack_nframes_t, user: *mut libc::c_void) -> libc::c_int where T: JackHandler { |
| 111 | +unsafe extern "C" fn buffer_size_callback<T>(frames: JackNFrames, user: *mut libc::c_void) -> libc::c_int where T: JackHandler { |
108 | 112 | let callbacks = &mut *(user as *mut T);
|
109 | 113 | catch_unwind(AssertUnwindSafe(|| {
|
110 | 114 | callbacks.buffer_size(frames) as _
|
111 | 115 | })).unwrap_or(-1)
|
112 | 116 | }
|
113 |
| -unsafe extern "C" fn sample_rate_callback<T>(frames: jack_nframes_t, user: *mut libc::c_void) -> libc::c_int where T: JackHandler { |
| 117 | +unsafe extern "C" fn sample_rate_callback<T>(frames: JackNFrames, user: *mut libc::c_void) -> libc::c_int where T: JackHandler { |
114 | 118 | let callbacks = &mut *(user as *mut T);
|
115 | 119 | catch_unwind(AssertUnwindSafe(|| {
|
116 | 120 | callbacks.sample_rate(frames) as _
|
@@ -139,7 +143,7 @@ unsafe extern "C" fn thread_init_callback<T>(user: *mut libc::c_void) where T: J
|
139 | 143 | callbacks.thread_init()
|
140 | 144 | }));
|
141 | 145 | }
|
142 |
| -unsafe extern "C" fn process_callback<T>(nframes: jack_nframes_t, user: *mut libc::c_void) -> libc::c_int where T: JackHandler { |
| 146 | +unsafe extern "C" fn process_callback<T>(nframes: JackNFrames, user: *mut libc::c_void) -> libc::c_int where T: JackHandler { |
143 | 147 | let callbacks = &mut *(user as *mut T);
|
144 | 148 | let ctx = JackCallbackContext {
|
145 | 149 | nframes: nframes
|
|
0 commit comments