From f03fd69b654d554ca9a7d4cd4b680354ca058af6 Mon Sep 17 00:00:00 2001 From: mitchmindtree Date: Mon, 25 May 2020 19:22:23 +0200 Subject: [PATCH] [webaudio] Return Err instead of panicking on input device requests Currently we are yet to implement input stream support for CPAL's webaudio host. Instead of panicking, we should return an error, None or empty iterator in order to let the user write well behaved cross-platform apps and notify the user accordingly rather than crashing. --- src/host/webaudio/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/host/webaudio/mod.rs b/src/host/webaudio/mod.rs index 3153a90..94818a9 100644 --- a/src/host/webaudio/mod.rs +++ b/src/host/webaudio/mod.rs @@ -85,7 +85,8 @@ impl Device { fn supported_input_configs( &self, ) -> Result { - unimplemented!(); + // TODO + Ok(Vec::new().into_iter()) } #[inline] @@ -105,7 +106,8 @@ impl Device { #[inline] fn default_input_config(&self) -> Result { - unimplemented!(); + // TODO + Err(DefaultStreamConfigError::StreamTypeNotSupported) } #[inline] @@ -167,7 +169,8 @@ impl DeviceTrait for Device { D: FnMut(&Data, &InputCallbackInfo) + Send + 'static, E: FnMut(StreamError) + Send + 'static, { - unimplemented!() + // TODO + Err(BuildStreamError::StreamConfigNotSupported) } /// Create an output stream. @@ -406,7 +409,8 @@ impl Iterator for Devices { #[inline] fn default_input_device() -> Option { - unimplemented!(); + // TODO + None } #[inline]