Improve handling of BuildStreamError throughout crate.

This commit is contained in:
mitchmindtree 2019-06-21 02:38:59 +02:00
parent f0e4e312c1
commit ba8d354e93
4 changed files with 160 additions and 73 deletions

View file

@ -371,9 +371,15 @@ pub enum BuildStreamError {
/// Trying to use capture capabilities on an output only format yields this.
#[fail(display = "The requested device does not support this capability (invalid argument)")]
InvalidArgument,
/// The C-Layer returned an error we don't know about
#[fail(display = "An unknown error in the Backend occured")]
Unknown,
/// Occurs if adding a new Stream ID would cause an integer overflow.
#[fail(display = "Adding a new stream ID would cause an overflow")]
StreamIdOverflow,
/// See the `BackendSpecificError` docs for more information about this error variant.
#[fail(display = "{}", err)]
BackendSpecific {
#[fail(cause)]
err: BackendSpecificError,
}
}
/// An iterator yielding all `Device`s currently available to the system.
@ -777,6 +783,12 @@ impl From<BackendSpecificError> for DefaultFormatError {
}
}
impl From<BackendSpecificError> for BuildStreamError {
fn from(err: BackendSpecificError) -> Self {
BuildStreamError::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.
//