[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.
This commit is contained in:
mitchmindtree 2020-05-25 19:22:23 +02:00
parent 1dfdeace25
commit f03fd69b65
1 changed files with 8 additions and 4 deletions

View File

@ -85,7 +85,8 @@ impl Device {
fn supported_input_configs(
&self,
) -> Result<SupportedInputConfigs, SupportedStreamConfigsError> {
unimplemented!();
// TODO
Ok(Vec::new().into_iter())
}
#[inline]
@ -105,7 +106,8 @@ impl Device {
#[inline]
fn default_input_config(&self) -> Result<SupportedStreamConfig, DefaultStreamConfigError> {
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<Device> {
unimplemented!();
// TODO
None
}
#[inline]