Update dependencies, switch to once_cell (#673)
This commit is contained in:
parent
b1457e5945
commit
223f28262a
6 changed files with 38 additions and 43 deletions
10
Cargo.toml
10
Cargo.toml
|
|
@ -25,11 +25,11 @@ clap = { version = "3.1", default-features = false, features = ["std"] }
|
||||||
ndk-glue = "0.6"
|
ndk-glue = "0.6"
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[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 }
|
asio-sys = { version = "0.2", path = "asio-sys", optional = true }
|
||||||
num-traits = { version = "0.2.6", optional = true }
|
num-traits = { version = "0.2.6", optional = true }
|
||||||
parking_lot = "0.11"
|
parking_lot = "0.12"
|
||||||
lazy_static = "1.4"
|
once_cell = "1.12"
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))'.dependencies]
|
[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))'.dependencies]
|
||||||
alsa = "0.6"
|
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.
|
mach = "0.3" # For access to mach_timebase type.
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[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]
|
[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]
|
[target.'cfg(target_os = "emscripten")'.dependencies]
|
||||||
stdweb = { version = "0.1.3", default-features = false }
|
stdweb = { version = "0.1.3", default-features = false }
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,6 @@ walkdir = "2"
|
||||||
cc = "1.0.25"
|
cc = "1.0.25"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lazy_static = "1.0.0"
|
once_cell = "1.12"
|
||||||
num-derive = "0.3"
|
num-derive = "0.3"
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ pub mod errors;
|
||||||
|
|
||||||
use self::errors::{AsioError, AsioErrorWrapper, LoadDriverError};
|
use self::errors::{AsioError, AsioErrorWrapper, LoadDriverError};
|
||||||
use num_traits::FromPrimitive;
|
use num_traits::FromPrimitive;
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::os::raw::{c_char, c_double, c_long, c_void};
|
use std::os::raw::{c_char, c_double, c_long, c_void};
|
||||||
|
|
@ -248,17 +249,16 @@ struct BufferSizes {
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
pub struct CallbackId(usize);
|
pub struct CallbackId(usize);
|
||||||
|
|
||||||
lazy_static! {
|
/// A global way to access all the callbacks.
|
||||||
/// A global way to access all the callbacks.
|
///
|
||||||
///
|
/// This is required because of how ASIO calls the `buffer_switch` function with no data
|
||||||
/// This is required because of how ASIO calls the `buffer_switch` function with no data
|
/// parameters.
|
||||||
/// parameters.
|
///
|
||||||
///
|
/// Options are used so that when a callback is removed we don't change the Vec indices.
|
||||||
/// 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.
|
||||||
/// The indices are how we match a callback with a stream.
|
static BUFFER_CALLBACK: Lazy<Mutex<Vec<(CallbackId, BufferCallback)>>> =
|
||||||
static ref BUFFER_CALLBACK: Mutex<Vec<(CallbackId, BufferCallback)>> = Mutex::new(Vec::new());
|
Lazy::new(|| Mutex::new(Vec::new()));
|
||||||
}
|
|
||||||
|
|
||||||
impl Asio {
|
impl Asio {
|
||||||
/// Initialise the ASIO API.
|
/// Initialise the ASIO API.
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
#[macro_use]
|
extern crate once_cell;
|
||||||
extern crate lazy_static;
|
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ use crate::{
|
||||||
SupportedBufferSize, SupportedStreamConfig, SupportedStreamConfigRange,
|
SupportedBufferSize, SupportedStreamConfig, SupportedStreamConfigRange,
|
||||||
SupportedStreamConfigsError, COMMON_SAMPLE_RATES,
|
SupportedStreamConfigsError, COMMON_SAMPLE_RATES,
|
||||||
};
|
};
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
use std;
|
use std;
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
@ -1068,29 +1069,27 @@ impl Endpoint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
static ENUMERATOR: Lazy<Enumerator> = Lazy::new(|| {
|
||||||
static ref ENUMERATOR: Enumerator = {
|
// COM initialization is thread local, but we only need to have COM initialized in the
|
||||||
// COM initialization is thread local, but we only need to have COM initialized in the
|
// thread we create the objects in
|
||||||
// thread we create the objects in
|
com::com_initialized();
|
||||||
com::com_initialized();
|
|
||||||
|
|
||||||
// building the devices enumerator object
|
// building the devices enumerator object
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut enumerator: *mut IMMDeviceEnumerator = ptr::null_mut();
|
let mut enumerator: *mut IMMDeviceEnumerator = ptr::null_mut();
|
||||||
|
|
||||||
let hresult = CoCreateInstance(
|
let hresult = CoCreateInstance(
|
||||||
&CLSID_MMDeviceEnumerator,
|
&CLSID_MMDeviceEnumerator,
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
CLSCTX_ALL,
|
CLSCTX_ALL,
|
||||||
&IMMDeviceEnumerator::uuidof(),
|
&IMMDeviceEnumerator::uuidof(),
|
||||||
&mut enumerator as *mut *mut IMMDeviceEnumerator as *mut _,
|
&mut enumerator as *mut *mut IMMDeviceEnumerator as *mut _,
|
||||||
);
|
);
|
||||||
|
|
||||||
check_result(hresult).unwrap();
|
check_result(hresult).unwrap();
|
||||||
Enumerator(enumerator)
|
Enumerator(enumerator)
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
/// RAII objects around `IMMDeviceEnumerator`.
|
/// RAII objects around `IMMDeviceEnumerator`.
|
||||||
struct Enumerator(*mut IMMDeviceEnumerator);
|
struct Enumerator(*mut IMMDeviceEnumerator);
|
||||||
|
|
|
||||||
|
|
@ -141,11 +141,8 @@
|
||||||
//! stream.pause().unwrap();
|
//! 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.
|
// Extern crate declarations with `#[macro_use]` must unfortunately be at crate root.
|
||||||
#[cfg(target_os = "emscripten")]
|
#[cfg(target_os = "emscripten")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue