diff options
| author | Eskil Queseth <eskilq@kth.se> | 2020-11-16 21:14:29 +0100 |
|---|---|---|
| committer | Eskil Queseth <eskilq@kth.se> | 2020-11-16 21:14:29 +0100 |
| commit | 505e850afab903797eba40bdc6c852f09dfa186f (patch) | |
| tree | 805c2ac76797d02d318caaa472cd6b91bf32e30f /mumd | |
| parent | 292ba0307ebcf14ab8362f8f8f276a67d38a93ea (diff) | |
| download | mum-505e850afab903797eba40bdc6c852f09dfa186f.tar.gz | |
clean up conditional compilation
Diffstat (limited to 'mumd')
| -rw-r--r-- | mumd/Cargo.toml | 6 | ||||
| -rw-r--r-- | mumd/src/audio.rs | 20 | ||||
| -rw-r--r-- | mumd/src/notify.rs | 6 |
3 files changed, 15 insertions, 17 deletions
diff --git a/mumd/Cargo.toml b/mumd/Cargo.toml index 1096041..e124eb4 100644 --- a/mumd/Cargo.toml +++ b/mumd/Cargo.toml @@ -9,13 +9,11 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = [] - -all = ["libnotify", "hound", "samplerate"] +default = ["notifications", "sound_effects"] notifications = ["libnotify"] -sounds = ["hound", "samplerate"] +sound_effects = ["hound", "samplerate"] [dependencies] mumlib = { path = "../mumlib" } diff --git a/mumd/src/audio.rs b/mumd/src/audio.rs index 316d66b..2e9d1bd 100644 --- a/mumd/src/audio.rs +++ b/mumd/src/audio.rs @@ -1,14 +1,14 @@ pub mod input; pub mod output; -#[cfg(any(feature = "sounds", feature = "all"))] +#[cfg(feature = "sound_effects")] use crate::audio::output::SaturatingAdd; use cpal::traits::{DeviceTrait, HostTrait, StreamTrait}; use cpal::{SampleFormat, SampleRate, Stream, StreamConfig}; use log::*; use mumble_protocol::voice::VoicePacketPayload; use opus::Channels; -#[cfg(any(feature = "sounds", feature = "all"))] +#[cfg(feature = "sound_effects")] use samplerate::ConverterType; use std::collections::hash_map::Entry; use std::collections::{HashMap, VecDeque}; @@ -16,7 +16,7 @@ use std::sync::{Arc, Mutex}; use tokio::sync::{mpsc, watch}; //TODO? move to mumlib -#[cfg(any(feature = "sounds", feature = "all"))] +#[cfg(feature = "sound_effects")] pub const EVENT_SOUNDS: &[(&str, NotificationEvents)] = &[ ("resources/connect.wav", NotificationEvents::ServerConnect), ( @@ -75,10 +75,10 @@ pub struct Audio { client_streams: Arc<Mutex<HashMap<u32, output::ClientStream>>>, - #[cfg(any(feature = "sounds", feature = "all"))] + #[cfg(feature = "sound_effects")] sounds: HashMap<NotificationEvents, Vec<f32>>, - #[cfg(any(feature = "sounds", feature = "all"))] + #[cfg(feature = "sound_effects")] play_sounds: Arc<Mutex<VecDeque<f32>>>, } @@ -220,7 +220,7 @@ impl Audio { output_stream.play().unwrap(); - #[cfg(any(feature = "sounds", feature = "all"))] + #[cfg(feature = "sound_effects")] let sounds = EVENT_SOUNDS .iter() .map(|(path, event)| { @@ -255,11 +255,11 @@ impl Audio { input_volume_sender, input_channel_receiver: Some(input_receiver), client_streams, - #[cfg(any(feature = "sounds", feature = "all"))] + #[cfg(feature = "sound_effects")] sounds, output_volume_sender, user_volumes, - #[cfg(any(feature = "sounds", feature = "all"))] + #[cfg(feature = "sound_effects")] play_sounds, } } @@ -343,7 +343,7 @@ impl Audio { } } - #[cfg(any(feature = "sounds", feature = "all"))] + #[cfg(feature = "sound_effects")] pub fn play_effect(&self, effect: NotificationEvents) { let samples = self.sounds.get(&effect).unwrap(); @@ -357,6 +357,6 @@ impl Audio { play_sounds.extend(samples.iter().skip(l)); } - #[cfg(not(any(feature = "sounds", feature = "all")))] + #[cfg(not(feature = "sound_effects"))] pub fn play_effect(&self, _: NotificationEvents) {} } diff --git a/mumd/src/notify.rs b/mumd/src/notify.rs index eaed3dc..ee387cc 100644 --- a/mumd/src/notify.rs +++ b/mumd/src/notify.rs @@ -1,9 +1,9 @@ pub fn init() { - #[cfg(any(feature = "notifications", feature = "all"))] + #[cfg(feature = "notifications")] libnotify::init("mumd").unwrap(); } -#[cfg(any(feature = "notifications", feature = "all"))] +#[cfg(feature = "notifications")] pub fn send(msg: String) -> Option<bool> { match libnotify::Notification::new("mumd", Some(msg.as_str()), None).show() { Ok(_) => Some(true), @@ -14,7 +14,7 @@ pub fn send(msg: String) -> Option<bool> { } } -#[cfg(not(any(feature = "notifications", feature = "all")))] +#[cfg(not(feature = "notifications"))] pub fn send(_: String) -> Option<bool> { None } |
