Get asio-sys examples working with latest API updates
This commit is contained in:
parent
09fd5562be
commit
747caeee38
|
@ -34,39 +34,22 @@ pub struct Format {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let driver_list = sys::get_driver_list();
|
for name in sys::get_driver_list() {
|
||||||
|
println!("Driver: {:?}", name);
|
||||||
let format = Format {
|
let driver = sys::Drivers::load(&name).expect("failed to load driver");
|
||||||
channels: 0,
|
let channels = driver.get_channels();
|
||||||
sample_rate: SampleRate(0),
|
let sample_rate = driver.get_sample_rate();
|
||||||
// TODO Not sure about how to set the data type
|
let in_fmt = Format {
|
||||||
data_type: SampleFormat::F32,
|
channels: channels.ins as _,
|
||||||
};
|
sample_rate: SampleRate(sample_rate.rate as _),
|
||||||
if driver_list.len() > 0 {
|
data_type: SampleFormat::F32,
|
||||||
let format = match sys::get_channels(&driver_list[0]) {
|
|
||||||
Ok(channels) => Format {
|
|
||||||
channels: channels.ins as u16,
|
|
||||||
sample_rate: format.sample_rate,
|
|
||||||
data_type: format.data_type,
|
|
||||||
},
|
|
||||||
Err(e) => {
|
|
||||||
println!("Error retrieving channels: {}", e);
|
|
||||||
format
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
let out_fmt = Format {
|
||||||
let format = match sys::get_sample_rate(&driver_list[0]) {
|
channels: channels.outs as _,
|
||||||
Ok(sample_rate) => Format {
|
sample_rate: SampleRate(sample_rate.rate as _),
|
||||||
channels: format.channels,
|
data_type: SampleFormat::F32,
|
||||||
sample_rate: SampleRate(sample_rate.rate),
|
|
||||||
data_type: format.data_type,
|
|
||||||
},
|
|
||||||
Err(e) => {
|
|
||||||
println!("Error retrieving sample rate: {}", e);
|
|
||||||
format
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
println!(" Input {:?}", in_fmt);
|
||||||
println!("Format {:?}", format);
|
println!(" Output {:?}", out_fmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,9 @@ fn main() {
|
||||||
|
|
||||||
for driver in &driver_list {
|
for driver in &driver_list {
|
||||||
println!("Driver: {}", driver);
|
println!("Driver: {}", driver);
|
||||||
}
|
|
||||||
|
|
||||||
if driver_list.len() > 0 {
|
let driver = sys::Drivers::load(driver).expect("failed to load drivers");
|
||||||
match sys::get_channels(&driver_list[0]) {
|
println!(" Channels: {:?}", driver.get_channels());
|
||||||
Ok(channels) => println!("Channels: {:?}", channels),
|
println!(" Sample rate: {:?}", driver.get_sample_rate());
|
||||||
Err(e) => println!("Error retrieving channels: {}", e),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue