From 73a035617b6c7f3c7938c3754647483898af9356 Mon Sep 17 00:00:00 2001 From: pin <90570748+0323pin@users.noreply.github.com> Date: Sat, 8 Oct 2022 14:55:50 +0200 Subject: [PATCH] Fix CI failure (#705) --- examples/beep.rs | 42 ++++++++++++++++++++++++++++++++++++------ examples/feedback.rs | 42 ++++++++++++++++++++++++++++++++++++------ examples/record_wav.rs | 42 ++++++++++++++++++++++++++++++++++++------ src/host/mod.rs | 14 ++++++++++++-- src/platform/mod.rs | 7 ++++++- 5 files changed, 126 insertions(+), 21 deletions(-) diff --git a/examples/beep.rs b/examples/beep.rs index 7deb717..5f71098 100644 --- a/examples/beep.rs +++ b/examples/beep.rs @@ -12,7 +12,12 @@ use cpal::{FromSample, Sample}; #[derive(Debug)] struct Opt { #[cfg(all( - any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"), + any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + ), feature = "jack" ))] jack: bool, @@ -24,7 +29,12 @@ 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"), + 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")); @@ -32,7 +42,12 @@ impl Opt { 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"), + any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + ), feature = "jack" ))] return Opt { @@ -41,7 +56,12 @@ impl Opt { }; #[cfg(any( - not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd")), + not(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + )), not(feature = "jack") ))] Opt { device } @@ -53,7 +73,12 @@ fn main() -> anyhow::Result<()> { // Conditionally compile with jack if the feature is specified. #[cfg(all( - any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"), + any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + ), feature = "jack" ))] // Manually check for flags. Can be passed through cargo with -- e.g. @@ -70,7 +95,12 @@ fn main() -> anyhow::Result<()> { }; #[cfg(any( - not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd")), + not(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + )), not(feature = "jack") ))] let host = cpal::default_host(); diff --git a/examples/feedback.rs b/examples/feedback.rs index 70d11a6..42980e5 100644 --- a/examples/feedback.rs +++ b/examples/feedback.rs @@ -19,7 +19,12 @@ use ringbuf::RingBuffer; #[derive(Debug)] struct Opt { #[cfg(all( - any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"), + any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + ), feature = "jack" ))] jack: bool, @@ -38,7 +43,12 @@ impl Opt { .arg(arg!([OUT] "The output audio device to use")); #[cfg(all( - any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"), + 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")); @@ -52,7 +62,12 @@ impl Opt { let output_device = matches.value_of("OUT").unwrap_or("default").to_string(); #[cfg(all( - any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"), + any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + ), feature = "jack" ))] return Ok(Opt { @@ -63,7 +78,12 @@ impl Opt { }); #[cfg(any( - not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd")), + not(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + )), not(feature = "jack") ))] Ok(Opt { @@ -79,7 +99,12 @@ fn main() -> anyhow::Result<()> { // Conditionally compile with jack if the feature is specified. #[cfg(all( - any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"), + any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + ), feature = "jack" ))] // Manually check for flags. Can be passed through cargo with -- e.g. @@ -96,7 +121,12 @@ fn main() -> anyhow::Result<()> { }; #[cfg(any( - not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd")), + not(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + )), not(feature = "jack") ))] let host = cpal::default_host(); diff --git a/examples/record_wav.rs b/examples/record_wav.rs index 8f7ca18..0549c9b 100644 --- a/examples/record_wav.rs +++ b/examples/record_wav.rs @@ -17,7 +17,12 @@ use std::sync::{Arc, Mutex}; #[derive(Debug)] struct Opt { #[cfg(all( - any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"), + any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + ), feature = "jack" ))] jack: bool, @@ -29,7 +34,12 @@ impl Opt { fn from_args() -> Self { let app = clap::Command::new("record_wav").arg(arg!([DEVICE] "The audio device to use")); #[cfg(all( - any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"), + 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")); @@ -37,7 +47,12 @@ impl Opt { 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"), + any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + ), feature = "jack" ))] return Opt { @@ -46,7 +61,12 @@ impl Opt { }; #[cfg(any( - not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd")), + not(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + )), not(feature = "jack") ))] Opt { device } @@ -58,7 +78,12 @@ 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", target_os = "netbsd"), + any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + ), feature = "jack" ))] // Manually check for flags. Can be passed through cargo with -- e.g. @@ -75,7 +100,12 @@ fn main() -> Result<(), anyhow::Error> { }; #[cfg(any( - not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd")), + not(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + )), not(feature = "jack") ))] let host = cpal::default_host(); diff --git a/src/host/mod.rs b/src/host/mod.rs index 109a737..8de06cb 100644 --- a/src/host/mod.rs +++ b/src/host/mod.rs @@ -1,4 +1,9 @@ -#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"))] +#[cfg(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" +))] pub(crate) mod alsa; #[cfg(all(windows, feature = "asio"))] pub(crate) mod asio; @@ -7,7 +12,12 @@ pub(crate) mod coreaudio; #[cfg(target_os = "emscripten")] pub(crate) mod emscripten; #[cfg(all( - any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"), + any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" + ), feature = "jack" ))] pub(crate) mod jack; diff --git a/src/platform/mod.rs b/src/platform/mod.rs index c90ce34..fb4550c 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -562,7 +562,12 @@ macro_rules! impl_platform_host { } // TODO: Add pulseaudio and jack here eventually. -#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"))] +#[cfg(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd" +))] mod platform_impl { pub use crate::host::alsa::{ Device as AlsaDevice, Devices as AlsaDevices, Host as AlsaHost, Stream as AlsaStream,