Improve handling of the DefaultFormatError

This commit is contained in:
mitchmindtree 2019-06-21 01:34:07 +02:00
parent fbb97f51ef
commit f0e4e312c1
4 changed files with 41 additions and 18 deletions

View file

@ -347,6 +347,12 @@ pub enum DefaultFormatError {
/// Returned if e.g. the default input format was requested on an output-only audio device.
#[fail(display = "The requested stream type is not supported by the device.")]
StreamTypeNotSupported,
/// See the `BackendSpecificError` docs for more information about this error variant.
#[fail(display = "{}", err)]
BackendSpecific {
#[fail(cause)]
err: BackendSpecificError,
}
}
/// Error that can happen when creating a `Stream`.
@ -765,6 +771,12 @@ impl From<BackendSpecificError> for SupportedFormatsError {
}
}
impl From<BackendSpecificError> for DefaultFormatError {
fn from(err: BackendSpecificError) -> Self {
DefaultFormatError::BackendSpecific { err }
}
}
// If a backend does not provide an API for retrieving supported formats, we query it with a bunch
// of commonly used rates. This is always the case for wasapi and is sometimes the case for alsa.
//