From 223f28262a80ac0b81688eb58507a4fb243e0694 Mon Sep 17 00:00:00 2001 From: James Liu Date: Sun, 5 Jun 2022 17:18:23 -0700 Subject: [PATCH] Update dependencies, switch to once_cell (#673) --- Cargo.toml | 10 ++++----- asio-sys/Cargo.toml | 2 +- asio-sys/src/bindings/mod.rs | 22 ++++++++++---------- asio-sys/src/lib.rs | 3 +-- src/host/wasapi/device.rs | 39 ++++++++++++++++++------------------ src/lib.rs | 5 +---- 6 files changed, 38 insertions(+), 43 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 15898db..ddff354 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,11 +25,11 @@ clap = { version = "3.1", default-features = false, features = ["std"] } ndk-glue = "0.6" [target.'cfg(target_os = "windows")'.dependencies] -winapi = { version = "0.3", features = ["audiosessiontypes", "audioclient", "coml2api", "combaseapi", "debug", "devpkey", "handleapi", "ksmedia", "mmdeviceapi", "objbase", "profileapi", "std", "synchapi", "winbase", "winuser"] } +winapi = { version = "0.3", features = ["audiosessiontypes", "audioclient", "coml2api", "combaseapi", "debug", "devpkey", "errhandlingapi", "handleapi", "ksmedia", "mmdeviceapi", "objbase", "profileapi", "std", "synchapi", "winbase", "winuser"] } asio-sys = { version = "0.2", path = "asio-sys", optional = true } num-traits = { version = "0.2.6", optional = true } -parking_lot = "0.11" -lazy_static = "1.4" +parking_lot = "0.12" +once_cell = "1.12" [target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))'.dependencies] alsa = "0.6" @@ -43,10 +43,10 @@ core-foundation-sys = "0.8.2" # For linking to CoreFoundation.framework and hand mach = "0.3" # For access to mach_timebase type. [target.'cfg(target_os = "macos")'.dependencies] -coreaudio-rs = { version = "0.10.0", default-features = false, features = ["audio_unit", "core_audio"] } +coreaudio-rs = { version = "0.10", default-features = false, features = ["audio_unit", "core_audio"] } [target.'cfg(target_os = "ios")'.dependencies] -coreaudio-rs = { version = "0.10.0", default-features = false, features = ["audio_unit", "core_audio", "audio_toolbox"] } +coreaudio-rs = { version = "0.10", default-features = false, features = ["audio_unit", "core_audio", "audio_toolbox"] } [target.'cfg(target_os = "emscripten")'.dependencies] stdweb = { version = "0.1.3", default-features = false } diff --git a/asio-sys/Cargo.toml b/asio-sys/Cargo.toml index 3266b76..93d79e4 100644 --- a/asio-sys/Cargo.toml +++ b/asio-sys/Cargo.toml @@ -15,6 +15,6 @@ walkdir = "2" cc = "1.0.25" [dependencies] -lazy_static = "1.0.0" +once_cell = "1.12" num-derive = "0.3" num-traits = "0.2" diff --git a/asio-sys/src/bindings/mod.rs b/asio-sys/src/bindings/mod.rs index db9168f..07e5e94 100644 --- a/asio-sys/src/bindings/mod.rs +++ b/asio-sys/src/bindings/mod.rs @@ -4,6 +4,7 @@ pub mod errors; use self::errors::{AsioError, AsioErrorWrapper, LoadDriverError}; use num_traits::FromPrimitive; +use once_cell::sync::Lazy; use std::ffi::CStr; use std::ffi::CString; use std::os::raw::{c_char, c_double, c_long, c_void}; @@ -248,17 +249,16 @@ struct BufferSizes { #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct CallbackId(usize); -lazy_static! { - /// A global way to access all the callbacks. - /// - /// This is required because of how ASIO calls the `buffer_switch` function with no data - /// parameters. - /// - /// Options are used so that when a callback is removed we don't change the Vec indices. - /// - /// The indices are how we match a callback with a stream. - static ref BUFFER_CALLBACK: Mutex> = Mutex::new(Vec::new()); -} +/// A global way to access all the callbacks. +/// +/// This is required because of how ASIO calls the `buffer_switch` function with no data +/// parameters. +/// +/// Options are used so that when a callback is removed we don't change the Vec indices. +/// +/// The indices are how we match a callback with a stream. +static BUFFER_CALLBACK: Lazy>> = + Lazy::new(|| Mutex::new(Vec::new())); impl Asio { /// Initialise the ASIO API. diff --git a/asio-sys/src/lib.rs b/asio-sys/src/lib.rs index e27209e..d9d07af 100644 --- a/asio-sys/src/lib.rs +++ b/asio-sys/src/lib.rs @@ -1,8 +1,7 @@ #![allow(non_camel_case_types)] #[allow(unused_imports)] -#[macro_use] -extern crate lazy_static; +extern crate once_cell; #[allow(unused_imports)] #[macro_use] diff --git a/src/host/wasapi/device.rs b/src/host/wasapi/device.rs index 3828177..0c8f1ec 100644 --- a/src/host/wasapi/device.rs +++ b/src/host/wasapi/device.rs @@ -4,6 +4,7 @@ use crate::{ SupportedBufferSize, SupportedStreamConfig, SupportedStreamConfigRange, SupportedStreamConfigsError, COMMON_SAMPLE_RATES, }; +use once_cell::sync::Lazy; use std; use std::ffi::OsString; use std::fmt; @@ -1068,29 +1069,27 @@ impl Endpoint { } } -lazy_static! { - static ref ENUMERATOR: Enumerator = { - // COM initialization is thread local, but we only need to have COM initialized in the - // thread we create the objects in - com::com_initialized(); +static ENUMERATOR: Lazy = Lazy::new(|| { + // COM initialization is thread local, but we only need to have COM initialized in the + // thread we create the objects in + com::com_initialized(); - // building the devices enumerator object - unsafe { - let mut enumerator: *mut IMMDeviceEnumerator = ptr::null_mut(); + // building the devices enumerator object + unsafe { + let mut enumerator: *mut IMMDeviceEnumerator = ptr::null_mut(); - let hresult = CoCreateInstance( - &CLSID_MMDeviceEnumerator, - ptr::null_mut(), - CLSCTX_ALL, - &IMMDeviceEnumerator::uuidof(), - &mut enumerator as *mut *mut IMMDeviceEnumerator as *mut _, - ); + let hresult = CoCreateInstance( + &CLSID_MMDeviceEnumerator, + ptr::null_mut(), + CLSCTX_ALL, + &IMMDeviceEnumerator::uuidof(), + &mut enumerator as *mut *mut IMMDeviceEnumerator as *mut _, + ); - check_result(hresult).unwrap(); - Enumerator(enumerator) - } - }; -} + check_result(hresult).unwrap(); + Enumerator(enumerator) + } +}); /// RAII objects around `IMMDeviceEnumerator`. struct Enumerator(*mut IMMDeviceEnumerator); diff --git a/src/lib.rs b/src/lib.rs index 8454d70..9818d77 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -141,11 +141,8 @@ //! stream.pause().unwrap(); //! ``` -#![recursion_limit = "512"] +#![recursion_limit = "2048"] -#[cfg(target_os = "windows")] -#[macro_use] -extern crate lazy_static; // Extern crate declarations with `#[macro_use]` must unfortunately be at crate root. #[cfg(target_os = "emscripten")] #[macro_use]