mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Prevent framerate drop when accessing settings menu
Former-commit-id: f51d1b700cd328b8156c7df97d6524277cc0718b
This commit is contained in:
parent
4dfebb779e
commit
eeceef12ef
@ -17,6 +17,8 @@ use vek::*;
|
||||
|
||||
pub struct AudioFrontend {
|
||||
device: Device,
|
||||
// Performance optimisation, iterating through available audio devices takes time
|
||||
devices: Vec<Device>,
|
||||
// streams: HashMap<String, SpatialSink>, //always use SpatialSink even if no possition is used for now
|
||||
stream: SpatialSink,
|
||||
}
|
||||
@ -36,6 +38,7 @@ impl AudioFrontend {
|
||||
device,
|
||||
// streams: HashMap::<String, SpatialSink>::new(),
|
||||
stream: sink,
|
||||
devices: AudioFrontend::get_devices_raw(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,8 +76,18 @@ impl AudioFrontend {
|
||||
|
||||
/// Returns a vec of the audio devices available.
|
||||
/// Does not return rodio Device struct in case our audio backend changes.
|
||||
pub fn get_devices() -> Vec<String> {
|
||||
rodio::output_devices().map(|x| x.name()).collect()
|
||||
pub fn get_devices(&self) -> Vec<String> {
|
||||
self.devices.iter().map(|x| x.name()).collect()
|
||||
}
|
||||
|
||||
/// Returns vec of devices
|
||||
fn get_devices_raw() -> Vec<Device> {
|
||||
rodio::output_devices().collect()
|
||||
}
|
||||
|
||||
/// Caches vec of devices for later reference
|
||||
fn collect_devices(&mut self) {
|
||||
self.devices = AudioFrontend::get_devices_raw()
|
||||
}
|
||||
|
||||
/// Returns the default audio device.
|
||||
|
@ -563,7 +563,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
|
||||
// Audio Device Selector --------------------------------------------
|
||||
let device = self.global_state.audio.get_device();
|
||||
let device_list = AudioFrontend::get_devices();
|
||||
let device_list = self.global_state.audio.get_devices();
|
||||
Text::new("Volume")
|
||||
.down_from(state.ids.audio_volume_slider, 10.0)
|
||||
.font_size(14)
|
||||
|
Loading…
Reference in New Issue
Block a user