Merge branch 'songtronix/clean-audio' into 'master'

comment out unused structs/functions in voxygen/audio

See merge request veloren/veloren!305
This commit is contained in:
Timo Koesters 2019-07-04 14:27:28 +00:00
commit 4c63af94de

View File

@ -6,7 +6,7 @@ use crossbeam::{
queue::SegQueue, queue::SegQueue,
sync::ShardedLock, sync::ShardedLock,
}; };
use rodio::{Decoder, Device, Sink, SpatialSink}; use rodio::{Decoder, Device, Sink};
use std::sync::{Arc, Condvar, Mutex}; use std::sync::{Arc, Condvar, Mutex};
use std::thread; use std::thread;
@ -92,11 +92,11 @@ impl AudioPlayer {
self.set_playing(true); self.set_playing(true);
} }
pub(crate) fn pause(&mut self) { // pub(crate) fn pause(&mut self) {
self.paused.store(true); // self.paused.store(true);
self.send(AudioPlayerMsg::AudioStop); // self.send(AudioPlayerMsg::AudioStop);
self.set_playing(false); // self.set_playing(false);
} // }
pub(crate) fn resume(&mut self) { pub(crate) fn resume(&mut self) {
self.paused.store(false); self.paused.store(false);
@ -104,12 +104,12 @@ impl AudioPlayer {
self.set_playing(true); self.set_playing(true);
} }
pub(crate) fn stop(&mut self) { // pub(crate) fn stop(&mut self) {
self.paused.store(false); // self.paused.store(false);
self.send(AudioPlayerMsg::AudioStop); // self.send(AudioPlayerMsg::AudioStop);
self.emit(Action::Stop); // self.emit(Action::Stop);
self.set_playing(false); // self.set_playing(false);
} // }
pub(crate) fn is_paused(&self) -> bool { pub(crate) fn is_paused(&self) -> bool {
self.paused.load() self.paused.load()
@ -220,9 +220,9 @@ impl Jukebox {
// TODO: The `update` function should associate with `conrod` to visualise the audio playlist // TODO: The `update` function should associate with `conrod` to visualise the audio playlist
// and settings. // and settings.
pub(crate) fn update(&mut self, _msg: AudioPlayerMsg) { // pub(crate) fn update(&mut self, _msg: AudioPlayerMsg) {
unimplemented!() // unimplemented!()
} // }
/// Display the current genre. /// Display the current genre.
pub(crate) fn get_genre(&self) -> Genre { pub(crate) fn get_genre(&self) -> Genre {
@ -258,9 +258,9 @@ impl AudioDevice {
} }
/// Caches vec of devices for later reference /// Caches vec of devices for later reference
pub(crate) fn update_devices(&mut self) { // pub(crate) fn update_devices(&mut self) {
self.devices = list_devices_raw() // self.devices = list_devices_raw()
} // }
/// Returns the name of the current audio device. /// Returns the name of the current audio device.
/// Does not return rodio Device struct in case our audio backend changes. /// Does not return rodio Device struct in case our audio backend changes.
@ -274,10 +274,10 @@ struct MonoEmitter {
stream: Sink, stream: Sink,
} }
struct StereoEmitter { // struct StereoEmitter {
device: AudioDevice, // device: AudioDevice,
stream: SpatialSink, // stream: SpatialSink,
} // }
impl MonoEmitter { impl MonoEmitter {
fn new(settings: &AudioSettings) -> Self { fn new(settings: &AudioSettings) -> Self {
@ -315,51 +315,51 @@ impl AudioConfig for MonoEmitter {
} }
} }
impl StereoEmitter { // impl StereoEmitter {
fn new(settings: &AudioSettings) -> Self { // fn new(settings: &AudioSettings) -> Self {
let device = AudioDevice::new(settings); // let device = AudioDevice::new(settings);
let sink = SpatialSink::new( // let sink = SpatialSink::new(
&device.device, // &device.device,
[0.0, 0.0, 0.0], // [0.0, 0.0, 0.0],
[1.0, 0.0, 0.0], // [1.0, 0.0, 0.0],
[-1.0, 0.0, 0.0], // [-1.0, 0.0, 0.0],
); // );
sink.set_volume(settings.music_volume); // sink.set_volume(settings.music_volume);
Self { // Self {
device, // device,
stream: sink, // stream: sink,
} // }
} // }
fn play_from(&mut self, path: &str) { // fn play_from(&mut self, path: &str) {
let bufreader = load_from_path(path).unwrap(); // let bufreader = load_from_path(path).unwrap();
let src = Decoder::new(bufreader).unwrap(); // let src = Decoder::new(bufreader).unwrap();
self.stream.append(src); // self.stream.append(src);
} // }
} // }
impl AudioConfig for StereoEmitter { // impl AudioConfig for StereoEmitter {
fn set_volume(&mut self, volume: f32) { // fn set_volume(&mut self, volume: f32) {
self.stream.set_volume(volume.min(1.0).max(0.0)) // self.stream.set_volume(volume.min(1.0).max(0.0))
} // }
/// Sets the current audio device from a string. // /// Sets the current audio device from a string.
/// Does not use the rodio Device struct in case that detail changes. // /// Does not use the rodio Device struct in case that detail changes.
/// If the string is an invalid audio device, then no change is made. // /// If the string is an invalid audio device, then no change is made.
fn set_device(&mut self, name: String) { // fn set_device(&mut self, name: String) {
if let Some(dev) = rodio::output_devices().find(|x| x.name() == name) { // if let Some(dev) = rodio::output_devices().find(|x| x.name() == name) {
self.device.device = dev; // self.device.device = dev;
self.stream = SpatialSink::new( // self.stream = SpatialSink::new(
&self.device.device, // &self.device.device,
[0.0, 0.0, 0.0], // [0.0, 0.0, 0.0],
[1.0, 0.0, 0.0], // [1.0, 0.0, 0.0],
[-1.0, 0.0, 0.0], // [-1.0, 0.0, 0.0],
); // );
} // }
} // }
} // }
/// Returns the default audio device. /// Returns the default audio device.
/// Does not return rodio Device struct in case our audio backend changes. /// Does not return rodio Device struct in case our audio backend changes.