Fix panic in case no default audio device found when audio off

This commit is contained in:
Gilbert Röhrbein 2020-01-12 21:06:32 +01:00 committed by timokoesters
parent dc2c3b0dd7
commit c2b99f3a62

View File

@ -116,13 +116,13 @@ fn main() {
panic!("Failed to save settings: {:?}", err);
}
let mut audio = if settings.audio.audio_on {
let audio_device = match &settings.audio.audio_device {
Some(d) => d.to_string(),
None => audio::get_default_device(),
};
let audio_device = || match &settings.audio.audio_device {
Some(d) => d.to_string(),
None => audio::get_default_device(),
};
AudioFrontend::new(audio_device, 16)
let mut audio = if settings.audio.audio_on {
AudioFrontend::new(audio_device(), 16)
} else {
AudioFrontend::no_audio()
};