From e1907114374c842654f86b234b816f57dbbc79d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Tue, 30 Mar 2021 11:21:38 +0200 Subject: add StateError and AudioError --- mumd/src/state.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'mumd/src/state.rs') diff --git a/mumd/src/state.rs b/mumd/src/state.rs index 20fe660..858441a 100644 --- a/mumd/src/state.rs +++ b/mumd/src/state.rs @@ -3,6 +3,7 @@ pub mod server; pub mod user; use crate::audio::{Audio, NotificationEvents}; +use crate::error::StateError; use crate::network::{ConnectionInfo, VoiceStreamType}; use crate::network::tcp::{TcpEvent, TcpEventData}; use crate::notify; @@ -62,14 +63,14 @@ pub struct State { } impl State { - pub fn new() -> Self { + pub fn new() -> Result { let config = mumlib::config::read_default_cfg(); let phase_watcher = watch::channel(StatePhase::Disconnected); let audio = Audio::new( config.audio.input_volume.unwrap_or(1.0), config.audio.output_volume.unwrap_or(1.0), phase_watcher.1.clone(), - ); + ).map_err(|e| StateError::AudioError(e))?; let mut state = Self { config, server: None, @@ -77,7 +78,7 @@ impl State { phase_watcher, }; state.reload_config(); - state + Ok(state) } pub fn handle_command( -- cgit v1.2.1