pub struct Driver { /* private fields */ }Expand description
A handle to a single ASIO driver.
Creating an instance of this type loads and initialises the driver.
Dropping all Driver instances will automatically dispose of any resources and de-initialise
the driver.
Implementations§
Source§impl Driver
impl Driver
Sourcepub fn channels(&self) -> Result<Channels, AsioError>
pub fn channels(&self) -> Result<Channels, AsioError>
Returns the number of input and output channels available on the driver.
Examples found in repository?
3fn main() {
4 let asio = sys::Asio::new();
5 for driver in asio.driver_names() {
6 println!("Driver: {}", driver);
7 let driver = asio.load_driver(&driver).expect("failed to load drivers");
8 println!(
9 " Channels: {:?}",
10 driver.channels().expect("failed to get channels")
11 );
12 println!(
13 " Sample rate: {:?}",
14 driver.sample_rate().expect("failed to get sample rate")
15 );
16 }
17}More examples
35fn main() {
36 let asio = sys::Asio::new();
37 for name in asio.driver_names() {
38 println!("Driver: {:?}", name);
39 let driver = asio.load_driver(&name).expect("failed to load driver");
40 let channels = driver
41 .channels()
42 .expect("failed to retrieve channel counts");
43 let sample_rate = driver
44 .sample_rate()
45 .expect("failed to retrieve sample rate");
46 let in_fmt = Format {
47 channels: channels.ins as _,
48 sample_rate: sample_rate as _,
49 data_type: SampleFormat::F32,
50 };
51 let out_fmt = Format {
52 channels: channels.outs as _,
53 sample_rate: sample_rate as _,
54 data_type: SampleFormat::F32,
55 };
56 println!(" Input {:?}", in_fmt);
57 println!(" Output {:?}", out_fmt);
58 }
59}Sourcepub fn buffersize_range(&self) -> Result<(c_long, c_long), AsioError>
pub fn buffersize_range(&self) -> Result<(c_long, c_long), AsioError>
Get the min and max supported buffersize of the driver.
Sourcepub fn sample_rate(&self) -> Result<c_double, AsioError>
pub fn sample_rate(&self) -> Result<c_double, AsioError>
Get current sample rate of the driver.
Examples found in repository?
3fn main() {
4 let asio = sys::Asio::new();
5 for driver in asio.driver_names() {
6 println!("Driver: {}", driver);
7 let driver = asio.load_driver(&driver).expect("failed to load drivers");
8 println!(
9 " Channels: {:?}",
10 driver.channels().expect("failed to get channels")
11 );
12 println!(
13 " Sample rate: {:?}",
14 driver.sample_rate().expect("failed to get sample rate")
15 );
16 }
17}More examples
35fn main() {
36 let asio = sys::Asio::new();
37 for name in asio.driver_names() {
38 println!("Driver: {:?}", name);
39 let driver = asio.load_driver(&name).expect("failed to load driver");
40 let channels = driver
41 .channels()
42 .expect("failed to retrieve channel counts");
43 let sample_rate = driver
44 .sample_rate()
45 .expect("failed to retrieve sample rate");
46 let in_fmt = Format {
47 channels: channels.ins as _,
48 sample_rate: sample_rate as _,
49 data_type: SampleFormat::F32,
50 };
51 let out_fmt = Format {
52 channels: channels.outs as _,
53 sample_rate: sample_rate as _,
54 data_type: SampleFormat::F32,
55 };
56 println!(" Input {:?}", in_fmt);
57 println!(" Output {:?}", out_fmt);
58 }
59}Sourcepub fn can_sample_rate(&self, sample_rate: c_double) -> Result<bool, AsioError>
pub fn can_sample_rate(&self, sample_rate: c_double) -> Result<bool, AsioError>
Can the driver accept the given sample rate.
Sourcepub fn set_sample_rate(&self, sample_rate: c_double) -> Result<(), AsioError>
pub fn set_sample_rate(&self, sample_rate: c_double) -> Result<(), AsioError>
Set the sample rate for the driver.
Sourcepub fn input_data_type(&self) -> Result<AsioSampleType, AsioError>
pub fn input_data_type(&self) -> Result<AsioSampleType, AsioError>
Get the current data type of the driver’s input stream.
This queries a single channel’s type assuming all channels have the same sample type.
Sourcepub fn output_data_type(&self) -> Result<AsioSampleType, AsioError>
pub fn output_data_type(&self) -> Result<AsioSampleType, AsioError>
Get the current data type of the driver’s output stream.
This queries a single channel’s type assuming all channels have the same sample type.
Sourcepub fn prepare_input_stream(
&self,
output: Option<AsioStream>,
num_channels: usize,
buffer_size: Option<i32>,
) -> Result<AsioStreams, AsioError>
pub fn prepare_input_stream( &self, output: Option<AsioStream>, num_channels: usize, buffer_size: Option<i32>, ) -> Result<AsioStreams, AsioError>
Prepare the input stream.
Because only the latest call to ASIOCreateBuffers is relevant this call will destroy all past active buffers and recreate them.
For this reason we take the output stream if it exists.
num_channels is the desired number of input channels.
buffer_size sets the desired buffer_size. If None is passed in, then the
default buffersize for the device is used.
This returns a full AsioStreams with both input and output if output was active.
Sourcepub fn prepare_output_stream(
&self,
input: Option<AsioStream>,
num_channels: usize,
buffer_size: Option<i32>,
) -> Result<AsioStreams, AsioError>
pub fn prepare_output_stream( &self, input: Option<AsioStream>, num_channels: usize, buffer_size: Option<i32>, ) -> Result<AsioStreams, AsioError>
Prepare the output stream.
Because only the latest call to ASIOCreateBuffers is relevant this call will destroy all past active buffers and recreate them.
For this reason we take the input stream if it exists.
num_channels is the desired number of output channels.
buffer_size sets the desired buffer_size. If None is passed in, then the
default buffersize for the device is used.
This returns a full AsioStreams with both input and output if input was active.
Sourcepub fn dispose_buffers(&self) -> Result<(), AsioError>
pub fn dispose_buffers(&self) -> Result<(), AsioError>
Releases buffers allocations.
This will stop the stream if the driver is Running.
No-op if no buffers are allocated.
Sourcepub fn start(&self) -> Result<(), AsioError>
pub fn start(&self) -> Result<(), AsioError>
Starts ASIO streams playing.
The driver must be in the Prepared state
If called successfully, the driver will be in the Running state.
No-op if already Running.
Sourcepub fn stop(&self) -> Result<(), AsioError>
pub fn stop(&self) -> Result<(), AsioError>
Stops ASIO streams playing.
No-op if the state is not Running.
If the state was Running and the stream is stopped successfully, the driver will be in
the Prepared state.
Sourcepub fn add_callback<F>(&self, callback: F) -> CallbackId
pub fn add_callback<F>(&self, callback: F) -> CallbackId
Adds a callback to the list of active callbacks.
The given function receives the index of the buffer currently ready for processing.
Returns an ID uniquely associated with the given callback so that it may be removed later.
Sourcepub fn remove_callback(&self, rem_id: CallbackId)
pub fn remove_callback(&self, rem_id: CallbackId)
Remove the callback with the given ID.
Sourcepub fn destroy(self) -> Result<bool, AsioError>
pub fn destroy(self) -> Result<bool, AsioError>
Consumes and destroys the Driver, stopping the streams if they are running and releasing
any associated resources.
Returns Ok(true) if the driver was successfully destroyed.
Returns Ok(false) if the driver was not destroyed because another handle to the driver
still exists.
Returns Err if some switching driver states failed or if ASIO returned an error on exit.
Sourcepub fn add_message_callback<F>(&self, callback: F) -> MessageCallbackId
pub fn add_message_callback<F>(&self, callback: F) -> MessageCallbackId
Adds a callback to the list of message listeners.
Returns an ID uniquely associated with the given callback so that it may be removed later.
Sourcepub fn remove_message_callback(&self, rem_id: MessageCallbackId)
pub fn remove_message_callback(&self, rem_id: MessageCallbackId)
Remove the callback with the given ID.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Driver
impl RefUnwindSafe for Driver
impl Send for Driver
impl Sync for Driver
impl Unpin for Driver
impl UnwindSafe for Driver
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)