mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fix: avoid rodio API when audio is disabled
This commit is contained in:
parent
c82d1b9316
commit
a83f09bd60
@ -1,4 +1,5 @@
|
||||
#![deny(unsafe_code)]
|
||||
#![feature(bool_to_option)]
|
||||
#![recursion_limit = "2048"]
|
||||
|
||||
use veloren_voxygen::{
|
||||
@ -44,17 +45,20 @@ fn main() {
|
||||
panic!("Failed to save settings: {:?}", err);
|
||||
}
|
||||
|
||||
let audio_device = settings
|
||||
let mut audio = settings
|
||||
.audio
|
||||
.audio_device
|
||||
.as_ref()
|
||||
.map(|s| s.clone())
|
||||
.or_else(audio::get_default_device);
|
||||
|
||||
let mut audio = match (audio_device, settings.audio.audio_on) {
|
||||
(Some(dev), true) => AudioFrontend::new(dev, settings.audio.max_sfx_channels),
|
||||
_ => AudioFrontend::no_audio()
|
||||
};
|
||||
.audio_on
|
||||
.then(|| {
|
||||
settings
|
||||
.audio
|
||||
.audio_device
|
||||
.as_ref()
|
||||
.map(Clone::clone)
|
||||
.or_else(audio::get_default_device)
|
||||
})
|
||||
.flatten()
|
||||
.map(|dev| AudioFrontend::new(dev, settings.audio.max_sfx_channels))
|
||||
.unwrap_or_else(AudioFrontend::no_audio);
|
||||
|
||||
audio.set_music_volume(settings.audio.music_volume);
|
||||
audio.set_sfx_volume(settings.audio.sfx_volume);
|
||||
|
@ -474,6 +474,11 @@ pub struct AudioSettings {
|
||||
|
||||
/// Audio Device that Voxygen will use to play audio.
|
||||
pub audio_device: Option<String>,
|
||||
/// Veloren's audio system wont work on some systems,
|
||||
/// so you can use this to disable it, and allow the
|
||||
/// game to function
|
||||
// If this option is disabled, functions in the rodio
|
||||
// library MUST NOT be called.
|
||||
pub audio_on: bool,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user