Merge pull request #642 from remilauzier/master

Rust 2021 and clap 3.0
This commit is contained in:
est31 2022-02-18 15:29:07 +01:00 • committed by GitHub
commit 83b96beb44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 21 additions and 20 deletions

View file

@ -7,6 +7,7 @@ repository = "https://github.com/rustaudio/cpal"
documentation = "https://docs.rs/cpal" documentation = "https://docs.rs/cpal"
license = "Apache-2.0" license = "Apache-2.0"
keywords = ["audio", "sound"] keywords = ["audio", "sound"]
edition = "2021"
[features] [features]
asio = ["asio-sys", "num-traits"] # Only available on Windows. See README for setup instructions. asio = ["asio-sys", "num-traits"] # Only available on Windows. See README for setup instructions.
@ -18,7 +19,7 @@ thiserror = "1.0.2"
anyhow = "1.0.12" anyhow = "1.0.12"
hound = "3.4" hound = "3.4"
ringbuf = "0.2" ringbuf = "0.2"
clap = { version = "3", default-features = false, features = ["std"] } clap = { version = "3.0", default-features = false, features = ["std"] }
[target.'cfg(target_os = "android")'.dev-dependencies] [target.'cfg(target_os = "android")'.dev-dependencies]
ndk-glue = "0.6" ndk-glue = "0.6"

View file

@ -1,7 +1,7 @@
use super::alsa; use super::alsa;
use super::parking_lot::Mutex; use super::parking_lot::Mutex;
use super::{Device, DeviceHandles}; use super::{Device, DeviceHandles};
use {BackendSpecificError, DevicesError}; use crate::{BackendSpecificError, DevicesError};
/// ALSA's implementation for `Devices`. /// ALSA's implementation for `Devices`.
pub struct Devices { pub struct Devices {

View file

@ -4,6 +4,7 @@ extern crate parking_lot;
use self::alsa::poll::Descriptors; use self::alsa::poll::Descriptors;
use self::parking_lot::Mutex; use self::parking_lot::Mutex;
use crate::traits::{DeviceTrait, HostTrait, StreamTrait};
use crate::{ use crate::{
BackendSpecificError, BufferSize, BuildStreamError, ChannelCount, Data, BackendSpecificError, BufferSize, BuildStreamError, ChannelCount, Data,
DefaultStreamConfigError, DeviceNameError, DevicesError, InputCallbackInfo, OutputCallbackInfo, DefaultStreamConfigError, DeviceNameError, DevicesError, InputCallbackInfo, OutputCallbackInfo,
@ -16,7 +17,6 @@ use std::convert::TryInto;
use std::sync::Arc; use std::sync::Arc;
use std::thread::{self, JoinHandle}; use std::thread::{self, JoinHandle};
use std::vec::IntoIter as VecIntoIter; use std::vec::IntoIter as VecIntoIter;
use traits::{DeviceTrait, HostTrait, StreamTrait};
pub use self::enumerate::{default_input_device, default_output_device, Devices}; pub use self::enumerate::{default_input_device, default_output_device, Devices};

View file

@ -21,7 +21,7 @@ trait Silence {
/// Constraints on the ASIO sample types. /// Constraints on the ASIO sample types.
trait AsioSample: Clone + Copy + Silence + std::ops::Add<Self, Output = Self> { trait AsioSample: Clone + Copy + Silence + std::ops::Add<Self, Output = Self> {
fn to_cpal_sample<T: Sample>(&self) -> T; fn to_cpal_sample<T: Sample>(&self) -> T;
fn from_cpal_sample<T: Sample>(&T) -> Self; fn from_cpal_sample<T: Sample>(_: &T) -> Self;
} }
// Used to keep track of whether or not the current asio stream buffer requires // Used to keep track of whether or not the current asio stream buffer requires

View file

@ -1,7 +1,7 @@
use std::vec::IntoIter as VecIntoIter; use std::vec::IntoIter as VecIntoIter;
use DevicesError; use crate::DevicesError;
use SupportedStreamConfigRange; use crate::SupportedStreamConfigRange;
use super::Device; use super::Device;

View file

@ -20,7 +20,7 @@ use self::coreaudio::sys::{
}; };
use super::{asbd_from_config, frames_to_duration, host_time_to_stream_instant}; use super::{asbd_from_config, frames_to_duration, host_time_to_stream_instant};
use traits::{DeviceTrait, HostTrait, StreamTrait}; use crate::traits::{DeviceTrait, HostTrait, StreamTrait};
use crate::{ use crate::{
BackendSpecificError, BufferSize, BuildStreamError, Data, DefaultStreamConfigError, BackendSpecificError, BufferSize, BuildStreamError, Data, DefaultStreamConfigError,

View file

@ -8,10 +8,10 @@ use self::coreaudio::sys::{
AudioObjectPropertyAddress, OSStatus, AudioObjectPropertyAddress, OSStatus,
}; };
use super::Device; use super::Device;
use crate::{BackendSpecificError, DevicesError, SupportedStreamConfigRange};
use std::mem; use std::mem;
use std::ptr::null; use std::ptr::null;
use std::vec::IntoIter as VecIntoIter; use std::vec::IntoIter as VecIntoIter;
use {BackendSpecificError, DevicesError, SupportedStreamConfigRange};
unsafe fn audio_devices() -> Result<Vec<AudioDeviceID>, OSStatus> { unsafe fn audio_devices() -> Result<Vec<AudioDeviceID>, OSStatus> {
let property_address = AudioObjectPropertyAddress { let property_address = AudioObjectPropertyAddress {

View file

@ -5,8 +5,8 @@ use self::coreaudio::sys::{
AudioStreamBasicDescription, OSStatus, AudioStreamBasicDescription, OSStatus,
}; };
use DefaultStreamConfigError; use crate::DefaultStreamConfigError;
use {BuildStreamError, SupportedStreamConfigsError}; use crate::{BuildStreamError, SupportedStreamConfigsError};
use crate::{BackendSpecificError, SampleFormat, StreamConfig}; use crate::{BackendSpecificError, SampleFormat, StreamConfig};

View file

@ -7,13 +7,13 @@ use stdweb::web::set_timeout;
use stdweb::web::TypedArray; use stdweb::web::TypedArray;
use stdweb::Reference; use stdweb::Reference;
use crate::traits::{DeviceTrait, HostTrait, StreamTrait};
use crate::{ use crate::{
BufferSize, BuildStreamError, Data, DefaultStreamConfigError, DeviceNameError, DevicesError, BufferSize, BuildStreamError, Data, DefaultStreamConfigError, DeviceNameError, DevicesError,
InputCallbackInfo, OutputCallbackInfo, PauseStreamError, PlayStreamError, SampleFormat, InputCallbackInfo, OutputCallbackInfo, PauseStreamError, PlayStreamError, SampleFormat,
SampleRate, StreamConfig, StreamError, SupportedBufferSize, SupportedStreamConfig, SampleRate, StreamConfig, StreamError, SupportedBufferSize, SupportedStreamConfig,
SupportedStreamConfigRange, SupportedStreamConfigsError, SupportedStreamConfigRange, SupportedStreamConfigsError,
}; };
use traits::{DeviceTrait, HostTrait, StreamTrait};
// The emscripten backend currently works by instantiating an `AudioContext` object per `Stream`. // The emscripten backend currently works by instantiating an `AudioContext` object per `Stream`.
// Creating a stream creates a new `AudioContext`. Destroying a stream destroys it. Creation of a // Creating a stream creates a new `AudioContext`. Destroying a stream destroys it. Creation of a

View file

@ -1,3 +1,4 @@
use crate::traits::DeviceTrait;
use crate::{ use crate::{
BackendSpecificError, BuildStreamError, Data, DefaultStreamConfigError, DeviceNameError, BackendSpecificError, BuildStreamError, Data, DefaultStreamConfigError, DeviceNameError,
InputCallbackInfo, OutputCallbackInfo, SampleFormat, SampleRate, StreamConfig, StreamError, InputCallbackInfo, OutputCallbackInfo, SampleFormat, SampleRate, StreamConfig, StreamError,
@ -5,7 +6,6 @@ use crate::{
SupportedStreamConfigsError, SupportedStreamConfigsError,
}; };
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use traits::DeviceTrait;
use super::stream::Stream; use super::stream::Stream;
use super::JACK_SAMPLE_FORMAT; use super::JACK_SAMPLE_FORMAT;

View file

@ -1,7 +1,7 @@
extern crate jack; extern crate jack;
use crate::traits::HostTrait;
use crate::{DevicesError, SampleFormat, SupportedStreamConfigRange}; use crate::{DevicesError, SampleFormat, SupportedStreamConfigRange};
use traits::HostTrait;
mod device; mod device;
pub use self::device::Device; pub use self::device::Device;

View file

@ -1,7 +1,7 @@
use crate::traits::StreamTrait;
use crate::ChannelCount; use crate::ChannelCount;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use traits::StreamTrait;
use crate::{ use crate::{
BackendSpecificError, Data, InputCallbackInfo, OutputCallbackInfo, PauseStreamError, BackendSpecificError, Data, InputCallbackInfo, OutputCallbackInfo, PauseStreamError,

View file

@ -1,10 +1,10 @@
use crate::traits::{DeviceTrait, HostTrait, StreamTrait};
use crate::{ use crate::{
BuildStreamError, Data, DefaultStreamConfigError, DeviceNameError, DevicesError, BuildStreamError, Data, DefaultStreamConfigError, DeviceNameError, DevicesError,
InputCallbackInfo, OutputCallbackInfo, PauseStreamError, PlayStreamError, SampleFormat, InputCallbackInfo, OutputCallbackInfo, PauseStreamError, PlayStreamError, SampleFormat,
StreamConfig, StreamError, SupportedStreamConfig, SupportedStreamConfigRange, StreamConfig, StreamError, SupportedStreamConfig, SupportedStreamConfigRange,
SupportedStreamConfigsError, SupportedStreamConfigsError,
}; };
use traits::{DeviceTrait, HostTrait, StreamTrait};
#[derive(Default)] #[derive(Default)]
pub struct Devices; pub struct Devices;

View file

@ -6,10 +6,10 @@ pub use self::device::{
}; };
pub use self::stream::Stream; pub use self::stream::Stream;
use self::winapi::um::winnt::HRESULT; use self::winapi::um::winnt::HRESULT;
use crate::traits::HostTrait;
use crate::BackendSpecificError;
use crate::DevicesError;
use std::io::Error as IoError; use std::io::Error as IoError;
use traits::HostTrait;
use BackendSpecificError;
use DevicesError;
mod com; mod com;
mod device; mod device;

View file

@ -6,6 +6,7 @@ use self::js_sys::eval;
use self::wasm_bindgen::prelude::*; use self::wasm_bindgen::prelude::*;
use self::wasm_bindgen::JsCast; use self::wasm_bindgen::JsCast;
use self::web_sys::{AudioContext, AudioContextOptions}; use self::web_sys::{AudioContext, AudioContextOptions};
use crate::traits::{DeviceTrait, HostTrait, StreamTrait};
use crate::{ use crate::{
BackendSpecificError, BufferSize, BuildStreamError, Data, DefaultStreamConfigError, BackendSpecificError, BufferSize, BuildStreamError, Data, DefaultStreamConfigError,
DeviceNameError, DevicesError, InputCallbackInfo, OutputCallbackInfo, PauseStreamError, DeviceNameError, DevicesError, InputCallbackInfo, OutputCallbackInfo, PauseStreamError,
@ -14,7 +15,6 @@ use crate::{
}; };
use std::ops::DerefMut; use std::ops::DerefMut;
use std::sync::{Arc, Mutex, RwLock}; use std::sync::{Arc, Mutex, RwLock};
use traits::{DeviceTrait, HostTrait, StreamTrait};
/// Content is false if the iterator is empty. /// Content is false if the iterator is empty.
pub struct Devices(bool); pub struct Devices(bool);

View file

@ -1,6 +1,6 @@
//! The suite of traits allowing CPAL to abstract over hosts, devices, event loops and stream IDs. //! The suite of traits allowing CPAL to abstract over hosts, devices, event loops and stream IDs.
use { use crate::{
BuildStreamError, Data, DefaultStreamConfigError, DeviceNameError, DevicesError, BuildStreamError, Data, DefaultStreamConfigError, DeviceNameError, DevicesError,
InputCallbackInfo, InputDevices, OutputCallbackInfo, OutputDevices, PauseStreamError, InputCallbackInfo, InputDevices, OutputCallbackInfo, OutputDevices, PauseStreamError,
PlayStreamError, Sample, SampleFormat, StreamConfig, StreamError, SupportedStreamConfig, PlayStreamError, Sample, SampleFormat, StreamConfig, StreamError, SupportedStreamConfig,