diff --git a/src/host/webaudio/mod.rs b/src/host/webaudio/mod.rs index dc9c0d9bf..fb835b735 100644 --- a/src/host/webaudio/mod.rs +++ b/src/host/webaudio/mod.rs @@ -2,7 +2,6 @@ extern crate js_sys; extern crate wasm_bindgen; extern crate web_sys; -use self::js_sys::eval; use self::wasm_bindgen::prelude::*; use self::wasm_bindgen::JsCast; use self::web_sys::{AudioContext, AudioContextOptions}; @@ -493,11 +492,9 @@ fn default_output_device() -> Option { // Detects whether the `AudioContext` global variable is available. fn is_webaudio_available() -> bool { - if let Ok(audio_context_is_defined) = eval("typeof AudioContext !== 'undefined'") { - audio_context_is_defined.as_bool().unwrap() - } else { - false - } + js_sys::Reflect::get(&js_sys::global(), &JsValue::from("AudioContext")) + .unwrap() + .is_truthy() } // Whether or not the given stream configuration is valid for building a stream. diff --git a/src/lib.rs b/src/lib.rs index 98444c239..efea3a379 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,7 @@ //! ``` //! //! Before we can create a stream, we must decide what the configuration of the audio stream is -//! going to be. +//! going to be. //! You can query all the supported configurations with the //! [`supported_input_configs()`] and [`supported_output_configs()`] methods. //! These produce a list of [`SupportedStreamConfigRange`] structs which can later be turned into @@ -225,7 +225,7 @@ pub type FrameCount = u32; /// behavior of the given host. Note, the default buffer size may be surprisingly /// large, leading to latency issues. If low latency is desired, [`Fixed(FrameCount)`] /// should be used in accordance with the [`SupportedBufferSize`] range produced by -/// the [`SupportedStreamConfig`] API. +/// the [`SupportedStreamConfig`] API. /// /// [`Default`]: BufferSize::Default /// [`Fixed(FrameCount)`]: BufferSize::Fixed @@ -243,7 +243,8 @@ impl wasm_bindgen::describe::WasmDescribe for BufferSize { #[cfg(target_os = "emscripten")] impl wasm_bindgen::convert::IntoWasmAbi for BufferSize { - type Abi = Option; + type Abi = as wasm_bindgen::convert::IntoWasmAbi>::Abi; + fn into_abi(self) -> Self::Abi { match self { Self::Default => None,