Add BackendSpecificError. Add new DevicesError.

See the documentation for both new errors for details.

The new `DevicesError` has been added to allow for returning errors when
enumerating devices. This has allowed to remove multiple potential
`panic!`s in each of the alsa, coreaudio and wasapi backends.
This commit is contained in:
mitchmindtree 2019-06-20 22:37:36 +02:00
parent cf84ab906f
commit 42fc702f53
8 changed files with 140 additions and 63 deletions

View file

@ -10,6 +10,7 @@ use stdweb::web::set_timeout;
use BuildStreamError;
use DefaultFormatError;
use DevicesError;
use Format;
use SupportedFormatsError;
use StreamData;
@ -183,6 +184,13 @@ fn is_webaudio_available() -> bool {
// Content is false if the iterator is empty.
pub struct Devices(bool);
impl Devices {
pub fn new() -> Result<Self, DevicesError> {
Ok(Self::default())
}
}
impl Default for Devices {
fn default() -> Devices {
// We produce an empty iterator if the WebAudio API isn't available.