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)]
|
#![deny(unsafe_code)]
|
||||||
|
#![feature(bool_to_option)]
|
||||||
#![recursion_limit = "2048"]
|
#![recursion_limit = "2048"]
|
||||||
|
|
||||||
use veloren_voxygen::{
|
use veloren_voxygen::{
|
||||||
@ -44,17 +45,20 @@ fn main() {
|
|||||||
panic!("Failed to save settings: {:?}", err);
|
panic!("Failed to save settings: {:?}", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
let audio_device = settings
|
let mut audio = settings
|
||||||
.audio
|
.audio
|
||||||
.audio_device
|
.audio_on
|
||||||
.as_ref()
|
.then(|| {
|
||||||
.map(|s| s.clone())
|
settings
|
||||||
.or_else(audio::get_default_device);
|
.audio
|
||||||
|
.audio_device
|
||||||
let mut audio = match (audio_device, settings.audio.audio_on) {
|
.as_ref()
|
||||||
(Some(dev), true) => AudioFrontend::new(dev, settings.audio.max_sfx_channels),
|
.map(Clone::clone)
|
||||||
_ => AudioFrontend::no_audio()
|
.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_music_volume(settings.audio.music_volume);
|
||||||
audio.set_sfx_volume(settings.audio.sfx_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.
|
/// Audio Device that Voxygen will use to play audio.
|
||||||
pub audio_device: Option<String>,
|
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,
|
pub audio_on: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user