JACK Host (#389)

Co-authored-by: Federico Dolce <psykopear@gmail.com>
This commit is contained in:
Erik Natanael Gustafsson 2020-10-01 11:04:43 +02:00 • committed by GitHub
parent 5fec80e344
commit 2b31fe41af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 1006 additions and 0 deletions

View file

@ -16,6 +16,31 @@ use ringbuf::RingBuffer;
const LATENCY_MS: f32 = 150.0;
fn main() -> Result<(), anyhow::Error> {
// Conditionally compile with jack if the feature is specified.
#[cfg(all(
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
feature = "jack"
))]
// Manually check for flags. Can be passed through cargo with -- e.g.
// cargo run --release --example beep --features jack -- --jack
let host = if std::env::args()
.collect::<String>()
.contains(&String::from("--jack"))
{
cpal::host_from_id(cpal::available_hosts()
.into_iter()
.find(|id| *id == cpal::HostId::Jack)
.expect(
"make sure --features jack is specified. only works on OSes where jack is available",
)).expect("jack host unavailable")
} else {
cpal::default_host()
};
#[cfg(any(
not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd")),
not(feature = "jack")
))]
let host = cpal::default_host();
// Default devices.