Eliminate or suppress Clippy messages.
This commit is contained in:
parent
997fb9fa8a
commit
17e079d15d
5 changed files with 23 additions and 15 deletions
2
build.rs
2
build.rs
|
|
@ -6,7 +6,7 @@ fn main() {
|
||||||
// If ASIO directory isn't set silently return early
|
// If ASIO directory isn't set silently return early
|
||||||
// otherwise set the asio config flag
|
// otherwise set the asio config flag
|
||||||
match env::var(CPAL_ASIO_DIR) {
|
match env::var(CPAL_ASIO_DIR) {
|
||||||
Err(_) => return,
|
Err(_) => {},
|
||||||
Ok(_) => println!("cargo:rustc-cfg=asio"),
|
Ok(_) => println!("cargo:rustc-cfg=asio"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ pub fn default_input_device() -> Option<Device> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let device = Device {
|
let device = Device {
|
||||||
audio_device_id: audio_device_id,
|
audio_device_id,
|
||||||
};
|
};
|
||||||
Some(device)
|
Some(device)
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +138,7 @@ pub fn default_output_device() -> Option<Device> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let device = Device {
|
let device = Device {
|
||||||
audio_device_id: audio_device_id,
|
audio_device_id,
|
||||||
};
|
};
|
||||||
Some(device)
|
Some(device)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ impl Device {
|
||||||
check_os_status(status)?;
|
check_os_status(status)?;
|
||||||
|
|
||||||
let c_string: *const c_char = CFStringGetCStringPtr(device_name, kCFStringEncodingUTF8);
|
let c_string: *const c_char = CFStringGetCStringPtr(device_name, kCFStringEncodingUTF8);
|
||||||
if c_string == null() {
|
if c_string.is_null() {
|
||||||
let status = AudioObjectGetPropertyData(
|
let status = AudioObjectGetPropertyData(
|
||||||
self.audio_device_id,
|
self.audio_device_id,
|
||||||
&property_address as *const _,
|
&property_address as *const _,
|
||||||
|
|
@ -192,6 +192,7 @@ impl Device {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logic re-used between `supported_input_configs` and `supported_output_configs`.
|
// Logic re-used between `supported_input_configs` and `supported_output_configs`.
|
||||||
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
fn supported_configs(
|
fn supported_configs(
|
||||||
&self,
|
&self,
|
||||||
scope: AudioObjectPropertyScope,
|
scope: AudioObjectPropertyScope,
|
||||||
|
|
@ -289,7 +290,7 @@ impl Device {
|
||||||
min_sample_rate: SampleRate(range.mMinimum as _),
|
min_sample_rate: SampleRate(range.mMinimum as _),
|
||||||
max_sample_rate: SampleRate(range.mMaximum as _),
|
max_sample_rate: SampleRate(range.mMaximum as _),
|
||||||
buffer_size: buffer_size.clone(),
|
buffer_size: buffer_size.clone(),
|
||||||
sample_format: sample_format,
|
sample_format,
|
||||||
};
|
};
|
||||||
fmts.push(fmt);
|
fmts.push(fmt);
|
||||||
}
|
}
|
||||||
|
|
@ -386,8 +387,8 @@ impl Device {
|
||||||
let config = SupportedStreamConfig {
|
let config = SupportedStreamConfig {
|
||||||
sample_rate: SampleRate(asbd.mSampleRate as _),
|
sample_rate: SampleRate(asbd.mSampleRate as _),
|
||||||
channels: asbd.mChannelsPerFrame as _,
|
channels: asbd.mChannelsPerFrame as _,
|
||||||
buffer_size: buffer_size,
|
buffer_size,
|
||||||
sample_format: sample_format,
|
sample_format,
|
||||||
};
|
};
|
||||||
Ok(config)
|
Ok(config)
|
||||||
}
|
}
|
||||||
|
|
@ -470,7 +471,7 @@ fn asbd_from_config(
|
||||||
SampleFormat::F32 => (kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked) as u32,
|
SampleFormat::F32 => (kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked) as u32,
|
||||||
_ => kAudioFormatFlagIsPacked as u32,
|
_ => kAudioFormatFlagIsPacked as u32,
|
||||||
};
|
};
|
||||||
let asbd = AudioStreamBasicDescription {
|
AudioStreamBasicDescription {
|
||||||
mBitsPerChannel: bits_per_channel as _,
|
mBitsPerChannel: bits_per_channel as _,
|
||||||
mBytesPerFrame: bytes_per_frame as _,
|
mBytesPerFrame: bytes_per_frame as _,
|
||||||
mChannelsPerFrame: n_channels as _,
|
mChannelsPerFrame: n_channels as _,
|
||||||
|
|
@ -480,8 +481,7 @@ fn asbd_from_config(
|
||||||
mFormatID: kAudioFormatLinearPCM,
|
mFormatID: kAudioFormatLinearPCM,
|
||||||
mSampleRate: sample_rate as _,
|
mSampleRate: sample_rate as _,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
}
|
||||||
asbd
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn audio_unit_from_device(device: &Device, input: bool) -> Result<AudioUnit, coreaudio::Error> {
|
fn audio_unit_from_device(device: &Device, input: bool) -> Result<AudioUnit, coreaudio::Error> {
|
||||||
|
|
@ -528,6 +528,9 @@ fn audio_unit_from_device(device: &Device, input: bool) -> Result<AudioUnit, cor
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Device {
|
impl Device {
|
||||||
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
|
#[allow(clippy::while_immutable_condition)]
|
||||||
|
#[allow(clippy::float_cmp)]
|
||||||
fn build_input_stream_raw<D, E>(
|
fn build_input_stream_raw<D, E>(
|
||||||
&self,
|
&self,
|
||||||
config: &StreamConfig,
|
config: &StreamConfig,
|
||||||
|
|
@ -656,6 +659,10 @@ impl Device {
|
||||||
// Wait for the reported_rate to change.
|
// Wait for the reported_rate to change.
|
||||||
//
|
//
|
||||||
// This should not take longer than a few ms, but we timeout after 1 sec just in case.
|
// This should not take longer than a few ms, but we timeout after 1 sec just in case.
|
||||||
|
//
|
||||||
|
// WARNING: a reference to reported_rate is unsafely captured above,
|
||||||
|
// and the loop below assumes it can change - but compiler does not know that!
|
||||||
|
//
|
||||||
let timer = ::std::time::Instant::now();
|
let timer = ::std::time::Instant::now();
|
||||||
while sample_rate != reported_rate {
|
while sample_rate != reported_rate {
|
||||||
if timer.elapsed() > Duration::from_secs(1) {
|
if timer.elapsed() > Duration::from_secs(1) {
|
||||||
|
|
|
||||||
|
|
@ -423,6 +423,7 @@ impl OutputCallbackInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::len_without_is_empty)]
|
||||||
impl Data {
|
impl Data {
|
||||||
// Internal constructor for host implementations to use.
|
// Internal constructor for host implementations to use.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@ impl SampleFormat {
|
||||||
/// Returns the size in bytes of a sample of this format.
|
/// Returns the size in bytes of a sample of this format.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn sample_size(&self) -> usize {
|
pub fn sample_size(&self) -> usize {
|
||||||
match self {
|
match *self {
|
||||||
&SampleFormat::I16 => mem::size_of::<i16>(),
|
SampleFormat::I16 => mem::size_of::<i16>(),
|
||||||
&SampleFormat::U16 => mem::size_of::<u16>(),
|
SampleFormat::U16 => mem::size_of::<u16>(),
|
||||||
&SampleFormat::F32 => mem::size_of::<f32>(),
|
SampleFormat::F32 => mem::size_of::<f32>(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue