diff --git a/Cargo.toml b/Cargo.toml index 61440236c..fb1d984db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,18 +41,15 @@ windows = { version = "0.52.0", features = [ ]} asio-sys = { version = "0.2", path = "asio-sys", optional = true } num-traits = { version = "0.2.6", optional = true } -parking_lot = "0.12" [target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"))'.dependencies] alsa = "0.8" libc = "0.2" -parking_lot = "0.12" jack = { version = "0.11", optional = true } [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies] core-foundation-sys = "0.8.2" # For linking to CoreFoundation.framework and handling device name `CFString`s. mach2 = "0.4" # For access to mach_timebase type. -parking_lot = "0.12" [target.'cfg(target_os = "macos")'.dependencies] coreaudio-rs = { version = "0.11", default-features = false, features = ["audio_unit", "core_audio"] } diff --git a/src/host/alsa/enumerate.rs b/src/host/alsa/enumerate.rs index 0aa7fb0d7..3032861c9 100644 --- a/src/host/alsa/enumerate.rs +++ b/src/host/alsa/enumerate.rs @@ -1,8 +1,7 @@ use super::alsa; -use super::parking_lot::Mutex; use super::{Device, DeviceHandles}; use crate::{BackendSpecificError, DevicesError}; -use std::sync::Arc; +use std::sync::{Arc, Mutex}; /// ALSA's implementation for `Devices`. pub struct Devices { diff --git a/src/host/alsa/mod.rs b/src/host/alsa/mod.rs index bb483220c..86a240b98 100644 --- a/src/host/alsa/mod.rs +++ b/src/host/alsa/mod.rs @@ -1,9 +1,7 @@ extern crate alsa; extern crate libc; -extern crate parking_lot; use self::alsa::poll::Descriptors; -use self::parking_lot::Mutex; use crate::traits::{DeviceTrait, HostTrait, StreamTrait}; use crate::{ BackendSpecificError, BufferSize, BuildStreamError, ChannelCount, Data, @@ -14,7 +12,7 @@ use crate::{ }; use std::cmp; use std::convert::TryInto; -use std::sync::Arc; +use std::sync::{Arc, Mutex}; use std::thread::{self, JoinHandle}; use std::time::Duration; use std::vec::IntoIter as VecIntoIter; @@ -252,6 +250,7 @@ impl Device { let handle_result = self .handles .lock() + .unwrap() .take(&self.name, stream_type) .map_err(|e| (e, e.errno())); @@ -311,7 +310,7 @@ impl Device { &self, stream_t: alsa::Direction, ) -> Result, SupportedStreamConfigsError> { - let mut guard = self.handles.lock(); + let mut guard = self.handles.lock().unwrap(); let handle_result = guard .get_mut(&self.name, stream_t) .map_err(|e| (e, e.errno())); diff --git a/src/host/asio/device.rs b/src/host/asio/device.rs index 30db00687..f503158e8 100644 --- a/src/host/asio/device.rs +++ b/src/host/asio/device.rs @@ -1,7 +1,6 @@ pub type SupportedInputConfigs = std::vec::IntoIter; pub type SupportedOutputConfigs = std::vec::IntoIter; -use super::parking_lot::Mutex; use super::sys; use crate::BackendSpecificError; use crate::DefaultStreamConfigError; @@ -15,7 +14,7 @@ use crate::SupportedStreamConfigRange; use crate::SupportedStreamConfigsError; use std::hash::{Hash, Hasher}; use std::sync::atomic::AtomicI32; -use std::sync::Arc; +use std::sync::{Arc, Mutex}; /// A ASIO Device #[derive(Clone)] diff --git a/src/host/asio/mod.rs b/src/host/asio/mod.rs index 3cf7e8c3a..73d936d99 100644 --- a/src/host/asio/mod.rs +++ b/src/host/asio/mod.rs @@ -1,5 +1,4 @@ extern crate asio_sys as sys; -extern crate parking_lot; use crate::traits::{DeviceTrait, HostTrait, StreamTrait}; use crate::{ diff --git a/src/host/asio/stream.rs b/src/host/asio/stream.rs index f151da258..c9070005a 100644 --- a/src/host/asio/stream.rs +++ b/src/host/asio/stream.rs @@ -2,14 +2,13 @@ extern crate asio_sys as sys; extern crate num_traits; use self::num_traits::PrimInt; -use super::parking_lot::Mutex; use super::Device; use crate::{ BackendSpecificError, BufferSize, BuildStreamError, Data, InputCallbackInfo, OutputCallbackInfo, PauseStreamError, PlayStreamError, SampleFormat, StreamConfig, StreamError, }; use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; +use std::sync::{Arc, Mutex}; use std::time::Duration; pub struct Stream { @@ -77,7 +76,7 @@ impl Device { } // There is 0% chance of lock contention the host only locks when recreating streams. - let stream_lock = asio_streams.lock(); + let stream_lock = asio_streams.lock().unwrap(); let asio_stream = match stream_lock.input { Some(ref asio_stream) => asio_stream, None => return, @@ -281,7 +280,7 @@ impl Device { } // There is 0% chance of lock contention the host only locks when recreating streams. - let mut stream_lock = asio_streams.lock(); + let mut stream_lock = asio_streams.lock().unwrap(); let asio_stream = match stream_lock.output { Some(ref mut asio_stream) => asio_stream, None => return, @@ -518,7 +517,7 @@ impl Device { Err(_) => Err(BuildStreamError::StreamConfigNotSupported), }?; let num_channels = config.channels as usize; - let mut streams = self.asio_streams.lock(); + let mut streams = self.asio_streams.lock().unwrap(); let buffer_size = match config.buffer_size { BufferSize::Fixed(v) => Some(v as i32), @@ -565,7 +564,7 @@ impl Device { Err(_) => Err(BuildStreamError::StreamConfigNotSupported), }?; let num_channels = config.channels as usize; - let mut streams = self.asio_streams.lock(); + let mut streams = self.asio_streams.lock().unwrap(); let buffer_size = match config.buffer_size { BufferSize::Fixed(v) => Some(v as i32), diff --git a/src/host/coreaudio/macos/mod.rs b/src/host/coreaudio/macos/mod.rs index e6e3e54cf..9a14ab269 100644 --- a/src/host/coreaudio/macos/mod.rs +++ b/src/host/coreaudio/macos/mod.rs @@ -28,7 +28,6 @@ use crate::{ SupportedBufferSize, SupportedStreamConfig, SupportedStreamConfigRange, SupportedStreamConfigsError, }; -use parking_lot::Mutex; use std::ffi::CStr; use std::fmt; use std::mem; @@ -36,7 +35,7 @@ use std::os::raw::c_char; use std::ptr::null; use std::slice; use std::sync::mpsc::{channel, RecvTimeoutError}; -use std::sync::Arc; +use std::sync::{Arc, Mutex}; use std::time::{Duration, Instant}; pub use self::enumerate::{ @@ -454,7 +453,7 @@ where E: FnMut(StreamError) + Send + 'static, { let stream_copy = stream.clone(); - let mut stream_inner = stream.inner.lock(); + let mut stream_inner = stream.inner.lock().unwrap(); stream_inner._disconnect_listener = Some(AudioObjectPropertyListener::new( stream_inner.device_id, AudioObjectPropertyAddress { @@ -464,7 +463,7 @@ where }, move || { let _ = stream_copy.pause(); - (error_callback.lock())(StreamError::DeviceNotAvailable); + (error_callback.lock().unwrap())(StreamError::DeviceNotAvailable); }, )?); Ok(()) @@ -587,7 +586,7 @@ impl Device { // TODO: Need a better way to get delay, for now we assume a double-buffer offset. let callback = match host_time_to_stream_instant(args.time_stamp.mHostTime) { Err(err) => { - (error_callback.lock())(err.into()); + (error_callback.lock().unwrap())(err.into()); return Err(()); } Ok(cb) => cb, @@ -617,7 +616,7 @@ impl Device { add_disconnect_listener(&stream, error_callback_disconnect)?; } - stream.inner.lock().audio_unit.start()?; + stream.inner.lock().unwrap().audio_unit.start()?; Ok(stream) } @@ -691,7 +690,7 @@ impl Device { let callback = match host_time_to_stream_instant(args.time_stamp.mHostTime) { Err(err) => { - (error_callback.lock())(err.into()); + (error_callback.lock().unwrap())(err.into()); return Err(()); } Ok(cb) => cb, @@ -722,7 +721,7 @@ impl Device { add_disconnect_listener(&stream, error_callback_disconnect)?; } - stream.inner.lock().audio_unit.start()?; + stream.inner.lock().unwrap().audio_unit.start()?; Ok(stream) } @@ -896,7 +895,7 @@ impl Stream { impl StreamTrait for Stream { fn play(&self) -> Result<(), PlayStreamError> { - let mut stream = self.inner.lock(); + let mut stream = self.inner.lock().unwrap(); if !stream.playing { if let Err(e) = stream.audio_unit.start() { @@ -910,7 +909,7 @@ impl StreamTrait for Stream { } fn pause(&self) -> Result<(), PauseStreamError> { - let mut stream = self.inner.lock(); + let mut stream = self.inner.lock().unwrap(); if stream.playing { if let Err(e) = stream.audio_unit.stop() { diff --git a/src/host/coreaudio/mod.rs b/src/host/coreaudio/mod.rs index 47f52e3b6..f1b47f82c 100644 --- a/src/host/coreaudio/mod.rs +++ b/src/host/coreaudio/mod.rs @@ -1,5 +1,4 @@ extern crate coreaudio; -extern crate parking_lot; use self::coreaudio::sys::{ kAudioFormatFlagIsFloat, kAudioFormatFlagIsPacked, kAudioFormatLinearPCM,