2015-09-22 12:43:30 +00:00
|
|
|
extern crate cpal;
|
2019-06-21 12:55:21 +00:00
|
|
|
extern crate failure;
|
2015-09-22 12:43:30 +00:00
|
|
|
|
2019-06-21 12:55:21 +00:00
|
|
|
fn main() -> Result<(), failure::Error> {
|
|
|
|
let default_in = cpal::default_input_device().map(|e| e.name().unwrap());
|
|
|
|
let default_out = cpal::default_output_device().map(|e| e.name().unwrap());
|
|
|
|
println!("Default Input Device:\n {:?}", default_in);
|
|
|
|
println!("Default Output Device:\n {:?}", default_out);
|
2017-10-11 11:24:49 +00:00
|
|
|
|
2019-06-21 12:55:21 +00:00
|
|
|
let devices = cpal::devices()?;
|
2018-02-12 13:10:24 +00:00
|
|
|
println!("Devices: ");
|
|
|
|
for (device_index, device) in devices.enumerate() {
|
2019-06-21 12:55:21 +00:00
|
|
|
println!("{}. \"{}\"", device_index + 1, device.name()?);
|
2015-09-22 12:46:27 +00:00
|
|
|
|
2018-02-12 13:10:24 +00:00
|
|
|
// Input formats
|
|
|
|
if let Ok(fmt) = device.default_input_format() {
|
|
|
|
println!(" Default input stream format:\n {:?}", fmt);
|
|
|
|
}
|
|
|
|
let mut input_formats = match device.supported_input_formats() {
|
|
|
|
Ok(f) => f.peekable(),
|
2017-10-11 11:24:49 +00:00
|
|
|
Err(e) => {
|
|
|
|
println!("Error: {:?}", e);
|
|
|
|
continue;
|
|
|
|
},
|
2015-09-22 13:46:56 +00:00
|
|
|
};
|
2018-02-12 13:10:24 +00:00
|
|
|
if input_formats.peek().is_some() {
|
|
|
|
println!(" All supported input stream formats:");
|
|
|
|
for (format_index, format) in input_formats.enumerate() {
|
|
|
|
println!(" {}.{}. {:?}", device_index + 1, format_index + 1, format);
|
|
|
|
}
|
|
|
|
}
|
2015-09-22 13:46:56 +00:00
|
|
|
|
2018-02-12 13:10:24 +00:00
|
|
|
// Output formats
|
|
|
|
if let Ok(fmt) = device.default_output_format() {
|
|
|
|
println!(" Default output stream format:\n {:?}", fmt);
|
|
|
|
}
|
|
|
|
let mut output_formats = match device.supported_output_formats() {
|
|
|
|
Ok(f) => f.peekable(),
|
|
|
|
Err(e) => {
|
|
|
|
println!("Error: {:?}", e);
|
|
|
|
continue;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
if output_formats.peek().is_some() {
|
|
|
|
println!(" All supported output stream formats:");
|
|
|
|
for (format_index, format) in output_formats.enumerate() {
|
|
|
|
println!(" {}.{}. {:?}", device_index + 1, format_index + 1, format);
|
|
|
|
}
|
2015-09-22 12:43:30 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-21 12:55:21 +00:00
|
|
|
|
|
|
|
Ok(())
|
2015-09-22 12:43:30 +00:00
|
|
|
}
|