diff options
| author | Eskil Queseth <eskilq@kth.se> | 2020-11-16 19:48:27 +0100 |
|---|---|---|
| committer | Eskil Queseth <eskilq@kth.se> | 2020-11-16 19:48:27 +0100 |
| commit | 292ba0307ebcf14ab8362f8f8f276a67d38a93ea (patch) | |
| tree | 458aaa2e0da8c50d107dfbcb05f1e83d1ffc4c26 /mumd/src | |
| parent | ac6b6e462f8dd7b6ab73e12b55de07b5019f232d (diff) | |
| download | mum-292ba0307ebcf14ab8362f8f8f276a67d38a93ea.tar.gz | |
change some things with extra features
Diffstat (limited to 'mumd/src')
| -rw-r--r-- | mumd/src/audio.rs | 12 | ||||
| -rw-r--r-- | mumd/src/notify.rs | 6 |
2 files changed, 15 insertions, 3 deletions
diff --git a/mumd/src/audio.rs b/mumd/src/audio.rs index a51c2f2..316d66b 100644 --- a/mumd/src/audio.rs +++ b/mumd/src/audio.rs @@ -1,12 +1,14 @@ pub mod input; pub mod output; +#[cfg(any(feature = "sounds", feature = "all"))] 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"))] use samplerate::ConverterType; use std::collections::hash_map::Entry; use std::collections::{HashMap, VecDeque}; @@ -14,6 +16,7 @@ use std::sync::{Arc, Mutex}; use tokio::sync::{mpsc, watch}; //TODO? move to mumlib +#[cfg(any(feature = "sounds", feature = "all"))] pub const EVENT_SOUNDS: &[(&str, NotificationEvents)] = &[ ("resources/connect.wav", NotificationEvents::ServerConnect), ( @@ -72,8 +75,10 @@ pub struct Audio { client_streams: Arc<Mutex<HashMap<u32, output::ClientStream>>>, + #[cfg(any(feature = "sounds", feature = "all"))] sounds: HashMap<NotificationEvents, Vec<f32>>, + #[cfg(any(feature = "sounds", feature = "all"))] play_sounds: Arc<Mutex<VecDeque<f32>>>, } @@ -215,6 +220,7 @@ impl Audio { output_stream.play().unwrap(); + #[cfg(any(feature = "sounds", feature = "all"))] let sounds = EVENT_SOUNDS .iter() .map(|(path, event)| { @@ -249,9 +255,11 @@ impl Audio { input_volume_sender, input_channel_receiver: Some(input_receiver), client_streams, + #[cfg(any(feature = "sounds", feature = "all"))] sounds, output_volume_sender, user_volumes, + #[cfg(any(feature = "sounds", feature = "all"))] play_sounds, } } @@ -335,6 +343,7 @@ impl Audio { } } + #[cfg(any(feature = "sounds", feature = "all"))] pub fn play_effect(&self, effect: NotificationEvents) { let samples = self.sounds.get(&effect).unwrap(); @@ -347,4 +356,7 @@ impl Audio { let l = play_sounds.len(); play_sounds.extend(samples.iter().skip(l)); } + + #[cfg(not(any(feature = "sounds", feature = "all")))] + pub fn play_effect(&self, _: NotificationEvents) {} } diff --git a/mumd/src/notify.rs b/mumd/src/notify.rs index 0739c58..eaed3dc 100644 --- a/mumd/src/notify.rs +++ b/mumd/src/notify.rs @@ -1,9 +1,9 @@ pub fn init() { - #[cfg(feature = "libnotify")] + #[cfg(any(feature = "notifications", feature = "all"))] libnotify::init("mumd").unwrap(); } -#[cfg(feature = "libnotify")] +#[cfg(any(feature = "notifications", feature = "all"))] 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(feature = "libnotify"))] +#[cfg(not(any(feature = "notifications", feature = "all")))] pub fn send(_: String) -> Option<bool> { None } |
