Fix some typo and warnings

This commit is contained in:
Rémi Lauzier 2021-06-28 11:55:15 -04:00
parent 5bbfa4992e
commit ba462dad18
No known key found for this signature in database
GPG key ID: D4B9ECD143336C1D
28 changed files with 98 additions and 98 deletions

View file

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

View file

@ -129,7 +129,7 @@ impl TriggerSender {
fn wakeup(&self) {
let buf = 1u64;
let ret = unsafe { libc::write(self.0, &buf as *const u64 as *const _, 8) };
assert!(ret == 8);
assert_eq!(ret, 8);
}
}
@ -459,7 +459,7 @@ impl Device {
return Err(DefaultStreamConfigError::DeviceNotAvailable);
}
Err(SupportedStreamConfigsError::InvalidArgument) => {
// this happens sometimes when querying for input and output capabilities but
// this happens sometimes when querying for input and output capabilities, but
// the device supports only one
return Err(DefaultStreamConfigError::StreamTypeNotSupported);
}
@ -997,7 +997,7 @@ fn set_hw_params_from_format(
}
BufferSize::Default => {
// These values together represent a moderate latency and wakeup interval.
// Without them we are at the mercy of the device
// Without them, we are at the mercy of the device
hw_params.set_period_time_near(25_000, alsa::ValueOr::Nearest)?;
hw_params.set_buffer_time_near(100_000, alsa::ValueOr::Nearest)?;
}

View file

@ -23,7 +23,7 @@ pub struct Device {
pub driver: Arc<sys::Driver>,
// Input and/or Output stream.
// An driver can only have one of each.
// A driver can only have one of each.
// They need to be created at the same time.
pub asio_streams: Arc<Mutex<sys::AsioStreams>>,
}

View file

@ -24,7 +24,7 @@ trait AsioSample: Clone + Copy + Silence + std::ops::Add<Self, Output = Self> {
fn from_cpal_sample<T: Sample>(&T) -> Self;
}
// Used to keep track of whether or not the current current asio stream buffer requires
// Used to keep track of whether or not the current asio stream buffer requires
// being silencing before summing audio.
#[derive(Default)]
struct SilenceAsioBuffer {

View file

@ -1,5 +1,5 @@
//!
//! coreaudio on iOS looks a bit different than on macOS. A lot of configuration needs to use
//! coreaudio on iOS looks a bit different from macOS. A lot of configuration needs to use
//! the AVAudioSession objc API which doesn't exist on macOS.
//!
//! TODO:

View file

@ -245,7 +245,7 @@ impl Device {
}
// TODO: macOS should support U8, I16, I32, F32 and F64. This should allow for using
// I16 but just use F32 for now as its the default anyway.
// I16 but just use F32 for now as it's the default anyway.
let sample_format = SampleFormat::F32;
// Get available sample rate ranges.
@ -535,7 +535,7 @@ impl Device {
// Setting the sample rate of a device is an asynchronous process in coreaudio.
//
// Thus we are required to set a `listener` so that we may be notified when the
// Thus, we are required to set a `listener` so that we may be notified when the
// change occurs.
unsafe extern "C" fn rate_listener(
device_id: AudioObjectID,

View file

@ -47,7 +47,7 @@ const MIN_SAMPLE_RATE: SampleRate = SampleRate(8_000);
const MAX_SAMPLE_RATE: SampleRate = SampleRate(96_000);
const DEFAULT_SAMPLE_RATE: SampleRate = SampleRate(44_100);
const MIN_BUFFER_SIZE: u32 = 1;
const MAX_BUFFER_SIZE: u32 = std::u32::MAX;
const MAX_BUFFER_SIZE: u32 = u32::MAX;
const DEFAULT_BUFFER_SIZE: usize = 2048;
const SUPPORTED_SAMPLE_FORMAT: SampleFormat = SampleFormat::F32;
@ -249,7 +249,7 @@ impl StreamTrait for Stream {
}
}
// The first argument of the callback function (a `void*`) is a casted pointer to `self`
// The first argument of the callback function (a `void*`) is a cast pointer to `self`
// and to the `callback` parameter that was passed to `run`.
fn audio_callback_fn<D, E>(
user_data_ptr: *mut c_void,
@ -282,7 +282,7 @@ fn audio_callback_fn<D, E>(
.try_into()
.expect("failed to retrieve Value as f64");
let callback = crate::StreamInstant::from_secs_f64(now_secs);
// TODO: Use proper latency instead. Currently unsupported on most browsers though so
// TODO: Use proper latency instead. Currently, unsupported on most browsers though, so
// we estimate based on buffer size instead. Probably should use this, but it's only
// supported by firefox (2020-04-28).
// let latency_secs: f64 = js!(@{audio_ctxt}.outputLatency).try_into().unwrap();

View file

@ -44,7 +44,7 @@ impl Device {
let client_options = super::get_client_options(start_server_automatically);
// Create a dummy client to find out the sample rate of the server to be able to provide it as a possible config.
// This client will be dropped and a new one will be created when making the stream.
// This client will be dropped, and a new one will be created when making the stream.
// This is a hack due to the fact that the Client must be moved to create the AsyncClient.
match super::get_client(&name, client_options) {
Ok(client) => Ok(Device {
@ -95,7 +95,7 @@ impl Device {
let channels = DEFAULT_NUM_CHANNELS;
let sample_rate = self.sample_rate;
let buffer_size = self.buffer_size.clone();
// The sample format for JACK audio ports is always "32 bit float mono audio" in the current implementation.
// The sample format for JACK audio ports is always "32-bit float mono audio" in the current implementation.
// Custom formats are allowed within JACK, but this is of niche interest.
// The format can be found programmatically by calling jack::PortSpec::port_type() on a created port.
let sample_format = JACK_SAMPLE_FORMAT;
@ -158,14 +158,14 @@ impl DeviceTrait for Device {
}
/// Returns the default input config
/// The sample format for JACK audio ports is always "32 bit float mono audio" unless using a custom type.
/// The sample format for JACK audio ports is always "32-bit float mono audio" unless using a custom type.
/// The sample rate is set by the JACK server.
fn default_input_config(&self) -> Result<SupportedStreamConfig, DefaultStreamConfigError> {
self.default_config()
}
/// Returns the default output config
/// The sample format for JACK audio ports is always "32 bit float mono audio" unless using a custom type.
/// The sample format for JACK audio ports is always "32-bit float mono audio" unless using a custom type.
/// The sample rate is set by the JACK server.
fn default_output_config(&self) -> Result<SupportedStreamConfig, DefaultStreamConfigError> {
self.default_config()

View file

@ -91,8 +91,8 @@ impl Host {
}
impl HostTrait for Host {
type Device = Device;
type Devices = Devices;
type Device = Device;
/// JACK is available if
/// - the jack feature flag is set

View file

@ -228,7 +228,7 @@ struct LocalProcessHandler {
input_data_callback: Option<Box<dyn FnMut(&Data, &InputCallbackInfo) + Send + 'static>>,
output_data_callback: Option<Box<dyn FnMut(&mut Data, &OutputCallbackInfo) + Send + 'static>>,
// JACK audio samples are 32 bit float (unless you do some custom dark magic)
// JACK audio samples are 32-bit float (unless you do some custom dark magic)
temp_input_buffer: Vec<f32>,
temp_output_buffer: Vec<f32>,
playing: Arc<AtomicBool>,

View file

@ -98,8 +98,8 @@ impl DeviceTrait for Device {
}
impl HostTrait for Host {
type Device = Device;
type Devices = Devices;
type Device = Device;
fn is_available() -> bool {
false

View file

@ -48,6 +48,22 @@ where
{
type FrameType = (T, C);
fn on_error_before_close(
&mut self,
_audio_stream: &mut dyn oboe::AudioInputStreamSafe,
error: oboe::Error,
) {
(self.error_cb)(StreamError::from(error))
}
fn on_error_after_close(
&mut self,
_audio_stream: &mut dyn oboe::AudioInputStreamSafe,
error: oboe::Error,
) {
(self.error_cb)(StreamError::from(error))
}
fn on_audio_ready(
&mut self,
audio_stream: &mut dyn oboe::AudioInputStreamSafe,
@ -71,20 +87,4 @@ where
);
oboe::DataCallbackResult::Continue
}
fn on_error_before_close(
&mut self,
_audio_stream: &mut dyn oboe::AudioInputStreamSafe,
error: oboe::Error,
) {
(self.error_cb)(StreamError::from(error))
}
fn on_error_after_close(
&mut self,
_audio_stream: &mut dyn oboe::AudioInputStreamSafe,
error: oboe::Error,
) {
(self.error_cb)(StreamError::from(error))
}
}

View file

@ -48,6 +48,22 @@ where
{
type FrameType = (T, C);
fn on_error_before_close(
&mut self,
_audio_stream: &mut dyn oboe::AudioOutputStreamSafe,
error: oboe::Error,
) {
(self.error_cb)(StreamError::from(error))
}
fn on_error_after_close(
&mut self,
_audio_stream: &mut dyn oboe::AudioOutputStreamSafe,
error: oboe::Error,
) {
(self.error_cb)(StreamError::from(error))
}
fn on_audio_ready(
&mut self,
audio_stream: &mut dyn oboe::AudioOutputStreamSafe,
@ -71,20 +87,4 @@ where
);
oboe::DataCallbackResult::Continue
}
fn on_error_before_close(
&mut self,
_audio_stream: &mut dyn oboe::AudioOutputStreamSafe,
error: oboe::Error,
) {
(self.error_cb)(StreamError::from(error))
}
fn on_error_after_close(
&mut self,
_audio_stream: &mut dyn oboe::AudioOutputStreamSafe,
error: oboe::Error,
) {
(self.error_cb)(StreamError::from(error))
}
}

View file

@ -232,7 +232,7 @@ pub unsafe fn is_format_supported(
}
// `IsFormatSupported` can return `S_FALSE` (which means that a compatible format
// has been found) but we also treat this as an error
// has been found), but we also treat this as an error
match (hresult, check_result(hresult)) {
(_, Err(ref e))
if e.raw_os_error() == Some(AUDCLNT_E_DEVICE_INVALIDATED) => {
@ -436,8 +436,8 @@ impl Device {
// querying them via `IsFormatSupported`.
//
// When calling `IsFormatSupported` with the shared-mode audio engine, only the default
// number of channels seems to be supported. Any more or less returns an invalid
// parameter error. Thus we just assume that the default number of channels is the only
// number of channels seems to be supported. Any, more or less returns an invalid
// parameter error. Thus, we just assume that the default number of channels is the only
// number supported.
fn supported_formats(&self) -> Result<SupportedInputConfigs, SupportedStreamConfigsError> {
// initializing COM because we call `CoTaskMemFree` to release the format.
@ -482,7 +482,7 @@ impl Device {
let mut test_format = {
match WaveFormat::copy_from_waveformatex_ptr(default_waveformatex_ptr.0) {
Some(f) => f,
// If the format is neither EX or EXTENSIBLE we don't know how to work with it.
// If the format is neither EX nor EXTENSIBLE we don't know how to work with it.
None => return Ok(vec![].into_iter()),
}
};
@ -650,7 +650,7 @@ impl Device {
match config.buffer_size {
BufferSize::Fixed(_) => {
// TO DO: We need IAudioClient3 to get buffersize ranges first
// Otherwise the supported ranges are unknown. In the mean time
// Otherwise the supported ranges are unknown. In the meantime
// the smallest buffersize is selected and used.
return Err(BuildStreamError::StreamConfigNotSupported);
}
@ -676,7 +676,7 @@ impl Device {
_ => (),
}
// finally initializing the audio client
// Finally, initializing the audio client
let hresult = (*audio_client).Initialize(
share_mode,
stream_flags,
@ -818,7 +818,7 @@ impl Device {
match config.buffer_size {
BufferSize::Fixed(_) => {
// TO DO: We need IAudioClient3 to get buffersize ranges first
// Otherwise the supported ranges are unknown. In the mean time
// Otherwise the supported ranges are unknown. In the meantime
// the smallest buffersize is selected and used.
return Err(BuildStreamError::StreamConfigNotSupported);
}
@ -838,7 +838,7 @@ impl Device {
_ => (),
}
// finally initializing the audio client
// Finally, initializing the audio client
let hresult = (*audio_client).Initialize(
share_mode,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK,
@ -1092,7 +1092,7 @@ lazy_static! {
};
}
/// RAII object around `IMMDeviceEnumerator`.
/// RAII objects around `IMMDeviceEnumerator`.
struct Enumerator(*mut IMMDeviceEnumerator);
unsafe impl Send for Enumerator {}

View file

@ -34,7 +34,7 @@ impl HostTrait for Host {
type Device = Device;
fn is_available() -> bool {
// Assume WASAPI is always available on windows.
// Assume WASAPI is always available on Windows.
true
}

View file

@ -40,7 +40,7 @@ const MIN_SAMPLE_RATE: SampleRate = SampleRate(8_000);
const MAX_SAMPLE_RATE: SampleRate = SampleRate(96_000);
const DEFAULT_SAMPLE_RATE: SampleRate = SampleRate(44_100);
const MIN_BUFFER_SIZE: u32 = 1;
const MAX_BUFFER_SIZE: u32 = std::u32::MAX;
const MAX_BUFFER_SIZE: u32 = u32::MAX;
const DEFAULT_BUFFER_SIZE: usize = 2048;
const SUPPORTED_SAMPLE_FORMAT: SampleFormat = SampleFormat::F32;
@ -234,7 +234,7 @@ impl DeviceTrait for Device {
let time = Arc::new(RwLock::new(0f64));
// Create a set of closures / callbacks which will continuously fetch and schedule sample
// playback. Starting with two workers, eg a front and back buffer so that audio frames
// playback. Starting with two workers, e.g. a front and back buffer so that audio frames
// can be fetched in the background.
for _i in 0..2 {
let data_callback_handle = data_callback.clone();
@ -297,7 +297,7 @@ impl DeviceTrait for Device {
}
// Deinterleave the sample data and copy into the audio context buffer.
// We do not reference the audio context buffer directly eg getChannelData.
// We do not reference the audio context buffer directly e.g. getChannelData.
// As wasm-bindgen only gives us a copy, not a direct reference.
for channel in 0..n_channels {
for i in 0..buffer_size_frames {