cpal/examples/enumerate.rs
mitchmindtree 3952c44c63 [macos] Implement Endpoint and Format Enumeration
Based on #195.

Also implements proper handling of the given `Endpoint` in the
macos implementation of the `build_voice` method.

Updates to the latest coreaudio-sys and coreaudio-rs which include the
additional necessary frameworks.

Also adds a line that prints the name of the default device in the
`enumeration.rs` example.

Updates the CHANGELOG for this PR.

Closes #194.
Related to #180.

Related external issues:

- RustAudio/coreaudio-sys#4
- RustAudio/coreaudio-rs#57
2018-01-28 12:40:25 +11:00

25 lines
744 B
Rust

extern crate cpal;
fn main() {
println!("Default Endpoint:\n {:?}", cpal::default_endpoint().map(|e| e.name()));
let endpoints = cpal::endpoints();
println!("Endpoints: ");
for (endpoint_index, endpoint) in endpoints.enumerate() {
println!("{}. Endpoint \"{}\" Audio formats: ",
endpoint_index + 1,
endpoint.name());
let formats = match endpoint.supported_formats() {
Ok(f) => f,
Err(e) => {
println!("Error: {:?}", e);
continue;
},
};
for (format_index, format) in formats.enumerate() {
println!("{}.{}. {:?}", endpoint_index + 1, format_index + 1, format);
}
}
}