Update examples for DeviceNameError
This commit is contained in:
parent
105086a108
commit
fbb97f51ef
|
@ -1,15 +1,15 @@
|
|||
extern crate cpal;
|
||||
|
||||
fn main() {
|
||||
println!("Default Input Device:\n {:?}", cpal::default_input_device().map(|e| e.name()));
|
||||
println!("Default Output Device:\n {:?}", cpal::default_output_device().map(|e| e.name()));
|
||||
println!("Default Input Device:\n {:?}", cpal::default_input_device().map(|e| e.name().unwrap()));
|
||||
println!("Default Output Device:\n {:?}", cpal::default_output_device().map(|e| e.name().unwrap()));
|
||||
|
||||
let devices = cpal::devices().expect("failed to enumerate devices");
|
||||
println!("Devices: ");
|
||||
for (device_index, device) in devices.enumerate() {
|
||||
println!("{}. \"{}\"",
|
||||
device_index + 1,
|
||||
device.name());
|
||||
device.name().unwrap());
|
||||
|
||||
// Input formats
|
||||
if let Ok(fmt) = device.default_input_format() {
|
||||
|
|
|
@ -16,8 +16,8 @@ fn main() {
|
|||
// Default devices.
|
||||
let input_device = cpal::default_input_device().expect("Failed to get default input device");
|
||||
let output_device = cpal::default_output_device().expect("Failed to get default output device");
|
||||
println!("Using default input device: \"{}\"", input_device.name());
|
||||
println!("Using default output device: \"{}\"", output_device.name());
|
||||
println!("Using default input device: \"{}\"", input_device.name().unwrap());
|
||||
println!("Using default output device: \"{}\"", output_device.name().unwrap());
|
||||
|
||||
// We'll try and use the same format between streams to keep it simple
|
||||
let mut format = input_device.default_input_format().expect("Failed to get default format");
|
||||
|
|
|
@ -8,7 +8,7 @@ extern crate hound;
|
|||
fn main() {
|
||||
// Setup the default input device and stream with the default input format.
|
||||
let device = cpal::default_input_device().expect("Failed to get default input device");
|
||||
println!("Default input device: {}", device.name());
|
||||
println!("Default input device: {}", device.name().unwrap());
|
||||
let format = device.default_input_format().expect("Failed to get default input format");
|
||||
println!("Default input format: {:?}", format);
|
||||
let event_loop = cpal::EventLoop::new();
|
||||
|
|
Loading…
Reference in New Issue