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
|
||||
// otherwise set the asio config flag
|
||||
match env::var(CPAL_ASIO_DIR) {
|
||||
Err(_) => return,
|
||||
Err(_) => {},
|
||||
Ok(_) => println!("cargo:rustc-cfg=asio"),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ pub fn default_input_device() -> Option<Device> {
|
|||
}
|
||||
|
||||
let device = Device {
|
||||
audio_device_id: audio_device_id,
|
||||
audio_device_id,
|
||||
};
|
||||
Some(device)
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ pub fn default_output_device() -> Option<Device> {
|
|||
}
|
||||
|
||||
let device = Device {
|
||||
audio_device_id: audio_device_id,
|
||||
audio_device_id,
|
||||
};
|
||||
Some(device)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ impl Device {
|
|||
check_os_status(status)?;
|
||||
|
||||
let c_string: *const c_char = CFStringGetCStringPtr(device_name, kCFStringEncodingUTF8);
|
||||
if c_string == null() {
|
||||
if c_string.is_null() {
|
||||
let status = AudioObjectGetPropertyData(
|
||||
self.audio_device_id,
|
||||
&property_address as *const _,
|
||||
|
|
@ -192,6 +192,7 @@ impl Device {
|
|||
}
|
||||
|
||||
// Logic re-used between `supported_input_configs` and `supported_output_configs`.
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
fn supported_configs(
|
||||
&self,
|
||||
scope: AudioObjectPropertyScope,
|
||||
|
|
@ -289,7 +290,7 @@ impl Device {
|
|||
min_sample_rate: SampleRate(range.mMinimum as _),
|
||||
max_sample_rate: SampleRate(range.mMaximum as _),
|
||||
buffer_size: buffer_size.clone(),
|
||||
sample_format: sample_format,
|
||||
sample_format,
|
||||
};
|
||||
fmts.push(fmt);
|
||||
}
|
||||
|
|
@ -386,8 +387,8 @@ impl Device {
|
|||
let config = SupportedStreamConfig {
|
||||
sample_rate: SampleRate(asbd.mSampleRate as _),
|
||||
channels: asbd.mChannelsPerFrame as _,
|
||||
buffer_size: buffer_size,
|
||||
sample_format: sample_format,
|
||||
buffer_size,
|
||||
sample_format,
|
||||
};
|
||||
Ok(config)
|
||||
}
|
||||
|
|
@ -470,7 +471,7 @@ fn asbd_from_config(
|
|||
SampleFormat::F32 => (kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked) as u32,
|
||||
_ => kAudioFormatFlagIsPacked as u32,
|
||||
};
|
||||
let asbd = AudioStreamBasicDescription {
|
||||
AudioStreamBasicDescription {
|
||||
mBitsPerChannel: bits_per_channel as _,
|
||||
mBytesPerFrame: bytes_per_frame as _,
|
||||
mChannelsPerFrame: n_channels as _,
|
||||
|
|
@ -480,8 +481,7 @@ fn asbd_from_config(
|
|||
mFormatID: kAudioFormatLinearPCM,
|
||||
mSampleRate: sample_rate as _,
|
||||
..Default::default()
|
||||
};
|
||||
asbd
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
#[allow(clippy::while_immutable_condition)]
|
||||
#[allow(clippy::float_cmp)]
|
||||
fn build_input_stream_raw<D, E>(
|
||||
&self,
|
||||
config: &StreamConfig,
|
||||
|
|
@ -656,6 +659,10 @@ impl Device {
|
|||
// 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.
|
||||
//
|
||||
// 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();
|
||||
while sample_rate != reported_rate {
|
||||
if timer.elapsed() > Duration::from_secs(1) {
|
||||
|
|
|
|||
|
|
@ -423,6 +423,7 @@ impl OutputCallbackInfo {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::len_without_is_empty)]
|
||||
impl Data {
|
||||
// Internal constructor for host implementations to use.
|
||||
//
|
||||
|
|
@ -457,7 +458,7 @@ impl Data {
|
|||
pub fn len(&self) -> usize {
|
||||
self.len
|
||||
}
|
||||
|
||||
|
||||
/// The raw slice of memory representing the underlying audio data as a slice of bytes.
|
||||
///
|
||||
/// It is up to the user to interpret the slice of memory based on `Data::sample_format`.
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ impl SampleFormat {
|
|||
/// Returns the size in bytes of a sample of this format.
|
||||
#[inline]
|
||||
pub fn sample_size(&self) -> usize {
|
||||
match self {
|
||||
&SampleFormat::I16 => mem::size_of::<i16>(),
|
||||
&SampleFormat::U16 => mem::size_of::<u16>(),
|
||||
&SampleFormat::F32 => mem::size_of::<f32>(),
|
||||
match *self {
|
||||
SampleFormat::I16 => mem::size_of::<i16>(),
|
||||
SampleFormat::U16 => mem::size_of::<u16>(),
|
||||
SampleFormat::F32 => mem::size_of::<f32>(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue