Skip to content

Commit

Permalink
Update examples for DeviceNameError
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchmindtree committed Jun 20, 2019
1 parent 105086a commit fbb97f5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions examples/enumerate.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions examples/feedback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion examples/record_wav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit fbb97f5

Please sign in to comment.