display error when rodio panic is fixed

This commit is contained in:
Marcel Märtens 2021-03-28 20:16:08 +02:00
parent b205358fe1
commit 614a0aac13

View File

@ -12,7 +12,7 @@ use fader::Fader;
use sfx::{SfxEvent, SfxTriggerItem}; use sfx::{SfxEvent, SfxTriggerItem};
use soundcache::{OggSound, WavSound}; use soundcache::{OggSound, WavSound};
use std::time::Duration; use std::time::Duration;
use tracing::debug; use tracing::{debug, error};
use common::assets::AssetExt; use common::assets::AssetExt;
use rodio::{source::Source, OutputStream, OutputStreamHandle, StreamError}; use rodio::{source::Source, OutputStream, OutputStreamHandle, StreamError};
@ -60,7 +60,16 @@ impl AudioFrontend {
let (stream, audio_stream) = match get_default_stream() { let (stream, audio_stream) = match get_default_stream() {
Ok(s) => (Some(s.0), Some(s.1)), Ok(s) => (Some(s.0), Some(s.1)),
Err(_) => (None, None), Err(e) => {
#[cfg(unix)]
error!(
?e,
"failed to construct audio frontend. Is `pulseaudio-alsa` installed?"
);
#[cfg(not(unix))]
error!(?e, "failed to construct audio frontend.");
(None, None)
},
}; };
let mut sfx_channels = Vec::with_capacity(max_sfx_channels); let mut sfx_channels = Vec::with_capacity(max_sfx_channels);
@ -420,7 +429,7 @@ impl AudioFrontend {
//} //}
/// Returns the default stream /// Returns the default stream
pub fn get_default_stream() -> Result<(OutputStream, OutputStreamHandle), StreamError> { fn get_default_stream() -> Result<(OutputStream, OutputStreamHandle), StreamError> {
rodio::OutputStream::try_default() rodio::OutputStream::try_default()
} }