Update dependencies, switch to once_cell (#673)

This commit is contained in:
James Liu 2022-06-05 17:18:23 -07:00 • committed by GitHub
parent b1457e5945
commit 223f28262a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 43 deletions

View file

@ -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<Enumerator> = 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);

View file

@ -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]