From 59f87dcb375b8bb8054cd06396dcf6a1f7018674 Mon Sep 17 00:00:00 2001 From: Sasha Hilton Date: Wed, 10 Feb 2021 01:44:05 +0000 Subject: [PATCH] Amend conditional compilation to fail on unsupported systems --- playback/src/audio_backend/mod.rs | 11 ++++++++++- playback/src/audio_backend/rodio.rs | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/playback/src/audio_backend/mod.rs b/playback/src/audio_backend/mod.rs index a656bcd2..b9db29fc 100644 --- a/playback/src/audio_backend/mod.rs +++ b/playback/src/audio_backend/mod.rs @@ -34,7 +34,16 @@ mod jackaudio; #[cfg(feature = "jackaudio-backend")] use self::jackaudio::JackSink; -#[cfg(feature = "rodiojack-backend")] +#[cfg(all( + feature = "rodiojack-backend", + not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd")) +))] +compile_error!("Rodio JACK backend is currently only supported on linux."); + +#[cfg(all( + feature = "rodiojack-backend", + any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd") +))] use self::rodio::JackRodioSink; #[cfg(feature = "gstreamer-backend")] diff --git a/playback/src/audio_backend/rodio.rs b/playback/src/audio_backend/rodio.rs index 660992e2..866e8a8c 100644 --- a/playback/src/audio_backend/rodio.rs +++ b/playback/src/audio_backend/rodio.rs @@ -12,7 +12,10 @@ pub struct RodioSink { stream: rodio::OutputStream, } -#[cfg(feature = "rodiojack-backend")] +#[cfg(all( + feature = "rodiojack-backend", + any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd") +))] pub struct JackRodioSink { jackrodio_sink: rodio::Sink, // We have to keep hold of this object, or the Sink can't play... @@ -117,7 +120,10 @@ impl Open for RodioSink { } } -#[cfg(feature = "rodiojack-backend")] +#[cfg(all( + feature = "rodiojack-backend", + any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd") +))] impl Open for JackRodioSink { fn open(device: Option) -> JackRodioSink { let host = cpal::host_from_id( @@ -173,7 +179,10 @@ impl Sink for RodioSink { } } -#[cfg(feature = "rodiojack-backend")] +#[cfg(all( + feature = "rodiojack-backend", + any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd") +))] impl Sink for JackRodioSink { fn start(&mut self) -> io::Result<()> { // More similar to an "unpause" than "play". Doesn't undo "stop".