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/audio.rs | |
| parent | ac6b6e462f8dd7b6ab73e12b55de07b5019f232d (diff) | |
| download | mum-292ba0307ebcf14ab8362f8f8f276a67d38a93ea.tar.gz | |
change some things with extra features
Diffstat (limited to 'mumd/src/audio.rs')
| -rw-r--r-- | mumd/src/audio.rs | 12 |
1 files changed, 12 insertions, 0 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) {} } |
