Update examples for switch to `thiserror`
To compensate for the removal of `failure`'s application friendly `failure::Error` trait, this `anyhow` crate has been added as a dev-dependency for the examples, but is by no means a necessity for other crates downstream of CPAL.
This commit is contained in:
parent
d9d4a906c9
commit
7b08cb0dae
|
@ -17,6 +17,7 @@ lazy_static = "1.3"
|
||||||
num-traits = "0.2.6"
|
num-traits = "0.2.6"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
anyhow = "1.0.12"
|
||||||
hound = "3.4"
|
hound = "3.4"
|
||||||
ringbuf = "0.1.6"
|
ringbuf = "0.1.6"
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
extern crate anyhow;
|
||||||
extern crate cpal;
|
extern crate cpal;
|
||||||
extern crate failure;
|
|
||||||
|
|
||||||
use cpal::traits::{DeviceTrait, EventLoopTrait, HostTrait};
|
use cpal::traits::{DeviceTrait, EventLoopTrait, HostTrait};
|
||||||
|
|
||||||
fn main() -> Result<(), failure::Error> {
|
fn main() -> Result<(), anyhow::Error> {
|
||||||
let host = cpal::default_host();
|
let host = cpal::default_host();
|
||||||
let device = host.default_output_device().expect("failed to find a default output device");
|
let device = host.default_output_device().expect("failed to find a default output device");
|
||||||
let format = device.default_output_format()?;
|
let format = device.default_output_format()?;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
extern crate cpal;
|
extern crate cpal;
|
||||||
extern crate failure;
|
extern crate anyhow;
|
||||||
|
|
||||||
use cpal::traits::{DeviceTrait, HostTrait};
|
use cpal::traits::{DeviceTrait, HostTrait};
|
||||||
|
|
||||||
fn main() -> Result<(), failure::Error> {
|
fn main() -> Result<(), anyhow::Error> {
|
||||||
println!("Supported hosts:\n {:?}", cpal::ALL_HOSTS);
|
println!("Supported hosts:\n {:?}", cpal::ALL_HOSTS);
|
||||||
let available_hosts = cpal::available_hosts();
|
let available_hosts = cpal::available_hosts();
|
||||||
println!("Available hosts:\n {:?}", available_hosts);
|
println!("Available hosts:\n {:?}", available_hosts);
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
//! Uses a delay of `LATENCY_MS` milliseconds in case the default input and output streams are not
|
//! Uses a delay of `LATENCY_MS` milliseconds in case the default input and output streams are not
|
||||||
//! precisely synchronised.
|
//! precisely synchronised.
|
||||||
|
|
||||||
|
extern crate anyhow;
|
||||||
extern crate cpal;
|
extern crate cpal;
|
||||||
extern crate failure;
|
|
||||||
extern crate ringbuf;
|
extern crate ringbuf;
|
||||||
|
|
||||||
use cpal::traits::{DeviceTrait, EventLoopTrait, HostTrait};
|
use cpal::traits::{DeviceTrait, EventLoopTrait, HostTrait};
|
||||||
|
@ -15,7 +15,7 @@ use ringbuf::RingBuffer;
|
||||||
|
|
||||||
const LATENCY_MS: f32 = 150.0;
|
const LATENCY_MS: f32 = 150.0;
|
||||||
|
|
||||||
fn main() -> Result<(), failure::Error> {
|
fn main() -> Result<(), anyhow::Error> {
|
||||||
let host = cpal::default_host();
|
let host = cpal::default_host();
|
||||||
let event_loop = host.event_loop();
|
let event_loop = host.event_loop();
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
//!
|
//!
|
||||||
//! The input data is recorded to "$CARGO_MANIFEST_DIR/recorded.wav".
|
//! The input data is recorded to "$CARGO_MANIFEST_DIR/recorded.wav".
|
||||||
|
|
||||||
|
extern crate anyhow;
|
||||||
extern crate cpal;
|
extern crate cpal;
|
||||||
extern crate failure;
|
|
||||||
extern crate hound;
|
extern crate hound;
|
||||||
|
|
||||||
use cpal::traits::{DeviceTrait, EventLoopTrait, HostTrait};
|
use cpal::traits::{DeviceTrait, EventLoopTrait, HostTrait};
|
||||||
|
|
||||||
fn main() -> Result<(), failure::Error> {
|
fn main() -> Result<(), anyhow::Error> {
|
||||||
// Use the default host for working with audio devices.
|
// Use the default host for working with audio devices.
|
||||||
let host = cpal::default_host();
|
let host = cpal::default_host();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue