Bump linux deps, simplify examples, remove nix dep (#712)

* bump linux dependencies, dev-dependencies, anyhow, hound, ringbuf

* update to clap v4 and simplify examples with clap_derive

* have libjack installed when running with --all-features

* don't force the patch version for libc

* allow room for version resolution with nix

* nix dependency not used anymore, remove it
This commit is contained in:
mbodmer 2022-10-23 20:59:45 +02:00 • committed by GitHub
parent 4b49fbd259
commit 97fc4edb8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 191 deletions

View file

@ -1,16 +1,18 @@
extern crate anyhow;
extern crate clap;
extern crate cpal;
use clap::arg;
use anyhow;
use clap::Parser;
use cpal::{
traits::{DeviceTrait, HostTrait, StreamTrait},
SizedSample,
FromSample, Sample, SizedSample,
};
use cpal::{FromSample, Sample};
#[derive(Debug)]
#[derive(Parser, Debug)]
#[command(version, about = "CPAL beep example", long_about = None)]
struct Opt {
/// The audio device to use
#[arg(short, long, default_value_t = String::from("default"))]
device: String,
/// Use the JACK host
#[cfg(all(
any(
target_os = "linux",
@ -20,56 +22,13 @@ struct Opt {
),
feature = "jack"
))]
#[arg(short, long)]
#[allow(dead_code)]
jack: bool,
device: String,
}
impl Opt {
fn from_args() -> Self {
let app = clap::Command::new("beep").arg(arg!([DEVICE] "The audio device to use"));
#[cfg(all(
any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd"
),
feature = "jack"
))]
let app = app.arg(arg!(-j --jack "Use the JACK host"));
let matches = app.get_matches();
let device = matches.value_of("DEVICE").unwrap_or("default").to_string();
#[cfg(all(
any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd"
),
feature = "jack"
))]
return Opt {
jack: matches.is_present("jack"),
device,
};
#[cfg(any(
not(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd"
)),
not(feature = "jack")
))]
Opt { device }
}
}
fn main() -> anyhow::Result<()> {
let opt = Opt::from_args();
let opt = Opt::parse();
// Conditionally compile with jack if the feature is specified.
#[cfg(all(